mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-05-27 00:06:49 +00:00
Adding a on death callback
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace BBM
|
||||
void addSystems(WAL::Wal &wal)
|
||||
{
|
||||
wal.addSystem<KeyboardSystem>()
|
||||
.addSystem<GamepadSystem>()
|
||||
.addSystem<GamepadSystem>()
|
||||
.addSystem<ControllableSystem>()
|
||||
.addSystem<MovableSystem>();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user