8#ifndef REGISTRY_IMPL_HPP
9#define REGISTRY_IMPL_HPP
20 template <
class Component>
22 componentsArrays[std::type_index(
typeid(
Component))] = std::make_any<SparseArray<Component>>();
24 return std::any_cast<SparseArray<Component> &>(componentsArrays[std::type_index(
typeid(
Component))]);
27 template <
class ... Components>
32 template <IsTuple Tuple>
39 template <
class Component>
41 return std::any_cast<SparseArray<Component> &>(componentsArrays[std::type_index(
typeid(
Component))]);
44 template <
class Component>
46 return std::any_cast<SparseArray<Component> &>(componentsArrays.at(std::type_index(
typeid(
Component))));
49 template <
typename...
Component,
typename>
54 template <
typename Component,
typename ... Params>
60 template <
typename ...
Component,
typename>
67 template<SystemImplementation System>
69 systems[std::type_index(
typeid(
System))] = std::shared_ptr<ISystem>(&
s, +[](
ISystem*){});
72 template<SystemImplementation System>
74 systems[std::type_index(
typeid(
System))] = std::make_shared<System>(std::move(
s));
84 systems[std::type_index(
typeid(
System))] = std::make_shared<System>(std::forward<Args>(
args)...);
89 (systems.erase(std::type_index(
typeid(
System))), ...);
94 (systems[std::type_index(
typeid(
System))]->update(*
this), ...);
Component is a template define in Registry. (not a class)
Abstract base class representing a system in the ECS architecture.
Entity class from ECS.
Definition Entity.hpp:26
define the Registry class
Definition Registry.hpp:44
void addComponent(Entity const &to, Component &&...c)
Definition Registry_impl.hpp:50
void emplaceSystem(Params &&... params)
add a system to the registry
void callSystem()
call a system
Definition Registry_impl.hpp:93
void removeSystem()
remove a system from the registry
Definition Registry_impl.hpp:88
void registerComponents()
register a list of components
Definition Registry_impl.hpp:28
SparseArray< Component > & registerComponent()
handling components (define in Registry_impl.hpp)
Definition Registry_impl.hpp:21
SparseArray< Component > & getComponents()
get components of a given type
Definition Registry_impl.hpp:40
void addSystem(System &s)
handling systems
Definition Registry_impl.hpp:68
void registerComponentsByExtraction()
register every components by extraction from a tuple
Definition Registry_impl.hpp:33
void emplaceComponent(Entity const &to, Params &&... p)
emplace a component to the given entity
Definition Registry_impl.hpp:55
void removeComponent(Entity const &from)
remove a component from the given entity
Definition Registry_impl.hpp:61
SparseArray class.
Definition SparseArray.hpp:45
Concept that ensures a type derives from System.
Definition System.hpp:55