Adding a on death callback

This commit is contained in:
Zoe Roux
2021-05-31 20:14:07 +02:00
parent 345cc721f4
commit 87c5703c60
3 changed files with 7 additions and 3 deletions
@@ -6,6 +6,7 @@
#pragma once
#include <Models/Callback.hpp>
#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<WAL::Entity &> onDeath;
//! @brief add health to the entity
void addHealthPoint(unsigned int healthPoint);
+1 -1
View File
@@ -41,7 +41,7 @@ namespace BBM
void addSystems(WAL::Wal &wal)
{
wal.addSystem<KeyboardSystem>()
.addSystem<GamepadSystem>()
.addSystem<GamepadSystem>()
.addSystem<ControllableSystem>()
.addSystem<MovableSystem>();
}
+2 -2
View File
@@ -20,7 +20,7 @@ namespace BBM
{
auto &health = entity.getComponent<HealthComponent>();
if (health.getHealthPoint() == 0);
entity.setDisable(true);
if (health.getHealthPoint() == 0)
health.onDeath(entity);
}
}