From 27c73de6ed172c9db99037a8b8ce87bbfe326615 Mon Sep 17 00:00:00 2001 From: EternalRat <44569175+EternalRat@users.noreply.github.com> Date: Wed, 2 Jun 2021 18:26:40 +0200 Subject: [PATCH] include collisioncomponent missing --- sources/Bonus/Bonus.cpp | 33 +++++++++++++------------- sources/Bonus/Bonus.hpp | 30 +++++++++++------------ sources/System/Health/HealthSystem.cpp | 7 +++--- 3 files changed, 36 insertions(+), 34 deletions(-) diff --git a/sources/Bonus/Bonus.cpp b/sources/Bonus/Bonus.cpp index 4d43997d..bf72e3bc 100644 --- a/sources/Bonus/Bonus.cpp +++ b/sources/Bonus/Bonus.cpp @@ -2,42 +2,43 @@ // Created by HENRY Benjamin on 02/06/2021. // +#include "Component/Movable/MovableComponent.hpp" #include "Bonus.hpp" //#include "Component/BombHolderComponent/BombHolderComponent.hpp" namespace BBM { - void Bonus::BombUpBonus(const WAL::Entity &entity, const WAL::Entity &other) + void Bonus::BombUpBonus(WAL::Entity &entity, const WAL::Entity &other) { - auto &bombHolder = other.getComponent(); - bombHolder.maxBombCount++; - //entity.scheduleDeletion(true); + //auto &bombHolder = entity.getComponent(); + //bombHolder.maxBombCount++; + //other.scheduleDeletion(true); } - void Bonus::DamageIncreasedBonus(const WAL::Entity &entity, const WAL::Entity &other) + void Bonus::DamageIncreasedBonus(WAL::Entity &entity, const WAL::Entity &other) { - auto &bombHolder = other.getComponent(); + //auto &bombHolder = entity.getComponent(); //bombHolder.damage++; - //entity.scheduleDeletion(true); + //other.scheduleDeletion(true); } - void Bonus::ExplosionRangeBonus(const WAL::Entity &entity, const WAL::Entity &other) + void Bonus::ExplosionRangeBonus(WAL::Entity &entity, const WAL::Entity &other) { - auto &bombHolder = other.getComponent(); + //auto &bombHolder = entity.getComponent(); //bombHolder.explosionRange++; - //entity.scheduleDeletion(true); + //other.scheduleDeletion(true); } - void Bonus::SpeedUpBonus(const WAL::Entity &entity, const WAL::Entity &other) + void Bonus::SpeedUpBonus(WAL::Entity &entity, const WAL::Entity &other) { - auto &movable = other.getComponent(); + auto &movable = entity.getComponent(); movable.addForce(Vector3f(1, 0, 1)); - //entity.scheduleDeletion(true); + //other.scheduleDeletion(true); } - void Bonus::IgnoreWallsBonus(const WAL::Entity &entity, const WAL::Entity &other) + void Bonus::IgnoreWallsBonus(WAL::Entity &entity, const WAL::Entity &other) { - auto &bombHolder = other.getComponent(); + //auto &bombHolder = entity.getComponent(); //bombHolder.ignoreWall = false; - //entity.scheduleDeletion(true); + //other.scheduleDeletion(true); } } \ No newline at end of file diff --git a/sources/Bonus/Bonus.hpp b/sources/Bonus/Bonus.hpp index 4169e510..cc3c15d6 100644 --- a/sources/Bonus/Bonus.hpp +++ b/sources/Bonus/Bonus.hpp @@ -10,29 +10,29 @@ namespace BBM { class Bonus { public: - //! @param entity bonus - //! @param other the entity on which the effect will be applied + //! @param other bonus + //! @param entity 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(const WAL::Entity &entity, const WAL::Entity &other); + static void BombUpBonus(WAL::Entity &entity, const WAL::Entity &other); - //! @param entity bonus - //! @param other the entity on which the effect will be applied + //! @param other bonus + //! @param entity the entity on which the effect will be applied //! @brief Apply bonus effect who increased the bomb damage - static void DamageIncreasedBonus(const WAL::Entity &entity, const WAL::Entity &other); + static void DamageIncreasedBonus(WAL::Entity &entity, const WAL::Entity &other); - //! @param entity bonus - //! @param other the entity on which the effect will be applied + //! @param other bonus + //! @param entity the entity on which the effect will be applied //! @brief Apply bonus effect that expend the explosion range of the bomb - static void ExplosionRangeBonus(const WAL::Entity &entity, const WAL::Entity &other); + static void ExplosionRangeBonus(WAL::Entity &entity, const WAL::Entity &other); - //! @param entity bonus - //! @param other the entity on which the effect will be applied + //! @param other bonus + //! @param entity the entity on which the effect will be applied //! @brief Apply bonus effect that allows to run faster - static void SpeedUpBonus(const WAL::Entity &entity, const WAL::Entity &other); + static void SpeedUpBonus(WAL::Entity &entity, const WAL::Entity &other); - //! @param entity bonus - //! @param other the entity on which the effect will be applied + //! @param other bonus + //! @param entity the entity on which the effect will be applied //! @brief Apply bonus effect that allows bomb explosion to pass through walls - static void IgnoreWallsBonus(const WAL::Entity &entity, const WAL::Entity &other); + static void IgnoreWallsBonus(WAL::Entity &entity, const WAL::Entity &other); }; } \ No newline at end of file diff --git a/sources/System/Health/HealthSystem.cpp b/sources/System/Health/HealthSystem.cpp index 0f24ee91..d57e0c82 100644 --- a/sources/System/Health/HealthSystem.cpp +++ b/sources/System/Health/HealthSystem.cpp @@ -6,6 +6,7 @@ #include #include #include +#include "Component/Collision/CollisionComponent.hpp" #include "HealthSystem.hpp" #include "Component/Health/HealthComponent.hpp" #include "Component/Bonus/BonusComponent.hpp" @@ -25,14 +26,14 @@ namespace BBM void HealthSystem::_createBonus(Vector3f position, BonusComponent::BonusType bonusType, std::chrono::nanoseconds timer) { - std::map map = { + static std::map map = { {BonusComponent::BonusType::BOMBSTOCK, "assets/items/bombup"}, {BonusComponent::BonusType::SPEEDUP, "assets/items/speedup"}, //{BonusComponent::BonusType::EXPLOSIONINC, "assets/items/explosion"}, {BonusComponent::BonusType::DAMAGEINC, "assets/items/fireup"}, {BonusComponent::BonusType::IGNOREWALLS, "assets/items/wallpass"} }; - std::vector> func = { + static std::vector> func = { &Bonus::BombUpBonus, &Bonus::SpeedUpBonus, &Bonus::ExplosionRangeBonus, &Bonus::DamageIncreasedBonus, &Bonus::IgnoreWallsBonus }; @@ -43,7 +44,7 @@ namespace BBM this->_wal.scene->addEntity("Bonus") .addComponent(position) .addComponent(1) - //.addComponent(1, func[bonusType -1]) + .addComponent(func[bonusType - 1], [](WAL::Entity &, const WAL::Entity &){}, 5.0) //.addComponent(timer, &[](WAL::Entity &bonus){ // std::cout << "Bonus disappeared" << std::endl; // bonus.scheduleDeletion();