Registry is a container for all our entities and components. Components are stored in continuously in memory allowing for very fast iterations, a so called SoA approach. A set of unique components form an archetype, where every entity is mapped to an archetype.
More...
|
| template<component... Components> |
| constexpr auto | create (Components &&... args) -> entity_ref |
| | Creates a new entity and attaches the specified components to it.
|
| |
| constexpr auto | get_entity (entity ent) noexcept -> entity_ref |
| | Retrieves a mutable reference to an entity.
|
| |
| constexpr auto | get_entity (entity ent) const noexcept -> const_entity_ref |
| | Retrieves a constant reference to an entity.
|
| |
| constexpr auto | get_entity_const (entity ent) const noexcept -> const_entity_ref |
| | Retrieves a constant reference to an entity (alias).
|
| |
| template<component_reference... Args> |
| constexpr auto | view () -> co_ecs::view< Args... > requires(!const_component_references_v< Args... >) |
| | Create a non-const view based on component query in parameter pack.
|
| |
template<component_reference... Args>
requires const_component_references_v<Args...> |
| constexpr auto | view () const -> co_ecs::view< Args... > |
| | Create a const view based on component query in parameter pack.
|
| |
| template<component_reference... Args> |
| constexpr auto | single () -> std::optional< std::tuple< Args... > > requires(!const_component_references_v< Args... >) |
| | Returns a single tuple of components matching Args, if available in the view.
|
| |
template<component_reference... Args>
requires const_component_references_v<Args...> |
| constexpr auto | single () const -> std::optional< std::tuple< Args... > > |
| | Returns a single tuple of components matching Args, if available in the view.
|
| |
template<typename F >
requires (!detail::func_decomposer<F>::is_const) |
| constexpr void | each (F &&func) |
| | Executes a given function on each entity that matches the specified component requirements.
|
| |
template<typename F >
requires (detail::func_decomposer<F>::is_const) |
| constexpr void | each (F &&func) const |
| | Executes a given function on each entity that matches the specified component requirements, without modifying the entities.
|
| |
| constexpr std::size_t | size () const noexcept |
| | Returns the number of enitites in the registry.
|
| |
| constexpr bool | empty () const noexcept |
| | Checks if the registry currently manages any entities.
|
| |
| constexpr auto | alive (entity ent) const noexcept -> bool |
| | Checks if the specified entity is currently active within the registry.
|
| |
| void | destroy (entity ent) |
| | Destroys the given entity.
|
| |
| constexpr auto | archetypes () noexcept -> class archetypes & |
| | Provides access to the modifiable list of archetypes in the registry.
|
| |
| constexpr auto | archetypes () const noexcept -> const class archetypes & |
| | Provides access to the immutable list of archetypes in the registry.
|
| |
| constexpr auto | reserve () -> placeholder_entity |
| | Reserves an entity in a thread-safe manner.
|
| |
| constexpr void | sync () |
| | Synchronizes concurently reserved entities.
|
| |
| template<component... C> |
| constexpr auto | has (entity ent) const -> bool |
| | Checks if the specified entity has all the given components.
|
| |
| constexpr void | visit (entity ent, auto &&func) |
| | Visit all components of an entity.
|
| |
| constexpr void | visit (entity ent, auto &&func) const |
| | Visit all components of an entity (const variant).
|
| |
|
| template<component... Components> |
| constexpr auto | create_impl (Components &&... args) -> entity |
| |
| template<component C> |
| constexpr auto | set_impl (entity ent) -> std::pair< bool, C * > |
| |
| template<component C> |
| constexpr void | remove (entity ent) |
| |
| constexpr auto | allocate () -> entity |
| |
| entity | move (entity ent, base_registry &dest) |
| |
| entity | copy (entity ent, base_registry &dest) const |
| |
| entity | move (entity ent, base_registry &dest, placeholder_entity placeholder) |
| |
| entity | copy (entity ent, base_registry &dest, placeholder_entity placeholder) const |
| |
| entity | clone (entity ent) |
| |
| entity | clone (entity ent, placeholder_entity placeholder) |
| |
| template<component... Args> |
| static constexpr auto | get_impl (auto &&self, entity ent) -> decltype(auto) |
| |
| entity_pool | _entity_pool |
| |
| class archetypes | _archetypes |
| |
| detail::sparse_map< typename entity::id_t, entity_location > | _entity_archetype_map |
| |
Registry is a container for all our entities and components. Components are stored in continuously in memory allowing for very fast iterations, a so called SoA approach. A set of unique components form an archetype, where every entity is mapped to an archetype.
template<typename F >
requires (detail::func_decomposer<F>::is_const)
| constexpr void co_ecs::registry::each |
( |
F && | func | ) |
const |
|
inlineconstexpr |
Executes a given function on each entity that matches the specified component requirements, without modifying the entities.
This constant version of each allows for iteration over entities in a read-only fashion. It is suitable for operations that only need to read component data without modifying it, ensuring that the entity data remains unchanged. This method shares the same optimization benefits as its non-constant counterpart.
- Template Parameters
-
| F | The type of the callable function to run on the entity components. |
- Parameters
-
| func | A callable to run on entity components, must not modify the entities. |