Przeglądaj źródła

prefer a clean api instead of cumbersome ones

Michele Caini 7 lat temu
rodzic
commit
700cf69f18
2 zmienionych plików z 4 dodań i 12 usunięć
  1. 0 2
      TODO
  2. 4 10
      src/entt/entity/prototype.hpp

+ 0 - 2
TODO

@@ -4,11 +4,9 @@
 * debugging tools (#60): the issue online already contains interesting tips on this, look at it
 * debugging tools (#60): the issue online already contains interesting tips on this, look at it
 * define basic reactive systems (track entities to which component is attached, track entities from which component is removed, and so on)
 * define basic reactive systems (track entities to which component is attached, track entities from which component is removed, and so on)
 * define systems as composable mixins (initializazion, reactive, update, whatever) with flexible auto-detected arguments (registry, views, etc)
 * define systems as composable mixins (initializazion, reactive, update, whatever) with flexible auto-detected arguments (registry, views, etc)
-* is it possible to allow multiple components for registry remove, reset, reserve, (maybe) managed, empty, get (tags), move and so on?
 * create dedicated flat map based on types implementation (sort of "type map") for types to use within the registry and so on...
 * create dedicated flat map based on types implementation (sort of "type map") for types to use within the registry and so on...
 * does it worth it to add an optional functor to the member functions of snapshot so as to filter out instances and entities?
 * does it worth it to add an optional functor to the member functions of snapshot so as to filter out instances and entities?
 * ease the assignment of tags as string (use a template class with a non-type template parameter behind the scene)
 * ease the assignment of tags as string (use a template class with a non-type template parameter behind the scene)
-* define a dedicated specialization for multi component view in case of two components
 * is it possible to reduce the storage used to manage empty components?
 * is it possible to reduce the storage used to manage empty components?
 * reintroduce meaningful copy/clone functionalities into the registry
 * reintroduce meaningful copy/clone functionalities into the registry
 * is registry/utility.hpp really required?
 * is registry/utility.hpp really required?

+ 4 - 10
src/entt/entity/prototype.hpp

@@ -102,17 +102,11 @@ public:
      * @brief Removes the given component from a prototype.
      * @brief Removes the given component from a prototype.
      * @tparam Component Type of component to remove.
      * @tparam Component Type of component to remove.
      */
      */
-    template<typename... Component>
+    template<typename Component>
     void unset() ENTT_NOEXCEPT {
     void unset() ENTT_NOEXCEPT {
-        auto erase = [this](const auto ctype) {
-            handlers.erase(std::remove_if(handlers.begin(), handlers.end(), [ctype](const auto &handler) {
-                return handler.type == ctype;
-            }), handlers.end());
-        };
-
-        using accumulator_type = int[];
-        accumulator_type accumulator = { (erase(registry_type::template type<Component>()), 0)... };
-        (void)accumulator;
+        handlers.erase(std::remove_if(handlers.begin(), handlers.end(), [](const auto &handler) {
+            return handler.type == registry_type::template type<Component>();
+        }), handlers.end());
     }
     }
 
 
     /**
     /**