aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlec Thomas <alec@swapoff.org>2012-10-27 09:16:29 -0400
committerAlec Thomas <alec@swapoff.org>2012-10-27 09:16:29 -0400
commit59f62b5c0df10be433b9380777e4d5a649d03d95 (patch)
tree433b39c8b609e37675feef9c823f2da5fc6e7fb2
parentb462654ab6d1345b0d256ccddd74794f311f8c7b (diff)
Add Entity::exists() and EntityManager::get().
-rw-r--r--entityx/Entity.cc4
-rw-r--r--entityx/Entity.h6
2 files changed, 10 insertions, 0 deletions
diff --git a/entityx/Entity.cc b/entityx/Entity.cc
index 89a83f7..6c43a06 100644
--- a/entityx/Entity.cc
+++ b/entityx/Entity.cc
@@ -15,4 +15,8 @@ namespace entityx {
BaseComponent::Family BaseComponent::family_counter_ = 0;
+bool Entity::exists() const {
+ return entities_.exists(id_);
+}
+
}
diff --git a/entityx/Entity.h b/entityx/Entity.h
index e763214..6d046c3 100644
--- a/entityx/Entity.h
+++ b/entityx/Entity.h
@@ -42,6 +42,8 @@ class Entity {
operator Id () { return id_; }
+ bool exists() const;
+
template <typename C>
boost::shared_ptr<C> assign(boost::shared_ptr<C> component);
template <typename C, typename ... Args>
@@ -328,6 +330,10 @@ class EntityManager : boost::noncopyable {
return free_list_.find(entity) == free_list_.end();
}
+ Entity get(Entity::Id id) {
+ return Entity(*this, id);
+ }
+
/**
* Assigns a previously constructed Component to an Entity::Id.
*