Had a mistake where I wasn't tracking the live->dead transition it the new code.

This commit is contained in:
Zed A. Shaw 2026-05-25 11:02:22 -04:00
parent e35e362846
commit 2a92687bc9
3 changed files with 10 additions and 17 deletions

View file

@ -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);