engine::ecs::Registry class

Orchestrates the entities and components associated with those entities.

Public functions

auto CreateEntity() -> EntityID
Creates an entity in the registry.
auto DeleteEntity(EntityID entity) -> void
Deletes the entity and associated data.
auto IsAlive(EntityID entity) const -> bool
Indicates if an entity is alive.
template<typename T>
auto AddComponent(EntityID entity, T component) -> void
Adds a component to the given entity.
template<typename T>
auto RemoveComponent(EntityID entity) -> void
Removes a component from the given entity.
template<typename T>
auto GetComponent(EntityID entity) -> T&
Retrieves the component for the entity.
template<typename T>
auto HasComponent(EntityID entity) -> bool
Returns true if the component exists on the entity.

Function documentation

EntityID engine::ecs::Registry::CreateEntity()

Creates an entity in the registry.

Returns the ID of the entity created.

void engine::ecs::Registry::DeleteEntity(EntityID entity)

Deletes the entity and associated data.

Parameters
entity the ID of the entity to delete.

bool engine::ecs::Registry::IsAlive(EntityID entity) const

Indicates if an entity is alive.

Parameters
entity the ID of the entity to check
Returns true if the entity is alive.

template<typename T>
void engine::ecs::Registry::AddComponent(EntityID entity, T component)

Adds a component to the given entity.

Parameters
entity the ID of the entity to add to.
component the component to add to the entity.

template<typename T>
void engine::ecs::Registry::RemoveComponent(EntityID entity)

Removes a component from the given entity.

Parameters
entity the ID of the entity to remove.

template<typename T>
T& engine::ecs::Registry::GetComponent(EntityID entity)

Retrieves the component for the entity.

Parameters
entity the ID of the entity to fetch the component for.
Returns the component of the given type.

template<typename T>
bool engine::ecs::Registry::HasComponent(EntityID entity)

Returns true if the component exists on the entity.

Parameters
entity the ID of the entity to check.
Returns true if the component exists.