Registry class
#include <include/engine/ecs/registry.h>
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.
- auto AddComponent(EntityID entity, T component) -> void
- Adds a component to the given entity.
- auto RemoveComponent(EntityID entity) -> void
- Removes a component from the given entity.
- auto GetComponent(EntityID entity) -> T&
- Retrieves the component for the entity.
- auto HasComponent(EntityID entity) -> bool
- Returns
trueif 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. |
void engine:: ecs:: Registry:: RemoveComponent(EntityID entity)
Removes a component from the given entity.
| Parameters | |
|---|---|
| entity | the ID of the entity to remove. |
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. |
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. |