|
|
@@ -41,6 +41,9 @@ template<typename Entity>
|
|
|
class basic_registry {
|
|
|
using traits_type = entt_traits<Entity>;
|
|
|
|
|
|
+ template<typename Component>
|
|
|
+ using storage_type = typename storage_traits<Entity, Component>::storage_type;
|
|
|
+
|
|
|
struct pool_data {
|
|
|
type_info info{};
|
|
|
std::unique_ptr<basic_sparse_set<Entity>> pool{};
|
|
|
@@ -59,7 +62,7 @@ class basic_registry {
|
|
|
void maybe_valid_if(basic_registry &owner, const Entity entt) {
|
|
|
[[maybe_unused]] const auto cpools = std::forward_as_tuple(owner.assure<Owned>()...);
|
|
|
|
|
|
- const auto is_valid = ((std::is_same_v<Component, Owned> || std::get<storage_t<Entity, Owned> &>(cpools).contains(entt)) && ...)
|
|
|
+ const auto is_valid = ((std::is_same_v<Component, Owned> || std::get<storage_type<Owned> &>(cpools).contains(entt)) && ...)
|
|
|
&& ((std::is_same_v<Component, Get> || owner.assure<Get>().contains(entt)) && ...)
|
|
|
&& ((std::is_same_v<Component, Exclude> || !owner.assure<Exclude>().contains(entt)) && ...);
|
|
|
|
|
|
@@ -70,7 +73,7 @@ class basic_registry {
|
|
|
} else {
|
|
|
if(is_valid && !(std::get<0>(cpools).index(entt) < current)) {
|
|
|
const auto pos = current++;
|
|
|
- (std::get<storage_t<Entity, Owned> &>(cpools).swap(std::get<storage_t<Entity, Owned> &>(cpools).data()[pos], entt), ...);
|
|
|
+ (std::get<storage_type<Owned> &>(cpools).swap(std::get<storage_type<Owned> &>(cpools).data()[pos], entt), ...);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -83,7 +86,7 @@ class basic_registry {
|
|
|
} else {
|
|
|
if(const auto cpools = std::forward_as_tuple(owner.assure<Owned>()...); std::get<0>(cpools).contains(entt) && (std::get<0>(cpools).index(entt) < current)) {
|
|
|
const auto pos = --current;
|
|
|
- (std::get<storage_t<Entity, Owned> &>(cpools).swap(std::get<storage_t<Entity, Owned> &>(cpools).data()[pos], entt), ...);
|
|
|
+ (std::get<storage_type<Owned> &>(cpools).swap(std::get<storage_type<Owned> &>(cpools).data()[pos], entt), ...);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -103,7 +106,7 @@ class basic_registry {
|
|
|
};
|
|
|
|
|
|
template<typename Component>
|
|
|
- [[nodiscard]] const storage_t<Entity, Component> & assure() const {
|
|
|
+ [[nodiscard]] const storage_type<Component> & assure() const {
|
|
|
const auto index = type_seq<Component>::value();
|
|
|
|
|
|
if(!(index < pools.size())) {
|
|
|
@@ -112,18 +115,18 @@ class basic_registry {
|
|
|
|
|
|
if(auto &&pdata = pools[index]; !pdata.pool) {
|
|
|
pdata.info = type_id<Component>();
|
|
|
- pdata.pool.reset(new storage_t<Entity, Component>());
|
|
|
+ pdata.pool.reset(new storage_type<Component>());
|
|
|
pdata.remove = +[](basic_sparse_set<Entity> &cpool, basic_registry &owner, const Entity *first, const Entity *last) {
|
|
|
- static_cast<storage_t<Entity, Component> &>(cpool).remove(owner, first, last);
|
|
|
+ static_cast<storage_type<Component> &>(cpool).remove(owner, first, last);
|
|
|
};
|
|
|
}
|
|
|
|
|
|
- return static_cast<const storage_t<Entity, Component> &>(*pools[index].pool);
|
|
|
+ return static_cast<const storage_type<Component> &>(*pools[index].pool);
|
|
|
}
|
|
|
|
|
|
template<typename Component>
|
|
|
- [[nodiscard]] storage_t<Entity, Component> & assure() {
|
|
|
- return const_cast<storage_t<Entity, Component> &>(std::as_const(*this).template assure<Component>());
|
|
|
+ [[nodiscard]] storage_type<Component> & assure() {
|
|
|
+ return const_cast<storage_type<Component> &>(std::as_const(*this).template assure<Component>());
|
|
|
}
|
|
|
|
|
|
Entity generate_identifier() {
|
|
|
@@ -1256,9 +1259,9 @@ public:
|
|
|
}
|
|
|
|
|
|
if constexpr(sizeof...(Owned) == 0) {
|
|
|
- return { handler->current, std::get<storage_t<Entity, std::decay_t<Get>> &>(cpools)... };
|
|
|
+ return { handler->current, std::get<storage_type<std::decay_t<Get>> &>(cpools)... };
|
|
|
} else {
|
|
|
- return { handler->current, std::get<storage_t<Entity, std::decay_t<Owned>> &>(cpools)... , std::get<storage_t<Entity, std::decay_t<Get>> &>(cpools)... };
|
|
|
+ return { handler->current, std::get<storage_type<std::decay_t<Owned>> &>(cpools)... , std::get<storage_type<std::decay_t<Get>> &>(cpools)... };
|
|
|
}
|
|
|
}
|
|
|
|