From: Daniel Guzman Date: Wed, 6 Apr 2016 16:10:54 +0000 (+0200) Subject: Added a function to retrieve the Entity associated with a component in ComponentHandle X-Git-Url: https://code.bitgloo.com/?a=commitdiff_plain;h=dd2e781d38d34a574bb173f70bb20f0aa3439246;p=clyne%2Fentityx.git Added a function to retrieve the Entity associated with a component in ComponentHandle --- 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