]> code.bitgloo.com Git - clyne/entityx.git/commitdiff
Added a function to retrieve the Entity associated with a component in ComponentHandle
authorDaniel Guzman <daniel.guzman85@gmail.com>
Wed, 6 Apr 2016 16:10:54 +0000 (18:10 +0200)
committerDaniel Guzman <daniel.guzman85@gmail.com>
Wed, 6 Apr 2016 16:21:05 +0000 (18:21 +0200)
entityx/Entity.h

index b55a45f5b4aa410dba0c488c685bad1750f8475f..2382c1195a80c874661348a0032150b83463c019 100644 (file)
@@ -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