diff options
author | Daniel Guzman <daniel.guzman85@gmail.com> | 2016-04-06 18:10:54 +0200 |
---|---|---|
committer | Daniel Guzman <daniel.guzman85@gmail.com> | 2016-04-06 18:21:05 +0200 |
commit | dd2e781d38d34a574bb173f70bb20f0aa3439246 (patch) | |
tree | 4e1eddc72c4fbc2642772bee9dd6bb7c0ce4e5d9 | |
parent | ceeddb88ba08e8a94f160246bb8562715a3203a5 (diff) |
Added a function to retrieve the Entity associated with a component in ComponentHandle
-rw-r--r-- | entityx/Entity.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/entityx/Entity.h b/entityx/Entity.h index b55a45f..2382c11 100644 --- a/entityx/Entity.h +++ b/entityx/Entity.h @@ -201,6 +201,11 @@ public: */ void remove(); + /** + * Returns the Entity associated with the component + */ + Entity entity(); + bool operator == (const ComponentHandle<C> &other) const { return manager_ == other.manager_ && id_ == other.id_; } @@ -1036,6 +1041,12 @@ inline void ComponentHandle<C, EM>::remove() { manager_->template remove<C>(id_); } +template <typename C, typename EM> +inline Entity ComponentHandle<C, EM>::entity() { + assert(valid()); + return manager_->template get(id_); +} + } // namespace entityx |