Browse Source

more on prototype

Michele Caini 7 years ago
parent
commit
d7394a8369
2 changed files with 8 additions and 14 deletions
  1. 6 12
      src/entt/entity/prototype.hpp
  2. 2 2
      test/entt/entity/prototype.cpp

+ 6 - 12
src/entt/entity/prototype.hpp

@@ -279,10 +279,8 @@ public:
      *
      *
      * @return A valid entity identifier.
      * @return A valid entity identifier.
      */
      */
-    entity_type create() const {
-        const auto entity = registry->create();
-        assign(*registry, entity);
-        return entity;
+    inline entity_type create() const {
+        return create(*registry);
     }
     }
 
 
     /**
     /**
@@ -332,10 +330,8 @@ public:
      *
      *
      * @param dst A valid entity identifier.
      * @param dst A valid entity identifier.
      */
      */
-    void assign(const entity_type dst) const {
-        for(auto &handler: handlers) {
-            handler.second.assign(*this, *registry, dst);
-        }
+    inline void assign(const entity_type dst) const {
+        assign(*registry, dst);
     }
     }
 
 
     /**
     /**
@@ -381,10 +377,8 @@ public:
      *
      *
      * @param dst A valid entity identifier.
      * @param dst A valid entity identifier.
      */
      */
-    void accommodate(const entity_type dst) const {
-        for(auto &handler: handlers) {
-            handler.second.accommodate(*this, *registry, dst);
-        }
+    inline void accommodate(const entity_type dst) const {
+        accommodate(*registry, dst);
     }
     }
 
 
     /**
     /**

+ 2 - 2
test/entt/entity/prototype.cpp

@@ -19,7 +19,7 @@ TEST(Prototype, SameRegistry) {
     ASSERT_EQ(std::get<0>(prototype.get<int, char>()), 3);
     ASSERT_EQ(std::get<0>(prototype.get<int, char>()), 3);
     ASSERT_EQ(std::get<1>(cprototype.get<int, char>()), 'c');
     ASSERT_EQ(std::get<1>(cprototype.get<int, char>()), 'c');
 
 
-    const auto e0 = prototype();
+    const auto e0 = prototype.create();
 
 
     ASSERT_TRUE((prototype.has<int, char>()));
     ASSERT_TRUE((prototype.has<int, char>()));
     ASSERT_FALSE(registry.orphan(e0));
     ASSERT_FALSE(registry.orphan(e0));
@@ -79,7 +79,7 @@ TEST(Prototype, OtherRegistry) {
     ASSERT_EQ(std::get<0>(prototype.get<int, char>()), 3);
     ASSERT_EQ(std::get<0>(prototype.get<int, char>()), 3);
     ASSERT_EQ(std::get<1>(cprototype.get<int, char>()), 'c');
     ASSERT_EQ(std::get<1>(cprototype.get<int, char>()), 'c');
 
 
-    const auto e0 = prototype(registry);
+    const auto e0 = prototype.create(registry);
 
 
     ASSERT_TRUE((prototype.has<int, char>()));
     ASSERT_TRUE((prototype.has<int, char>()));
     ASSERT_FALSE(registry.orphan(e0));
     ASSERT_FALSE(registry.orphan(e0));