From 183331ccf1aa3f4142697e9e37528f084fae7466 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Mon, 13 Feb 2017 16:57:19 -0500 Subject: rip skirl --- entityx/Entity.cc | 5 +++++ entityx/Entity.h | 16 ++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) (limited to 'entityx') diff --git a/entityx/Entity.cc b/entityx/Entity.cc index adac3de..476def7 100644 --- a/entityx/Entity.cc +++ b/entityx/Entity.cc @@ -27,6 +27,11 @@ void Entity::destroy() { invalidate(); } +void Entity::kill(void) { + assign(); +} + + std::bitset Entity::component_mask() const { return manager_->component_mask(id_); } diff --git a/entityx/Entity.h b/entityx/Entity.h index a423f8f..e7d2e8d 100644 --- a/entityx/Entity.h +++ b/entityx/Entity.h @@ -46,7 +46,7 @@ class EntityManager; template class ComponentHandle; - +struct Killed {}; /** A convenience handle around an Entity::Id. * @@ -166,6 +166,8 @@ public: std::bitset component_mask() const; + void kill(); + private: EntityManager *manager_ = nullptr; Entity::Id id_ = INVALID; @@ -462,11 +464,13 @@ class EntityManager : entityx::help::NonCopyable { public: template struct identity { typedef T type; }; - void each(typename identity>::type f) { + void each(typename identity>::type f, bool dead = false) { static std::mutex locked; locked.lock(); - for (auto it : *this) - f(it, *(it.template component().get())...); + for (auto it : *this) { + if (dead || !it.has_component()) + f(it, *(it.template component().get())...); + } locked.unlock(); } @@ -766,8 +770,8 @@ class EntityManager : entityx::help::NonCopyable { template struct identity { typedef T type; }; template - void each(typename identity>::type f) { - return entities_with_components().each(f); + void each(typename identity>::type f, bool dead = false) { + return entities_with_components().each(f, dead); } /** -- cgit v1.2.3