X-Git-Url: http://git.localhorst.tv/?p=blobs.git;a=blobdiff_plain;f=src%2Fcreature%2Fcreature.cpp;h=3c03e576770d71ac2a5310c09c3176e9ffe6866c;hp=de82f86ad9a7db52924106735450f49ee8033a8c;hb=23f64a38a27866e88e87602cc6f8b11ef7173d6e;hpb=d364d8a9203138be1c569cdc31144f51883ec79f diff --git a/src/creature/creature.cpp b/src/creature/creature.cpp index de82f86..3c03e57 100644 --- a/src/creature/creature.cpp +++ b/src/creature/creature.cpp @@ -92,7 +92,7 @@ Creature::Creature(world::Simulation &sim) , mass(1.0) , size(1.0) , birth(sim.Time()) -, death(0.0) +, death(-1.0) , on_death() , removable(false) , parents() @@ -230,6 +230,8 @@ void Creature::Hurt(double amount) noexcept { } void Creature::Die() noexcept { + if (Dead()) return; + sim.SetDead(this); death = sim.Time(); steering.Halt(); @@ -239,6 +241,10 @@ void Creature::Die() noexcept { Remove(); } +bool Creature::Dead() const noexcept { + return death > birth; +} + void Creature::Remove() noexcept { removable = true; }