|
R-Type
|
Entity component system, handling entities, components and systems. More...
#include <Registry.hpp>
Public Member Functions | |
| Registry (const std::size_t maxEntities) | |
| Constructor. More... | |
| template<class Component > | |
| SparseArray< Component > & | registerComponent () |
| Register a new component to the registry. More... | |
| template<class Component > | |
| SparseArray< Component > & | getComponent () |
| Getter to a speecific component's SparseArray. More... | |
| template<class Component > | |
| const SparseArray< Component > & | getComponent () const |
| Getter to a speecific component's SparseArray. More... | |
| Entity | spawnEntity () |
| Spawns a new entity. Entities can't be spawned otherwise. More... | |
| Entity | spawnEntity (const std::size_t &id) |
| Spawns a new entity. Entities can't be spawned otherwise. More... | |
| Entity | getEntityById (const std::size_t &id) const |
| Getter for an entity at a given index. Will throw an error if the entity hasn't been spawned. More... | |
| void | killEntity (const Entity &entity) |
| Kills the entity given, it destroys all the components to this entity. More... | |
| template<typename Component > | |
| SparseArray< Component >::referenceType | addComponent (const Entity &entity, Component &&component) |
| Add a component to the entity given. More... | |
| template<typename Component > | |
| SparseArray< Component >::referenceType | addComponent (const Entity &entity, const Component &component) |
| Add a component to the entity given. More... | |
| template<typename Component , typename... Params> | |
| SparseArray< Component >::referenceType | emplaceComponent (const Entity &entity, Params &&...params) |
| Emplace the component type to the entities given. More... | |
| template<typename Component > | |
| void | removeComponent (const Entity &entity) |
| Removes a component to the specified entity. More... | |
| template<typename Component > | |
| bool | isComponentRegistered () |
| tells if a component is registered More... | |
| template<typename Function , class... Components> | |
| void | addSystem (const Function &function) |
| Adds a system to the registry. The system function can take reference to some component's SparseArrays, they will be automatically get. More... | |
| template<typename SystemClass , class... Components> | |
| void | addSystem (std::shared_ptr< SystemClass > systemClass) |
| Adds a system to the registry. This method is to use when the class system needs to stay at the same place in the memory (for example DrawSystem) More... | |
| void | runSystems () |
| Runs all the registered system functions. Need to be called in the main loop. More... | |
Friends | |
| class | Debug::DebugMenu |
Entity component system, handling entities, components and systems.
|
inline |
Constructor.
| maxEntities | Maximum amount of entities at once. Will set the maximum size for the components array. |
|
inline |
Add a component to the entity given.
| Component | type of the component to add to the entity. |
| entity | Entity on which the component will be added. |
| component | Component to add to the entity. The component will be moved. |
|
inline |
Add a component to the entity given.
| Component | type of the component to add to the entity. |
| entity | Entity on which the component will be added. |
| component | Component to add to the entity. The component will be copied. |
|
inline |
Adds a system to the registry. The system function can take reference to some component's SparseArrays, they will be automatically get.
| Function | type of the system function to registeru |
| ...Components | Variadic template for the components which are in parameter of the system function. |
| function | System function to register. |
|
inline |
Adds a system to the registry. This method is to use when the class system needs to stay at the same place in the memory (for example DrawSystem)
| SystemClass | Class of the system to register, must have an overload for the () |
| ...Components | Variadic template for the components which are in parameter of the system function. |
| systemClass | System class to register. |
|
inline |
Emplace the component type to the entities given.
| Component | type of the component to emplace to the entities. |
| ...Params | Variadic parameters of Entities to emplace the component to. |
| entity | First entity to emplace. |
| ...params | Variadic parameter of entities. |
|
inline |
Getter to a speecific component's SparseArray.
| Component | type of the component to get |
|
inline |
Getter to a speecific component's SparseArray.
| Component | type of the component to get |
|
inline |
Getter for an entity at a given index. Will throw an error if the entity hasn't been spawned.
| id | Index of the entity. |
|
inline |
tells if a component is registered
| Component | component to find |
|
inline |
Kills the entity given, it destroys all the components to this entity.
| entity | Entity to kill. |
|
inline |
Register a new component to the registry.
| Component | type of the component to register |
|
inline |
Removes a component to the specified entity.
| Component | type of the component to remove. |
| entity | Entity to remove the component from. |
|
inline |
Runs all the registered system functions. Need to be called in the main loop.
|
inline |
Spawns a new entity. Entities can't be spawned otherwise.
|
inline |
Spawns a new entity. Entities can't be spawned otherwise.
| id | Id of the entity to spawn. |
|
friend |