1#ifndef ENTT_ENTITY_HELPER_HPP
2#define ENTT_ENTITY_HELPER_HPP
7#include "../core/fwd.hpp"
8#include "../core/type_traits.hpp"
9#include "component.hpp"
21template<
typename Registry>
23 template<
typename... Get,
typename... Exclude>
47 template<
typename Get,
typename Exclude>
49 return dispatch(Get{}, Exclude{});
60template<
typename Registry>
62 template<
typename... Owned,
typename... Get,
typename... Exclude>
64 if constexpr(std::is_const_v<registry_type>) {
65 return reg->template group_if_exists<
typename Owned::element_type...>(
get_t<
typename Get::element_type...>{},
exclude_t<
typename Exclude::element_type...>{});
91 template<
typename Owned,
typename Get,
typename Exclude>
93 return dispatch(Owned{}, Get{}, Exclude{});
107template<auto Member,
typename Registry = std::decay_t<nth_argument_t<0u, decltype(Member)>>>
108void invoke(Registry ®,
const typename Registry::entity_type
entt) {
109 static_assert(std::is_member_function_pointer_v<
decltype(Member)>,
"Invalid pointer to non-static member function");
125template<
typename... Args>
128 static_assert(traits_type::page_size != 0u,
"Unexpected page size");
129 const auto *page =
storage.raw();
132 for(std::size_t pos{}, count =
storage.size(); pos < count; pos += traits_type::page_size, ++page) {
133 if(
const auto dist = (std::addressof(instance) - *page); dist >= 0 && dist < static_cast<decltype(dist)>(traits_type::page_size)) {
134 return *(
static_cast<const typename
basic_storage<Args...
>::base_type &>(
storage).
rbegin() +
static_cast<decltype(dist)
>(pos) + dist);
150template<
typename Registry>
168 template<
typename Type>
182 registry_type *bucket;
190template<
typename Registry,
typename Type>
211 template<
auto Candidate,
typename... Args>
224 template<
auto Candidate,
typename... Args>
237 template<
auto Candidate,
typename... Args>
251template<
typename Registry>
typename registry_type::entity_type entity_type
Underlying entity identifier.
Registry registry_type
Type of registry to convert.
as_group(registry_type &source) noexcept
Constructs a converter for a given registry.
as_view(registry_type &source) noexcept
Constructs a converter for a given registry.
typename registry_type::entity_type entity_type
Underlying entity identifier.
Registry registry_type
Type of registry to convert.
const_reverse_iterator rbegin() const noexcept
Returns a reverse iterator to the beginning.
element_type value_type
Type of the objects assigned to entities.
typename member_class< Member >::type member_class_t
Helper type.
basic_view(Type &...storage) -> basic_view< get_t< Type... >, exclude_t<> >
Deduction guide.
constexpr entt_traits< Entity >::entity_type to_entity(const Entity value) noexcept
Returns the entity part once converted to the underlying type.
constexpr null_t null
Compile-time constant for null entities.
basic_view< type_list_transform_t< Get, storage_for >, type_list_transform_t< Exclude, storage_for > > view
Alias declaration for the most common use case.
std::uint32_t id_type
Alias declaration for type identifiers.
basic_group< type_list_transform_t< Owned, storage_for >, type_list_transform_t< Get, storage_for >, type_list_transform_t< Exclude, storage_for > > group
Alias declaration for the most common use case.
constexpr get_t< Type... > get
Variable template for lists of observed elements.
basic_registry<> registry
Alias declaration for the most common use case.
void invoke(Registry ®, const typename Registry::entity_type entt)
Helper to create a listener that directly invokes a member function.
sigh_helper(Registry &) -> sigh_helper< Registry >
Deduction guide.
@ ref
Aliasing mode, the object points to a non-const element.
basic_storage< Type > storage
Alias declaration for the most common use case.
Common way to access various properties of components.
Alias for exclusion lists.
Alias for lists of observed elements.
Alias for lists of owned elements.
auto on_destroy(Args &&...args)
Forwards the call to on_destroy on the underlying storage.
auto on_construct(Args &&...args)
Forwards the call to on_construct on the underlying storage.
Registry registry_type
Registry type.
auto on_update(Args &&...args)
Forwards the call to on_update on the underlying storage.
sigh_helper(registry_type &ref, const id_type id=type_hash< Type >::value())
Constructs a helper for a given registry.
sigh_helper(registry_type &ref)
Constructs a helper for a given registry.
Registry registry_type
Registry type.
registry_type & registry() noexcept
Returns a reference to the underlying registry.
auto with(const id_type id=type_hash< Type >::value()) noexcept
Binds a properly initialized helper to a given signal type.
Primary template isn't defined on purpose.
static constexpr id_type value() noexcept
Returns the numeric representation of a given type.