minor changes

This commit is contained in:
Michele Caini
2019-10-16 09:00:21 +02:00
parent f6e3121c76
commit f7c285af20
2 changed files with 3 additions and 21 deletions

View File

@@ -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);

View File

@@ -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;
}