|
@@ -192,9 +192,6 @@ class basic_view<Entity, get_t<Component...>, exclude_t<Exclude...>> {
|
|
|
template<typename, typename, typename, typename>
|
|
template<typename, typename, typename, typename>
|
|
|
friend class basic_view;
|
|
friend class basic_view;
|
|
|
|
|
|
|
|
- template<typename Comp>
|
|
|
|
|
- using storage_for = constness_as_t<storage_type_t<std::remove_const_t<Comp>, Entity>, Comp>;
|
|
|
|
|
-
|
|
|
|
|
[[nodiscard]] auto opaque_check() const noexcept {
|
|
[[nodiscard]] auto opaque_check() const noexcept {
|
|
|
std::array<const base_type *, sizeof...(Component) - 1u> other{};
|
|
std::array<const base_type *, sizeof...(Component) - 1u> other{};
|
|
|
std::apply([&other, pos = 0u, view = view](const auto *...curr) mutable { ((curr == view ? void() : void(other[pos++] = curr)), ...); }, pools);
|
|
std::apply([&other, pos = 0u, view = view](const auto *...curr) mutable { ((curr == view ? void() : void(other[pos++] = curr)), ...); }, pools);
|
|
@@ -242,11 +239,11 @@ public:
|
|
|
/*! @brief Unsigned integer type. */
|
|
/*! @brief Unsigned integer type. */
|
|
|
using size_type = std::size_t;
|
|
using size_type = std::size_t;
|
|
|
/*! @brief Common type among all storage types. */
|
|
/*! @brief Common type among all storage types. */
|
|
|
- using base_type = std::common_type_t<typename storage_for<Component>::base_type...>;
|
|
|
|
|
|
|
+ using base_type = std::common_type_t<typename storage_for_t<Component, entity_type>::base_type...>;
|
|
|
/*! @brief Bidirectional iterator type. */
|
|
/*! @brief Bidirectional iterator type. */
|
|
|
using iterator = internal::view_iterator<base_type, sizeof...(Component) - 1u, sizeof...(Exclude)>;
|
|
using iterator = internal::view_iterator<base_type, sizeof...(Component) - 1u, sizeof...(Exclude)>;
|
|
|
/*! @brief Iterable view type. */
|
|
/*! @brief Iterable view type. */
|
|
|
- using iterable = iterable_adaptor<internal::extended_view_iterator<iterator, storage_for<Component>...>>;
|
|
|
|
|
|
|
+ using iterable = iterable_adaptor<internal::extended_view_iterator<iterator, storage_for_t<Component, entity_type>...>>;
|
|
|
|
|
|
|
|
/*! @brief Default constructor to use to create empty, invalid views. */
|
|
/*! @brief Default constructor to use to create empty, invalid views. */
|
|
|
basic_view() noexcept
|
|
basic_view() noexcept
|
|
@@ -259,7 +256,7 @@ public:
|
|
|
* @param component The storage for the types to iterate.
|
|
* @param component The storage for the types to iterate.
|
|
|
* @param epool The storage for the types used to filter the view.
|
|
* @param epool The storage for the types used to filter the view.
|
|
|
*/
|
|
*/
|
|
|
- basic_view(storage_for<Component> &...component, storage_for<Exclude> &...epool) noexcept
|
|
|
|
|
|
|
+ basic_view(storage_for_t<Component, entity_type> &...component, storage_for_t<Exclude, entity_type> &...epool) noexcept
|
|
|
: basic_view{std::forward_as_tuple(component...), std::forward_as_tuple(epool...)} {}
|
|
: basic_view{std::forward_as_tuple(component...), std::forward_as_tuple(epool...)} {}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -267,7 +264,7 @@ public:
|
|
|
* @param component The storage for the types to iterate.
|
|
* @param component The storage for the types to iterate.
|
|
|
* @param epool The storage for the types used to filter the view.
|
|
* @param epool The storage for the types used to filter the view.
|
|
|
*/
|
|
*/
|
|
|
- basic_view(std::tuple<storage_for<Component> &...> component, std::tuple<storage_for<Exclude> &...> epool = {}) noexcept
|
|
|
|
|
|
|
+ basic_view(std::tuple<storage_for_t<Component, entity_type> &...> component, std::tuple<storage_for_t<Exclude, entity_type> &...> epool = {}) noexcept
|
|
|
: pools{std::apply([](auto &...curr) { return std::make_tuple(&curr...); }, component)},
|
|
: pools{std::apply([](auto &...curr) { return std::make_tuple(&curr...); }, component)},
|
|
|
filter{std::apply([](auto &...curr) { return std::make_tuple(&curr...); }, epool)},
|
|
filter{std::apply([](auto &...curr) { return std::make_tuple(&curr...); }, epool)},
|
|
|
view{std::apply([](const auto &...curr) { return (std::min)({&static_cast<const base_type &>(curr)...}, [](auto *lhs, auto *rhs) { return lhs->size() < rhs->size(); }); }, component)} {}
|
|
view{std::apply([](const auto &...curr) { return (std::min)({&static_cast<const base_type &>(curr)...}, [](auto *lhs, auto *rhs) { return lhs->size() < rhs->size(); }); }, component)} {}
|
|
@@ -280,7 +277,7 @@ public:
|
|
|
template<typename Comp>
|
|
template<typename Comp>
|
|
|
[[nodiscard]] basic_view use() const noexcept {
|
|
[[nodiscard]] basic_view use() const noexcept {
|
|
|
basic_view other{*this};
|
|
basic_view other{*this};
|
|
|
- other.view = std::get<storage_for<Comp> *>(pools);
|
|
|
|
|
|
|
+ other.view = std::get<storage_for_t<Comp, entity_type> *>(pools);
|
|
|
return other;
|
|
return other;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -311,7 +308,7 @@ public:
|
|
|
*/
|
|
*/
|
|
|
template<typename Comp>
|
|
template<typename Comp>
|
|
|
[[nodiscard]] decltype(auto) storage() const noexcept {
|
|
[[nodiscard]] decltype(auto) storage() const noexcept {
|
|
|
- return *std::get<storage_for<Comp> *>(pools);
|
|
|
|
|
|
|
+ return *std::get<storage_for_t<Comp, entity_type> *>(pools);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -433,9 +430,9 @@ public:
|
|
|
if constexpr(sizeof...(Comp) == 0) {
|
|
if constexpr(sizeof...(Comp) == 0) {
|
|
|
return std::apply([entt](auto *...curr) { return std::tuple_cat(curr->get_as_tuple(entt)...); }, pools);
|
|
return std::apply([entt](auto *...curr) { return std::tuple_cat(curr->get_as_tuple(entt)...); }, pools);
|
|
|
} else if constexpr(sizeof...(Comp) == 1) {
|
|
} else if constexpr(sizeof...(Comp) == 1) {
|
|
|
- return (std::get<storage_for<Comp> *>(pools)->get(entt), ...);
|
|
|
|
|
|
|
+ return (std::get<storage_for_t<Comp, entity_type> *>(pools)->get(entt), ...);
|
|
|
} else {
|
|
} else {
|
|
|
- return std::tuple_cat(std::get<storage_for<Comp> *>(pools)->get_as_tuple(entt)...);
|
|
|
|
|
|
|
+ return std::tuple_cat(std::get<storage_for_t<Comp, entity_type> *>(pools)->get_as_tuple(entt)...);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -512,8 +509,8 @@ public:
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
private:
|
|
|
- std::tuple<storage_for<Component> *...> pools;
|
|
|
|
|
- std::tuple<storage_for<Exclude> *...> filter;
|
|
|
|
|
|
|
+ std::tuple<storage_for_t<Component, entity_type> *...> pools;
|
|
|
|
|
+ std::tuple<storage_for_t<Exclude, entity_type> *...> filter;
|
|
|
const base_type *view;
|
|
const base_type *view;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
@@ -544,21 +541,19 @@ class basic_view<Entity, get_t<Component>, exclude_t<>, std::void_t<std::enable_
|
|
|
template<typename, typename, typename, typename>
|
|
template<typename, typename, typename, typename>
|
|
|
friend class basic_view;
|
|
friend class basic_view;
|
|
|
|
|
|
|
|
- using storage_for = constness_as_t<storage_type_t<std::remove_const_t<Component>, Entity>, Component>;
|
|
|
|
|
-
|
|
|
|
|
public:
|
|
public:
|
|
|
/*! @brief Underlying entity identifier. */
|
|
/*! @brief Underlying entity identifier. */
|
|
|
using entity_type = Entity;
|
|
using entity_type = Entity;
|
|
|
/*! @brief Unsigned integer type. */
|
|
/*! @brief Unsigned integer type. */
|
|
|
using size_type = std::size_t;
|
|
using size_type = std::size_t;
|
|
|
/*! @brief Common type among all storage types. */
|
|
/*! @brief Common type among all storage types. */
|
|
|
- using base_type = typename storage_for::base_type;
|
|
|
|
|
|
|
+ using base_type = typename storage_for_t<Component, entity_type>::base_type;
|
|
|
/*! @brief Random access iterator type. */
|
|
/*! @brief Random access iterator type. */
|
|
|
using iterator = typename base_type::iterator;
|
|
using iterator = typename base_type::iterator;
|
|
|
/*! @brief Reversed iterator type. */
|
|
/*! @brief Reversed iterator type. */
|
|
|
using reverse_iterator = typename base_type::reverse_iterator;
|
|
using reverse_iterator = typename base_type::reverse_iterator;
|
|
|
/*! @brief Iterable view type. */
|
|
/*! @brief Iterable view type. */
|
|
|
- using iterable = decltype(std::declval<storage_for>().each());
|
|
|
|
|
|
|
+ using iterable = decltype(std::declval<storage_for_t<Component, entity_type>>().each());
|
|
|
|
|
|
|
|
/*! @brief Default constructor to use to create empty, invalid views. */
|
|
/*! @brief Default constructor to use to create empty, invalid views. */
|
|
|
basic_view() noexcept
|
|
basic_view() noexcept
|
|
@@ -570,14 +565,14 @@ public:
|
|
|
* @brief Constructs a single-type view from a storage class.
|
|
* @brief Constructs a single-type view from a storage class.
|
|
|
* @param ref The storage for the type to iterate.
|
|
* @param ref The storage for the type to iterate.
|
|
|
*/
|
|
*/
|
|
|
- basic_view(storage_for &ref) noexcept
|
|
|
|
|
|
|
+ basic_view(storage_for_t<Component, entity_type> &ref) noexcept
|
|
|
: basic_view{std::forward_as_tuple(ref)} {}
|
|
: basic_view{std::forward_as_tuple(ref)} {}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @brief Constructs a single-type view from a storage class.
|
|
* @brief Constructs a single-type view from a storage class.
|
|
|
* @param ref The storage for the type to iterate.
|
|
* @param ref The storage for the type to iterate.
|
|
|
*/
|
|
*/
|
|
|
- basic_view(std::tuple<storage_for &> ref, std::tuple<> = {}) noexcept
|
|
|
|
|
|
|
+ basic_view(std::tuple<storage_for_t<Component, entity_type> &> ref, std::tuple<> = {}) noexcept
|
|
|
: pools{&std::get<0>(ref)},
|
|
: pools{&std::get<0>(ref)},
|
|
|
filter{},
|
|
filter{},
|
|
|
view{&std::get<0>(ref)} {}
|
|
view{&std::get<0>(ref)} {}
|
|
@@ -838,7 +833,7 @@ public:
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
private:
|
|
|
- std::tuple<storage_for *> pools;
|
|
|
|
|
|
|
+ std::tuple<storage_for_t<Component, entity_type> *> pools;
|
|
|
std::tuple<> filter;
|
|
std::tuple<> filter;
|
|
|
const base_type *view;
|
|
const base_type *view;
|
|
|
};
|
|
};
|