瀏覽代碼

registry: internal changes

Michele Caini 6 年之前
父節點
當前提交
1fb0765443
共有 1 個文件被更改,包括 6 次插入4 次删除
  1. 6 4
      src/entt/entity/registry.hpp

+ 6 - 4
src/entt/entity/registry.hpp

@@ -64,8 +64,10 @@ class basic_registry {
 
 
     template<typename Component>
     template<typename Component>
     struct pool_handler: storage<Entity, Component> {
     struct pool_handler: storage<Entity, Component> {
-        sigh<void(basic_registry &, const Entity, std::conditional_t<std::is_empty_v<Component>, const Component &, Component &>)> on_construct;
-        sigh<void(basic_registry &, const Entity, std::conditional_t<std::is_empty_v<Component>, const Component &, Component &>)> on_replace;
+        using reference_type = std::conditional_t<std::is_empty_v<Component>, const Component &, Component &>;
+
+        sigh<void(basic_registry &, const Entity, reference_type)> on_construct;
+        sigh<void(basic_registry &, const Entity, reference_type)> on_replace;
         sigh<void(basic_registry &, const Entity)> on_destroy;
         sigh<void(basic_registry &, const Entity)> on_destroy;
         void *group{};
         void *group{};
 
 
@@ -96,8 +98,8 @@ class basic_registry {
                 storage<Entity, Component>::batch(first, last);
                 storage<Entity, Component>::batch(first, last);
 
 
                 if(!on_construct.empty()) {
                 if(!on_construct.empty()) {
-                    std::for_each(first, last, [&registry, component = Component{}, this](const auto entt) mutable {
-                        on_construct.publish(registry, entt, component);
+                    std::for_each(first, last, [&registry, this](const auto entt) {
+                        on_construct.publish(registry, entt, Component{});
                     });
                     });
                 }
                 }
             } else {
             } else {