FECS
Loading...
Searching...
No Matches
FECS::Registry Class Reference

Acts as a main interface for the ECS, manages a **Local** environment for entities, and component manipulation. More...

#include <registry.h>

Public Member Functions

 Registry ()
 Constructs a new Registry Instance.
 
Entity CreateEntity ()
 Creates a new Entity.
 
void DestroyEntity (Entity id)
 Destroys an Entity and Removes its components.
 
bool IsEntityAlive (Entity id) const
 Checks whether the given entity is still alive.
 
EntityManagerGetEntityManager ()
 Get the local entity manager.
 
void Reserve (std::size_t size)
 Reserve a predicted amount of components.
 
template<typename T>
Container::SparseSet< T > & RegisterComponent ()
 Registers a new Component Type and returns its Pool.
 
template<typename T>
Container::SparseSet< T > & GetPool ()
 Retrieves the pool for a given component type.
 
template<typename T>
void Attach (Entity e, const T &component)
 Attachs a component to an entity.
 
template<typename T>
T & Get (Entity e)
 Retrieves a component reference attached to an entity.
 
template<typename T>
void Detach (Entity e)
 Detaches a component from an entity.
 
template<typename T>
bool Has (Entity e)
 Checks if a given component type exists on an entity.
 
template<typename... C>
FECS::View< C... > View ()
 Creates a view for the specified component types.
 

Detailed Description

Acts as a main interface for the ECS, manages a **Local** environment for entities, and component manipulation.

The registry handes entity creation and destruction, component attachment/detachment, exposes access to Component Pool and Views

Member Function Documentation

◆ Attach()

template<typename T>
void FECS::Registry::Attach ( Entity e,
const T & component )
inline

Attachs a component to an entity.

Template Parameters
TThe component type.
Parameters
eThe target entity.
componentThe component to attach.

◆ CreateEntity()

Entity FECS::Registry::CreateEntity ( )
inline

Creates a new Entity.

Returns
The newly created Entity ID.

◆ DestroyEntity()

void FECS::Registry::DestroyEntity ( Entity id)
inline

Destroys an Entity and Removes its components.

Parameters
idThe ID of the entity to destroy.

◆ Detach()

template<typename T>
void FECS::Registry::Detach ( Entity e)
inline

Detaches a component from an entity.

Template Parameters
TThe component type.
Parameters
eThe target entity

◆ Get()

template<typename T>
T & FECS::Registry::Get ( Entity e)
inline

Retrieves a component reference attached to an entity.

Template Parameters
TThe component type.
Parameters
eThe target entity.
Returns
Reference to the component.

◆ GetEntityManager()

EntityManager & FECS::Registry::GetEntityManager ( )
inline

Get the local entity manager.

Returns
A reference to the entity manager

◆ GetPool()

template<typename T>
Container::SparseSet< T > & FECS::Registry::GetPool ( )
inline

Retrieves the pool for a given component type.

Template Parameters
TThe component type.
Returns
Reference to the component's Sparse Set pool.
Note
This function may pay the allocation cost for the component pool use RegisterComponent<T>() to avoid that cost.

◆ Has()

template<typename T>
bool FECS::Registry::Has ( Entity e)
inline

Checks if a given component type exists on an entity.

Template Parameters
TThe component type.
Parameters
eThe target entity.

◆ IsEntityAlive()

bool FECS::Registry::IsEntityAlive ( Entity id) const
inline

Checks whether the given entity is still alive.

Parameters
idThe ID of the entity to check.
Returns
True if the entity is alive, otherwise false.

◆ RegisterComponent()

template<typename T>
Container::SparseSet< T > & FECS::Registry::RegisterComponent ( )
inline

Registers a new Component Type and returns its Pool.

Template Parameters
TThe component type.
Returns
Reference to the component's SparseSet pool.

◆ Reserve()

void FECS::Registry::Reserve ( std::size_t size)
inline

Reserve a predicted amount of components.

Parameters
sizeThe number of predicted components

◆ View()

template<typename... C>
FECS::View< C... > FECS::Registry::View ( )
inline

Creates a view for the specified component types.

Template Parameters
C...The component types to include in the view.
Returns
A View object for iterating over matching entities.

The documentation for this class was generated from the following file: