Had a mistake where I wasn't tracking the live->dead transition it the new code.
This commit is contained in:
parent
e35e362846
commit
2a92687bc9
3 changed files with 10 additions and 17 deletions
|
|
@ -191,15 +191,18 @@ void System::death() {
|
|||
std::vector<Entity> dead_things;
|
||||
|
||||
world.query<Combat>([&](auto ent, auto &combat) {
|
||||
// bring out yer dead
|
||||
if(combat.is_dead()) {
|
||||
// bring out yer dead, have to do it here to notify on the transition from
|
||||
// live -> dead
|
||||
if(!combat.has_died && combat.is_dead()) {
|
||||
combat.has_died = true;
|
||||
|
||||
if(ent != player.entity) {
|
||||
// we won't change out the player's components later
|
||||
dead_things.push_back(ent);
|
||||
}
|
||||
// we need to send this event for everything that dies
|
||||
world.send<game::Event>(game::Event::DEATH, ent, {});
|
||||
} else if(float(combat.hp) / float(combat.max_hp) < 0.5f) {
|
||||
} else if(combat.almost_dead()) {
|
||||
// if enemies are below 50% health they are marked with bad health
|
||||
if(world.has<ai::EntityAI>(ent)) {
|
||||
auto& enemy_ai = world.get<ai::EntityAI>(ent);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue