just miss timercomponent + bombholdercomponent now (using all callbacks from collisioncomponent)

This commit is contained in:
HENRY Benjamin
2021-06-03 09:51:35 +02:00
parent 27c73de6ed
commit 6134ab9352
3 changed files with 42 additions and 35 deletions
+24 -19
View File
@@ -7,38 +7,43 @@
//#include "Component/BombHolderComponent/BombHolderComponent.hpp"
namespace BBM {
void Bonus::BombUpBonus(WAL::Entity &entity, const WAL::Entity &other)
void Bonus::BombUpBonus(WAL::Entity &player, const WAL::Entity &bonus)
{
//auto &bombHolder = entity.getComponent<BombHolderComponent>();
//bombHolder.maxBombCount++;
//other.scheduleDeletion(true);
/* if (player.hasComponent<BombHolderComponent>()) {
auto &bombHolder = player.getComponent<BombHolderComponent>();
bombHolder.maxBombCount++;
} */
}
void Bonus::DamageIncreasedBonus(WAL::Entity &entity, const WAL::Entity &other)
void Bonus::DamageIncreasedBonus(WAL::Entity &player, const WAL::Entity &bonus)
{
//auto &bombHolder = entity.getComponent<BombHolderComponent>();
//bombHolder.damage++;
//other.scheduleDeletion(true);
/* if (player.hasComponent<BombHolderComponent>()) {
auto &bombHolder = player.getComponent<BombHolderComponent>();
bombHolder.damage++;
} */
}
void Bonus::ExplosionRangeBonus(WAL::Entity &entity, const WAL::Entity &other)
void Bonus::ExplosionRangeBonus(WAL::Entity &player, const WAL::Entity &bonus)
{
//auto &bombHolder = entity.getComponent<BombHolderComponent>();
//bombHolder.explosionRange++;
//other.scheduleDeletion(true);
/* if (player.hasComponent<BombHolderComponent>()) {
auto &bombHolder = player.getComponent<BombHolderComponent>();
bombHolder.explosionRange++;
} */
}
void Bonus::SpeedUpBonus(WAL::Entity &entity, const WAL::Entity &other)
void Bonus::SpeedUpBonus(WAL::Entity &player, const WAL::Entity &bonus)
{
auto &movable = entity.getComponent<MovableComponent>();
if (!player.hasComponent<MovableComponent>())
return;
auto &movable = player.getComponent<MovableComponent>();
movable.addForce(Vector3f(1, 0, 1));
//other.scheduleDeletion(true);
}
void Bonus::IgnoreWallsBonus(WAL::Entity &entity, const WAL::Entity &other)
void Bonus::IgnoreWallsBonus(WAL::Entity &player, const WAL::Entity &bonus)
{
//auto &bombHolder = entity.getComponent<BombHolderComponent>();
//bombHolder.ignoreWall = false;
//other.scheduleDeletion(true);
/* if (player.hasComponent<BombHolderComponent>()) {
auto &bombHolder = player.getComponent<BombHolderComponent>();
bombHolder.ignoreWalls = true;
} */
}
}
+15 -15
View File
@@ -10,29 +10,29 @@
namespace BBM {
class Bonus {
public:
//! @param other bonus
//! @param entity the entity on which the effect will be applied
//! @param bonus bonus
//! @param player the entity on which the effect will be applied
//! @brief Apply bonus effect that allows players to carry one more bomb than before
static void BombUpBonus(WAL::Entity &entity, const WAL::Entity &other);
static void BombUpBonus(WAL::Entity &player, const WAL::Entity &bonus);
//! @param other bonus
//! @param entity the entity on which the effect will be applied
//! @param bonus bonus
//! @param player the entity on which the effect will be applied
//! @brief Apply bonus effect who increased the bomb damage
static void DamageIncreasedBonus(WAL::Entity &entity, const WAL::Entity &other);
static void DamageIncreasedBonus(WAL::Entity &player, const WAL::Entity &bonus);
//! @param other bonus
//! @param entity the entity on which the effect will be applied
//! @param bonus bonus
//! @param player the entity on which the effect will be applied
//! @brief Apply bonus effect that expend the explosion range of the bomb
static void ExplosionRangeBonus(WAL::Entity &entity, const WAL::Entity &other);
static void ExplosionRangeBonus(WAL::Entity &player, const WAL::Entity &bonus);
//! @param other bonus
//! @param entity the entity on which the effect will be applied
//! @param bonus bonus
//! @param player the entity on which the effect will be applied
//! @brief Apply bonus effect that allows to run faster
static void SpeedUpBonus(WAL::Entity &entity, const WAL::Entity &other);
static void SpeedUpBonus(WAL::Entity &player, const WAL::Entity &bonus);
//! @param other bonus
//! @param entity the entity on which the effect will be applied
//! @param bonus bonus
//! @param player the entity on which the effect will be applied
//! @brief Apply bonus effect that allows bomb explosion to pass through walls
static void IgnoreWallsBonus(WAL::Entity &entity, const WAL::Entity &other);
static void IgnoreWallsBonus(WAL::Entity &player, const WAL::Entity &bonus);
};
}
+3 -1
View File
@@ -44,7 +44,9 @@ namespace BBM
this->_wal.scene->addEntity("Bonus")
.addComponent<PositionComponent>(position)
.addComponent<HealthComponent>(1)
.addComponent<CollisionComponent>(func[bonusType - 1], [](WAL::Entity &, const WAL::Entity &){}, 5.0)
.addComponent<CollisionComponent>([](WAL::Entity &bonus, const WAL::Entity &player) {
//bonus.scheduleDeletion(true);
}, func[bonusType - 1])
//.addComponent<TimerComponent>(timer, &[](WAL::Entity &bonus){
// std::cout << "Bonus disappeared" << std::endl;
// bonus.scheduleDeletion();