class ecs::Registry

Stores all entities and components in their respective storages.

Allows creation

& destruction of entities, as well as a way to add or remove components to/from those entities. Allows creation of views or groups that allow iteration over entities containing a certain subset of components. Provides other helper functionality such as sorting.

Public

Methods

TryGetStorage

const SparseSet *TryGetStorage(TypeId typeId) const

Tries to retrieve the storage that contains a component identified with .

Returns null if the storage has not been created.

TryGetStorage

SparseSet *TryGetStorage(TypeId typeId)

Tries to retrieve the storage that contains a component identified with .

Returns null if the storage has not been created.

RemoveStorage

bool RemoveStorage(TypeId typeId)

Destroys storage and all associated components of type .

Clear

void Clear()

Clears all components and entities from the registry.

IsEntityValid

bool IsEntityValid(Entity entity) const

Returns true if the entity has been created and is still valid.

HasEntityAnyComponents

bool HasEntityAnyComponents(Entity entity) const

Returns true if entity has at least one associated component.

GetEntityVersion

Entity::VersionType GetEntityVersion(Entity entity) const

Returns the current version of the entity.

If an entity is destroyed and its identifier re-used, the version will be incremented.

CreateEntity

Entity CreateEntity()

Creates a brand new entity with a unique identifier.

CreateEntity

Entity CreateEntity(Entity hint)

Creates a new entity while attempting to re-use an invalid entity identifier as provided by .

EraseEntity

Entity::VersionType EraseEntity(Entity entity)

Removes an entity and all associated components from the set if it exists, otherwise does nothing.

Returns the version of the entity that was removed.

Private

Fields

mEntityStorage

EntitySparseSet mEntityStorage

mComponentStorage

UnorderedMap<TypeId, SPtr<SparseSet>> mComponentStorage

mGroupStorage

UnorderedMap<TypeId, SPtr<GroupCommon>> mGroupStorage