ecs::Registry
#include <Registry.hpp>
Public Functions
Registry()
template <class Component > SparseArray< Component > &
template <class Component > SparseArray< Component > &
template <class Component > SparseArray< Component > const &
getComponents() const
entityFromIndex(std::size_t idx)
void
killEntity(Entity const & e)
template <typename Component > SparseArray< Component >::referenceType
addComponent(Entity const & to, Component && c)
template <typename Component ,typename... Params> SparseArray< Component >::referenceType
emplaceComponent(Entity const & to, Params &&... p)
template <typename Component > void
removeComponent(Entity const & from)
Detailed Description
class ecs::Registry;[This is the core of the ECS]
This class contains many feature as follows :
Component Manager, Registry is able to register/get components from the unordered map
(Feel free to check the Entity.hpp to learn more about the subject)
EntitiesBin Manager, Registry is saving killed entity in the bin that which can be recovered instead of creating another one
Public Functions Documentation
function Registry
function registerComponent
Template Parameters:
Component The type of components you want to register
Return: The SparseArray of components you just registered
This function is used to register a new component in the private member _unordered_map
function getComponents
Template Parameters:
Component The type of components you want to get
Return: The SparseArray of components you asked
This function is used to get all components already registered in the Registry class following the given component template
function getComponents
Template Parameters:
Component The type of components you want to get
Return: The const SparseArray of components you asked
This function is used to get all components already registered in the Registry class following the given component template as const
function spawn_entity
Return: The entity just created (id)
This function is used to create a new entity if it doesn't exists in the _entitiesBin, otherwise it recover it from the bin
function entityFromIndex
Parameters:
idx The index of the entity whose id is desired
Return: The id of the Entity if it exists, ecs::npos otherwise
This function is used to get the id of the Entity following the give index
function killEntity
Parameters:
e The Entity you want to kill
This is used to delete the given Entity (id) For optimisation purposes, Registry class push it in the _entitiesBin
function addComponent
Parameters:
to The Entity in which you want to add component
c The component you want to add
Template Parameters:
Component The type of component want to be added
Return: the SparseArray reference of the component
This function is used to add a component into the Entity given as parameter. In the same time, the erase function of this component is pushed into the _eraseFunctions vector, in this case we can simply delete a component without needing type of it
function emplaceComponent
Parameters:
to The Entity in which you want to emplace component
p Parameters of the component you want to emplace
Template Parameters:
Component The type of component you want to emplace
Params The parameters' type of the component you want to emplace
Return: the SparseArray reference of the component
This function is used to emplace a component with given parameters of this component
function removeComponent
Parameters:
from The Entity in which you want to remove component
Template Parameters:
Component The type of the component you want to remove
This function is used to remove a component into an Entity given as parameter
Updated on 2022-11-13 at 17:21:37 +0100
Last updated