Archetype groups entities that share the same types of components. Archetype has a list of fixed size chunks where entities and their components are stored in a packed arrays, in a so called SoA fashion.
More...
#include <archetype.hpp>
|
| | archetype ()=default |
| | Construct a new archetype object without components.
|
| |
| | archetype (component_meta_set components) |
| | Construct a new archetype object.
|
| |
| auto | components () const noexcept -> const component_meta_set & |
| | Return components set.
|
| |
| auto | chunks () noexcept -> chunks_storage_t & |
| | Return reference to chunks vector.
|
| |
| auto | chunks () const noexcept -> const chunks_storage_t & |
| | Return const reference to chunks vector.
|
| |
| template<component... Components> |
| auto | emplace (entity ent, Components &&... components) -> entity_location |
| | Emplace new entity and assign given components to it, return entities location.
|
| |
| auto | swap_erase (const entity_location &location) noexcept -> std::optional< entity > |
| | Swap erase an entity at given location, returns an entity that has been moved as a result of this operation or std::nullopt if no entities were moved.
|
| |
| auto | move (const entity_location &location, archetype &other) -> std::pair< entity_location, std::optional< entity > > |
| | Move entity and its components to a different archetype and returns a pair where the first element is moved entity location in a new archetype and the second is the entity that has been moved in this archetype or std::nullopt if no entities were moved.
|
| |
| auto | copy (const entity_location &location, archetype &other) -> entity_location |
| | Copy entity and its components to a different archetype.
|
| |
| void | visit (const entity_location &location, auto &&func) |
| | Visit all components of an entity.
|
| |
| void | visit (const entity_location &location, auto &&func) const |
| | Visit all components of an entity (const variant).
|
| |
| template<component C> |
| auto | get (entity_location location) -> C & |
| | Get component data.
|
| |
| template<component C> |
| auto | get (entity_location location) const -> const C & |
| | Get component data, const variant.
|
| |
| template<component C> |
| auto | contains () const noexcept -> bool |
| | Check if archetype has component C.
|
| |
Archetype groups entities that share the same types of components. Archetype has a list of fixed size chunks where entities and their components are stored in a packed arrays, in a so called SoA fashion.
◆ chunks_storage_t
◆ archetype() [1/2]
| co_ecs::archetype::archetype |
( |
| ) |
|
|
default |
Construct a new archetype object without components.
◆ archetype() [2/2]
Construct a new archetype object.
- Parameters
-
◆ chunks() [1/2]
Return const reference to chunks vector.
- Returns
- const chunks_storage_t&
◆ chunks() [2/2]
Return reference to chunks vector.
- Returns
- chunks_storage_t&
◆ components()
◆ contains()
template<component C>
| auto co_ecs::archetype::contains |
( |
| ) |
const -> bool |
|
inlinenoexcept |
Check if archetype has component C.
- Template Parameters
-
- Returns
- true If this archetype has component C
-
false If this archetype does not have component C
◆ copy()
Copy entity and its components to a different archetype.
- Parameters
-
| location | Entity location |
| other | Archetype to copy entity and its components to |
- Returns
- entity_location
◆ emplace()
template<component... Components>
Emplace new entity and assign given components to it, return entities location.
- Template Parameters
-
| Components | Components types |
- Parameters
-
| ent | Entity |
| components | Components parameter pack |
- Returns
- entity_location
◆ get() [1/2]
Get component data.
- Template Parameters
-
- Parameters
-
- Returns
- C& Component reference
◆ get() [2/2]
Get component data, const variant.
- Template Parameters
-
- Parameters
-
- Returns
- const C& Component reference
◆ move()
Move entity and its components to a different archetype and returns a pair where the first element is moved entity location in a new archetype and the second is the entity that has been moved in this archetype or std::nullopt if no entities were moved.
- Parameters
-
| location | Entity location |
| other | Archetype to move entity and its components to |
- Returns
- std::pair<entity_location, std::optional<entity>>
◆ swap_erase()
Swap erase an entity at given location, returns an entity that has been moved as a result of this operation or std::nullopt if no entities were moved.
- Parameters
-
- Returns
- std::optional<entity>
◆ visit() [1/2]
| void co_ecs::archetype::visit |
( |
const entity_location & | location, |
|
|
auto && | func ) |
|
inline |
Visit all components of an entity.
- Parameters
-
| location | Entity location |
| func | Function, a visitor, to apply components to. |
◆ visit() [2/2]
| void co_ecs::archetype::visit |
( |
const entity_location & | location, |
|
|
auto && | func ) const |
|
inline |
Visit all components of an entity (const variant).
- Parameters
-
| location | Entity location |
| func | Function, a visitor, to apply components to. |
The documentation for this class was generated from the following file: