diff --git a/sources/Component/Health/HealthComponent.hpp b/sources/Component/Health/HealthComponent.hpp index a7c72c7f..2eadafc5 100644 --- a/sources/Component/Health/HealthComponent.hpp +++ b/sources/Component/Health/HealthComponent.hpp @@ -6,6 +6,7 @@ #pragma once +#include #include "Component/Component.hpp" #include "Entity/Entity.hpp" @@ -19,6 +20,9 @@ namespace BBM unsigned int _healthPoint; public: + //! @brief The callback invoked on this entity's death. + WAL::Callback onDeath; + //! @brief add health to the entity void addHealthPoint(unsigned int healthPoint); diff --git a/sources/Runner/Runner.cpp b/sources/Runner/Runner.cpp index c6a6c196..9e527fcb 100644 --- a/sources/Runner/Runner.cpp +++ b/sources/Runner/Runner.cpp @@ -41,7 +41,7 @@ namespace BBM void addSystems(WAL::Wal &wal) { wal.addSystem() - .addSystem() + .addSystem() .addSystem() .addSystem(); } diff --git a/sources/System/Health/HealthSystem.cpp b/sources/System/Health/HealthSystem.cpp index a3ecee88..90bbfbb9 100644 --- a/sources/System/Health/HealthSystem.cpp +++ b/sources/System/Health/HealthSystem.cpp @@ -20,7 +20,7 @@ namespace BBM { auto &health = entity.getComponent(); - if (health.getHealthPoint() == 0); - entity.setDisable(true); + if (health.getHealthPoint() == 0) + health.onDeath(entity); } } \ No newline at end of file