From dd2e781d38d34a574bb173f70bb20f0aa3439246 Mon Sep 17 00:00:00 2001 From: Daniel Guzman Date: Wed, 6 Apr 2016 18:10:54 +0200 Subject: Added a function to retrieve the Entity associated with a component in ComponentHandle --- entityx/Entity.h | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 &other) const { return manager_ == other.manager_ && id_ == other.id_; } @@ -1036,6 +1041,12 @@ inline void ComponentHandle::remove() { manager_->template remove(id_); } +template +inline Entity ComponentHandle::entity() { + assert(valid()); + return manager_->template get(id_); +} + } // namespace entityx -- cgit v1.2.3