32 return *_registry.get().get_location(_entity).archetype;
41 [[nodiscard]]
constexpr auto alive() const noexcept ->
bool {
42 return _registry.get().alive(_entity);
55 [[nodiscard]]
constexpr auto has() const noexcept ->
bool {
56 return _registry.get().template
has<C...>(_entity);
77 [[nodiscard]]
constexpr auto get() -> C& {
78 return std::get<0>(base_registry::template get_impl<C>(_registry.get(), _entity));
99 [[nodiscard]]
constexpr auto get() const -> const C& {
100 return std::get<0>(base_registry::template get_impl<C>(_registry.get(), _entity));
119 [[nodiscard]]
constexpr auto get() ->
decltype(
auto) {
120 return base_registry::template get_impl<C, O, Args...>(_registry.get(), _entity);
134 [[nodiscard]]
constexpr auto get() const -> decltype(auto) {
135 return base_registry::template get_impl<C, O, Args...>(_registry.get(), _entity);
149 template<component C>
151 auto [inserted, ptr] = _registry.get().set_impl<C>(_entity);
153 std::construct_at(ptr, std::forward<
decltype(args)>(args)...);
178 auto [inserted, ptr] = _registry.get().set_impl<C>(_entity);
180 std::construct_at(ptr, std::forward<Args>(args)...);
182 *ptr = C{ std::forward<Args>(args)... };
201 template<component C>
203 _registry.get().remove<C>(_entity);
216 _registry.get().destroy(_entity);
230 _registry.get().visit(_entity, std::forward<
decltype(func)>(func));
244 constexpr auto visit(
auto&& func)
const {
245 static_cast<const base_registry&
>(_registry.get()).
visit(_entity, std::forward<
decltype(func)>(func));
266 return entity_ref{ _registry, _registry.get().clone(_entity) };
276 return entity_ref{ _registry, _registry.get().clone(_entity, placeholder) };
287 return entity_ref{ destination, _registry.get().copy(_entity, destination) };
299 return entity_ref{ destination, _registry.get().copy(_entity, destination, placeholder) };
310 return entity_ref{ destination, _registry.get().move(_entity, destination) };
322 return entity_ref{ destination, _registry.get().move(_entity, destination, placeholder) };
331 [[nodiscard]]
constexpr operator entity() const noexcept {
341 [[nodiscard]]
constexpr operator bool() const noexcept {
342 return _entity.valid();
346 std::reference_wrapper<base_registry> _registry;
372 return *_registry.get().get_location(_entity).archetype;
381 [[nodiscard]]
constexpr auto alive() const noexcept ->
bool {
382 return _registry.get().alive(_entity);
395 [[nodiscard]]
constexpr auto has() const noexcept ->
bool {
396 return _registry.get().template
has<C...>(_entity);
408 template<component C>
409 [[nodiscard]]
constexpr auto get() const -> const C& {
410 return std::get<0>(base_registry::template get_impl<C>(_registry.get(), _entity));
424 [[nodiscard]]
constexpr auto get() const -> decltype(auto) {
425 return base_registry::template get_impl<C, O, Args...>(_registry.get(), _entity);
439 constexpr auto visit(
auto&& func)
const {
440 static_cast<const base_registry&
>(_registry.get()).
visit(_entity, std::forward<
decltype(func)>(func));
451 return entity_ref{ destination, _registry.get().copy(_entity, destination) };
463 return entity_ref{ destination, _registry.get().copy(_entity, destination, placeholder) };
472 [[nodiscard]]
constexpr operator entity() const noexcept {
482 [[nodiscard]]
constexpr operator bool() const noexcept {
483 return _entity.valid();
487 std::reference_wrapper<const base_registry> _registry;
Archetype groups entities that share the same types of components. Archetype has a list of fixed size...
Definition archetype.hpp:15
Definition base_registry.hpp:35
Represents a reference to an entity within a registry.
Definition entity_ref.hpp:355
auto copy(base_registry &destination, placeholder_entity placeholder) const
Copies the current entity to another registry into a placeholder entity.
Definition entity_ref.hpp:462
constexpr const_entity_ref(const base_registry ®istry, entity entity)
Constructs a const entity reference for a specific entity in the given registry.
Definition entity_ref.hpp:361
constexpr auto get() const -> const C &
Retrieves a const-qualified component of type C from the entity in a read-only manner.
Definition entity_ref.hpp:409
constexpr auto has() const noexcept -> bool
Determines if the entity has all specified components.
Definition entity_ref.hpp:395
auto copy(base_registry &destination) const -> entity_ref
Copies the current entity to another registry.
Definition entity_ref.hpp:450
constexpr auto alive() const noexcept -> bool
Checks if the entity is currently active in the registry.
Definition entity_ref.hpp:381
constexpr auto get() const -> decltype(auto)
Retrieves multiple components from the underlying registry for the current entity (const version).
Definition entity_ref.hpp:424
constexpr auto archetype() const noexcept -> const archetype &
Retrieves a constant reference to the archetype of the entity.
Definition entity_ref.hpp:371
constexpr auto visit(auto &&func) const
Visit all components of an entity and apply a function to them (const version).
Definition entity_ref.hpp:439
Represents a reference to an entity within a registry.
Definition entity_ref.hpp:13
auto clone() const -> entity_ref
Creates a duplicate of the current entity.
Definition entity_ref.hpp:265
constexpr auto archetype() const noexcept -> const archetype &
Retrieves a constant reference to the archetype of the entity.
Definition entity_ref.hpp:31
constexpr auto remove() -> entity_ref
Remove component C from an entity. In case entity does not have component attached nothing is done an...
Definition entity_ref.hpp:202
constexpr auto get() const -> const C &
Retrieves a const-qualified component of type C from the entity in a read-only manner.
Definition entity_ref.hpp:99
constexpr entity_ref(base_registry ®istry, entity entity) noexcept
Constructs an entity reference for a specific entity in the given registry.
Definition entity_ref.hpp:21
constexpr auto get() const -> decltype(auto)
Retrieves multiple components from the underlying registry for the current entity (const version).
Definition entity_ref.hpp:134
constexpr auto has() const noexcept -> bool
Determines if the entity has all specified components.
Definition entity_ref.hpp:55
auto move(base_registry &destination, placeholder_entity placeholder)
Moves the current entity to another registry into a placeholder entity.
Definition entity_ref.hpp:321
auto clone(placeholder_entity placeholder)
Clones the current entity to a placeholder entity.
Definition entity_ref.hpp:275
constexpr auto visit(auto &&func)
Visit all components of an entity and apply a function to them.
Definition entity_ref.hpp:229
auto copy(base_registry &destination, placeholder_entity placeholder) const
Copies the current entity to another registry into a placeholder entity.
Definition entity_ref.hpp:298
auto copy(base_registry &destination) const -> entity_ref
Copies the current entity to another registry.
Definition entity_ref.hpp:286
void destroy()
Destroys the current entity.
Definition entity_ref.hpp:215
constexpr auto alive() const noexcept -> bool
Checks if the entity is currently active in the registry.
Definition entity_ref.hpp:41
auto move(base_registry &destination) -> entity_ref
Moves the current entity to another registry.
Definition entity_ref.hpp:309
constexpr auto get_or_insert(auto &&... args) -> C &
Get reference to component C, or insert it with provided arguments if not present.
Definition entity_ref.hpp:150
constexpr auto get() -> decltype(auto)
Retrieves multiple components from the underlying registry for the current entity.
Definition entity_ref.hpp:119
constexpr auto get() -> C &
Retrieves a component of type C from the entity.
Definition entity_ref.hpp:77
constexpr auto set(Args &&... args) -> entity_ref
Set component to an entity. It can either override a component value that is already assigned to an e...
Definition entity_ref.hpp:177
constexpr auto visit(auto &&func) const
Visit all components of an entity and apply a function to them (const version).
Definition entity_ref.hpp:244
Placeholder (reserved) entity.
Definition base_registry.hpp:13
Registry is a container for all our entities and components. Components are stored in continuously in...
Definition registry.hpp:13
Component concept. The component must be a struct/class that can be move constructed and move assigna...
Definition component.hpp:86
Definition archetype.hpp:11
detail::handle< struct entity_tag_t > entity
Represents an entity, consisting of an ID and generation.
Definition entity.hpp:13