void Hurt(double d) noexcept;
void Die() noexcept;
+ bool Dead() const noexcept;
void OnDeath(Callback cb) noexcept { on_death = cb; }
void Remove() noexcept;
bool Removable() const noexcept { return removable; }
, mass(1.0)
, size(1.0)
, birth(sim.Time())
-, death(0.0)
+, death(-1.0)
, on_death()
, removable(false)
, parents()
}
void Creature::Die() noexcept {
+ if (Dead()) return;
+
sim.SetDead(this);
death = sim.Time();
steering.Halt();
Remove();
}
+bool Creature::Dead() const noexcept {
+ return death > birth;
+}
+
void Creature::Remove() noexcept {
removable = true;
}
void Cache() noexcept;
void CheckCollision() noexcept;
- // body takes over ownership of given pointer
void AddCreature(creature::Creature *);
void RemoveCreature(creature::Creature *);
std::vector<creature::Creature *> &Creatures() noexcept { return creatures; }