Selaa lähdekoodia

spawning registry::create is no longer available

Michele Caini 6 vuotta sitten
vanhempi
commit
cad8a90124
3 muutettua tiedostoa jossa 8 lisäystä ja 141 poistoa
  1. 8 11
      docs/md/entity.md
  2. 0 54
      src/entt/entity/registry.hpp
  3. 0 76
      test/entt/entity/registry.cpp

+ 8 - 11
docs/md/entity.md

@@ -20,7 +20,7 @@
   * [Sorting: is it possible?](#sorting-is-it-possible)
   * [Helpers](#helpers)
     * [Null entity](#null-entity)
-    * [Stomp and spawn](#stomp-and-spawn)
+    * [Stomp](#stomp)
     * [Dependencies](#dependencies)
     * [Tags](#tags)
     * [Actor](#actor)
@@ -677,29 +677,26 @@ const auto entity = registry.create();
 const bool null = (entity == entt::null);
 ```
 
-### Stomp and spawn
+### Stomp
 
-The use of multiple registries is quite common. Examples of use are the
+Using multiple registries at the same time is quite common. Examples are the
 separation of the UI from the simulation or the loading of different scenes in
 the background, possibly on a separate thread, without having to keep track of
 which entity belongs to which scene.<br/>
 In fact, with `EnTT` this is even a recommended practice, as the registry is
-nothing more than a container and different optimizations and strategies can be
-applied to different containers.
+nothing more than an opaque container you can swap at any time.
 
 Once there are multiple registries available, however, one or more methods are
 needed to transfer information from one container to another. This results in
-the `stomp` member functions and a couple of overloads of the `create` member
-function for the `registry` class .<br/>
+the `stomp` member functions of the `registry` class .<br/>
 These functions allow to take one entity from a registry and use it to _stomp_
 one or more entities in another registry (or even the same, actually making
-local copies). On the other hand, the overloads of the `create` member function
-can be used to spawn new entities from a prototype.
+local copies).
 
 These features open definitely the doors to a lot of interesting features like
 migrating entities between registries, prototypes, shadow registry, prefabs,
-shared components without an explicit owner and copy-on-write policies among the
-other things.
+shared components without explicit ownership and copy-on-write policies among
+the other things.
 
 ### Dependencies
 

+ 0 - 54
src/entt/entity/registry.hpp

@@ -576,60 +576,6 @@ public:
         }
     }
 
-    /**
-     * @brief Creates a new entity from a prototype entity.
-     *
-     * @sa create
-     *
-     * The components must be copyable for obvious reasons. The source entity
-     * must be a valid one.<br/>
-     * If no components are provided, the registry will try to copy all the
-     * existing types. The non-copyable ones will be ignored.
-     *
-     * @note
-     * Specifying the list of components is ways faster than an opaque copy.
-     *
-     * @tparam Component Types of components to copy.
-     * @tparam Exclude Types of components not to be copied.
-     * @param src A valid entity identifier to be copied.
-     * @param other The registry that owns the source entity.
-     * @return A valid entity identifier.
-     */
-    template<typename... Component, typename... Exclude>
-    entity_type create(entity_type src, const basic_registry &other, exclude_t<Exclude...> = {}) {
-        const auto entt = create();
-        stomp<Component...>(entt, src, other, exclude<Exclude...>);
-        return entt;
-    }
-
-    /**
-     * @brief Assigns each element in a range an entity from a prototype entity.
-     *
-     * @sa create
-     *
-     * The components must be copyable for obvious reasons. The entities must be
-     * all valid.<br/>
-     * If no components are provided, the registry will try to copy all the
-     * existing types. The non-copyable ones will be ignored.
-     *
-     * @note
-     * Specifying the list of components is faster than an opaque copy and uses
-     * the batch creation under the hood.
-     *
-     * @tparam Component Types of components to copy.
-     * @tparam It Type of input iterator.
-     * @tparam Exclude Types of components not to be copied.
-     * @param first An iterator to the first element of the range to generate.
-     * @param last An iterator past the last element of the range to generate.
-     * @param src A valid entity identifier to be copied.
-     * @param other The registry that owns the source entity.
-     */
-    template<typename... Component, typename It, typename... Exclude>
-    void create(It first, It last, entity_type src, const basic_registry &other, exclude_t<Exclude...> = {}) {
-        create(first, last);
-        stomp<Component...>(first, last, src, other, exclude<Exclude...>);
-    }
-
     /**
      * @brief Destroys an entity and lets the registry recycle the identifier.
      *

+ 0 - 76
test/entt/entity/registry.cpp

@@ -1210,82 +1210,6 @@ TEST(Registry, CreateManyEntitiesWithComponentsAtOnceWithListener) {
     ASSERT_EQ(listener.counter, 6);
 }
 
-TEST(Registry, CreateFromPrototype) {
-    entt::registry registry;
-
-    const auto prototype = registry.create();
-    registry.assign<int>(prototype, 3);
-    registry.assign<char>(prototype, 'c');
-
-    const auto full = registry.create(prototype, registry);
-
-    ASSERT_TRUE((registry.has<int, char>(full)));
-    ASSERT_EQ(registry.get<int>(full), 3);
-    ASSERT_EQ(registry.get<char>(full), 'c');
-
-    const auto partial = registry.create<int>(prototype, registry);
-
-    ASSERT_TRUE(registry.has<int>(partial));
-    ASSERT_FALSE(registry.has<char>(partial));
-    ASSERT_EQ(registry.get<int>(partial), 3);
-
-    const auto exclude = registry.create(prototype, registry, entt::exclude<int>);
-
-    ASSERT_FALSE(registry.has<int>(exclude));
-    ASSERT_TRUE(registry.has<char>(exclude));
-    ASSERT_EQ(registry.get<char>(exclude), 'c');
-}
-
-TEST(Registry, CreateManyFromPrototype) {
-    entt::registry registry;
-    entt::entity entities[2];
-
-    const auto prototype = registry.create();
-    registry.assign<int>(prototype, 3);
-    registry.assign<char>(prototype, 'c');
-
-    registry.create(std::begin(entities), std::end(entities), prototype, registry);
-
-    ASSERT_TRUE((registry.has<int, char>(entities[0])));
-    ASSERT_TRUE((registry.has<int, char>(entities[1])));
-    ASSERT_EQ(registry.get<int>(entities[0]), 3);
-    ASSERT_EQ(registry.get<char>(entities[1]), 'c');
-
-    registry.create<int>(std::begin(entities), std::end(entities), prototype, registry);
-
-    ASSERT_TRUE(registry.has<int>(entities[0]));
-    ASSERT_FALSE(registry.has<char>(entities[1]));
-    ASSERT_EQ(registry.get<int>(entities[0]), 3);
-
-    registry.create(std::begin(entities), std::end(entities), prototype, registry, entt::exclude<int>);
-
-    ASSERT_FALSE(registry.has<int>(entities[0]));
-    ASSERT_TRUE(registry.has<char>(entities[1]));
-    ASSERT_EQ(registry.get<char>(entities[0]), 'c');
-}
-
-TEST(Registry, CreateFromPrototypeWithListener) {
-    entt::registry registry;
-    entt::entity entities[3];
-    listener listener;
-
-    const auto prototype = registry.create();
-    registry.assign<int>(prototype, 3);
-    registry.assign<char>(prototype, 'c');
-    registry.assign<empty_type>(prototype);
-
-    registry.on_construct<int>().connect<&listener::incr<int>>(listener);
-    registry.create<int, char>(std::begin(entities), std::end(entities), prototype, registry);
-
-    ASSERT_EQ(listener.counter, 3);
-
-    registry.on_construct<int>().disconnect<&listener::incr<int>>(listener);
-    registry.on_construct<empty_type>().connect<&listener::incr<empty_type>>(listener);
-    registry.create<char, empty_type>(std::begin(entities), std::end(entities), prototype, registry);
-
-    ASSERT_EQ(listener.counter, 6);
-}
-
 TEST(Registry, NonOwningGroupInterleaved) {
     entt::registry registry;
     typename entt::entity entity = entt::null;