cubos::core::ecs::EntityPool class final

Manages the creation and destruction of entity identifiers, as well as storing their archetype identifiers.

Public functions

void reset()
Resets the pool to its initial state.
auto create(ArchetypeId archetype) -> Entity
Creates a new entity on the given archetype.
void destroy(uint32_t index)
Removes an entity from the world.
void archetype(uint32_t index, ArchetypeId archetype)
Changes the archetype identifier of an entity.
auto archetype(uint32_t index) const -> ArchetypeId
Gets the archetype identifier of an entity.
auto generation(uint32_t index) const -> uint32_t
Gets the generation of an entity index.
auto contains(Entity entity) const -> bool
Checks if a given entity exists.
auto size() const -> size_t
Gets the number of alive entities in the pool.

Function documentation

void cubos::core::ecs::EntityPool::reset()

Resets the pool to its initial state.

Previously returned entity identifiers become invalid, as they might be reused.

Entity cubos::core::ecs::EntityPool::create(ArchetypeId archetype)

Creates a new entity on the given archetype.

Parameters
archetype Archetype identifier.
Returns Entity.

void cubos::core::ecs::EntityPool::destroy(uint32_t index)

Removes an entity from the world.

Parameters
index Entity index to remove.

void cubos::core::ecs::EntityPool::archetype(uint32_t index, ArchetypeId archetype)

Changes the archetype identifier of an entity.

Parameters
index Entity index.
archetype New archetype identifier.

ArchetypeId cubos::core::ecs::EntityPool::archetype(uint32_t index) const

Gets the archetype identifier of an entity.

Parameters
index Entity index.
Returns Archetype identifier.

uint32_t cubos::core::ecs::EntityPool::generation(uint32_t index) const

Gets the generation of an entity index.

Parameters
index Entity index.
Returns Generation.

bool cubos::core::ecs::EntityPool::contains(Entity entity) const

Checks if a given entity exists.

Parameters
entity Entity to check.
Returns Whether the entity exists.

size_t cubos::core::ecs::EntityPool::size() const

Gets the number of alive entities in the pool.

Returns Number of entities.