Represents a reference to an entity within a registry.
More...
#include <entity_ref.hpp>
|
| constexpr | const_entity_ref (const base_registry ®istry, entity entity) |
| | Constructs a const entity reference for a specific entity in the given registry.
|
| |
| constexpr auto | archetype () const noexcept -> const archetype & |
| | Retrieves a constant reference to the archetype of the entity.
|
| |
| constexpr auto | alive () const noexcept -> bool |
| | Checks if the entity is currently active in the registry.
|
| |
| template<component... C> |
| constexpr auto | has () const noexcept -> bool |
| | Determines if the entity has all specified components.
|
| |
| template<component C> |
| constexpr auto | get () const -> const C & |
| | Retrieves a const-qualified component of type C from the entity in a read-only manner.
|
| |
| template<component C, component O, component... Args> |
| constexpr auto | get () const -> decltype(auto) |
| | Retrieves multiple components from the underlying registry for the current entity (const version).
|
| |
| constexpr auto | visit (auto &&func) const |
| | Visit all components of an entity and apply a function to them (const version).
|
| |
| auto | copy (base_registry &destination) const -> entity_ref |
| | Copies the current entity to another registry.
|
| |
| auto | copy (base_registry &destination, placeholder_entity placeholder) const |
| | Copies the current entity to another registry into a placeholder entity.
|
| |
| constexpr | operator entity () const noexcept |
| | Converts this const_entity_ref to its underlying entity.
|
| |
| constexpr | operator bool () const noexcept |
| | Checks if the underlying entity is valid.
|
| |
Represents a reference to an entity within a registry.
This class provides read only access to entity.
◆ const_entity_ref()
| constexpr co_ecs::const_entity_ref::const_entity_ref |
( |
const base_registry & | registry, |
|
|
entity | entity ) |
|
inlineconstexpr |
Constructs a const entity reference for a specific entity in the given registry.
- Parameters
-
| registry | Reference to the base_registry that manages the entity. |
| entity | The entity that this reference will encapsulate. |
◆ alive()
| constexpr auto co_ecs::const_entity_ref::alive |
( |
| ) |
const -> bool |
|
inlineconstexprnoexcept |
Checks if the entity is currently active in the registry.
This method queries the registry to determine if the entity is still active and has not been destroyed. It is particularly useful for validity checks before performing operations on the entity.
- Returns
- bool Returns true if the entity is active; otherwise, false.
◆ archetype()
| constexpr auto co_ecs::const_entity_ref::archetype |
( |
| ) |
const -> const archetype& |
|
inlineconstexprnoexcept |
Retrieves a constant reference to the archetype of the entity.
This method returns a reference to the archetype associated with the encapsulated entity. An archetype defines the configuration of components that an entity possesses in the entity-component system. Accessing the archetype can be useful for inspecting the structure and component makeup of the entity.
- Returns
- const archetype& A reference to the archetype of the entity.
◆ copy() [1/2]
Copies the current entity to another registry.
This method copies the current entity to a specified destination registry, creating a new entity in the destination registry.
- Parameters
-
| destination | The destination registry where the entity will be copied. |
- Returns
- The copied entity reference in the destination registry.
◆ copy() [2/2]
Copies the current entity to another registry into a placeholder entity.
This method copies the current entity to a specified destination registry, creating a new entity in the destination registry and associating it with a placeholder entity.
- Parameters
-
| destination | The destination registry where the entity will be copied. |
| placeholder | The placeholder entity in the destination registry. |
- Returns
- The copied entity reference in the destination registry.
◆ get() [1/2]
template<component C>
| constexpr auto co_ecs::const_entity_ref::get |
( |
| ) |
const -> const C& |
|
inlineconstexpr |
Retrieves a const-qualified component of type C from the entity in a read-only manner.
This const method template is designed for read-only access to a specific component from the entity managed by the registry. It is used when the entity is expected to contain the component and modifications are not intended. If the requested component is not present, it throws a component_not_found exception.
- Template Parameters
-
| C | The type of the component to retrieve, specified as a const-qualified reference. |
- Returns
- C A const reference to the requested component of the entity.
- Exceptions
-
◆ get() [2/2]
template<component C, component O, component... Args>
| constexpr auto co_ecs::const_entity_ref::get |
( |
| ) |
const -> decltype(auto) |
|
inlineconstexpr |
Retrieves multiple components from the underlying registry for the current entity (const version).
This method allows accessing multiple components associated with the current entity from the underlying registry in a const context.
- Template Parameters
-
| C | The first component type to retrieve. |
| O | The second component type to retrieve. |
| Args | Additional component types to retrieve. |
- Returns
- A tuple containing the requested components.
◆ has()
template<component... C>
| constexpr auto co_ecs::const_entity_ref::has |
( |
| ) |
const -> bool |
|
inlineconstexprnoexcept |
Determines if the entity has all specified components.
This template method checks whether the entity has each of the components listed in the template arguments. This can be useful for conditional logic where actions depend on the presence of specific components in an entity. For example, an operation that should only be performed if an entity has both a position and velocity component.
- Template Parameters
-
| C | The component types to check for. |
- Returns
- bool Returns true if the entity has all specified components; otherwise, false.
◆ operator bool()
| constexpr co_ecs::const_entity_ref::operator bool |
( |
| ) |
const |
|
inlineconstexprnoexcept |
Checks if the underlying entity is valid.
This conversion operator allows the entity_ref to be used in boolean contexts to check if the underlying entity is valid (i.e., has valid (id, generation) but may not be alive).
- Returns
- bool True if the underlying entity is valid, false otherwise.
◆ operator entity()
| constexpr co_ecs::const_entity_ref::operator entity |
( |
| ) |
const |
|
inlineconstexprnoexcept |
Converts this const_entity_ref to its underlying entity.
This conversion operator allows const_entity_ref to be treated as its underlying entity type directly. Useful in contexts where the entity's identifier is needed without explicit method calls.
- Returns
- entity The underlying entity associated with this
const_entity_ref.
◆ visit()
| constexpr auto co_ecs::const_entity_ref::visit |
( |
auto && | func | ) |
const |
|
inlineconstexpr |
Visit all components of an entity and apply a function to them (const version).
This function visits all components associated with an entity in the registry and applies the provided function to each component. This version is const and can be used in const contexts.
- Parameters
-
| func | A callable object (function, lambda, etc.) that will be applied to each component. |
Example
detail::handle< struct entity_tag_t > entity
Represents an entity, consisting of an ID and generation.
Definition entity.hpp:13
The documentation for this class was generated from the following file: