Jelajahi Sumber

minor changes

Michele Caini 6 tahun lalu
induk
melakukan
f7c285af20
2 mengubah file dengan 3 tambahan dan 21 penghapusan
  1. 2 2
      src/entt/entity/registry.hpp
  2. 1 19
      src/entt/entity/snapshot.hpp

+ 2 - 2
src/entt/entity/registry.hpp

@@ -72,8 +72,8 @@ class basic_registry {
         decltype(auto) assign(basic_registry &registry, const Entity entt, Args &&... args) {
             if constexpr(std::is_empty_v<Component>) {
                 storage<Entity, Component>::construct(entt);
-                construction.publish(entt, registry, Component{std::forward<Args>(args)...});
-                return Component{};
+                construction.publish(entt, registry, Component{});
+                return Component{std::forward<Args>(args)...};
             } else {
                 auto &component = storage<Entity, Component>::construct(entt, std::forward<Args>(args)...);
                 construction.publish(entt, registry, component);

+ 1 - 19
src/entt/entity/snapshot.hpp

@@ -135,25 +135,7 @@ public:
      */
     template<typename... Component, typename Archive>
     const basic_snapshot & component(Archive &archive) const {
-        if constexpr(sizeof...(Component) == 1) {
-            const auto sz = reg->template size<Component...>();
-            const auto *entities = reg->template data<Component...>();
-
-            archive(typename traits_type::entity_type(sz));
-
-            for(std::remove_const_t<decltype(sz)> pos{}; pos < sz; ++pos) {
-                const auto entt = entities[pos];
-
-                if constexpr(std::is_empty_v<Component...>) {
-                    archive(entt);
-                } else {
-                    archive(entt, reg->template get<Component...>(entt));
-                }
-            };
-        } else {
-            (component<Component>(archive), ...);
-        }
-
+        (component<Component>(archive, reg->template data<Component>(), reg->template data<Component>() + reg->template size<Component>()), ...);
         return *this;
     }