Class Engine::ComponentArray¶
template <typename T>
ClassList > Engine > ComponentArray
Template class that stores a specific type of component for entities. More...
#include <Registry.hpp>
Inherits the following classes: Engine::IComponentArray
Public Attributes¶
| Type | Name |
|---|---|
| std::unordered_map< Entity, T > | m_ComponentMap |
Public Functions¶
| Type | Name |
|---|---|
| virtual void | Clear () override Removes the components of every entity from this array. |
| virtual void | EntityDestroyed (Entity entity) override Automatically cleans up components when an entity is destroyed. |
| T & | GetData (Entity entity) Retrieves the component for a given entity. |
| virtual bool | Has (Entity entity) override const Returns whether an entity has a component in this array. |
| bool | HasData (Entity entity) const |
| void | InsertData (Entity entity, T component) Inserts a component for a given entity. |
| virtual void | Remove (Entity entity) override Removes the component of an entity from this array. |
| void | RemoveData (Entity entity) Removes a component for a given entity. |
| auto | begin () |
| auto | begin () const |
| void | clear () |
| auto | end () |
| auto | end () const |
| size_t | size () const |
Public Functions inherited from Engine::IComponentArray¶
| Type | Name |
|---|---|
| virtual void | Clear () = 0 Removes the components of every entity from this array. |
| virtual void | EntityDestroyed (Entity entity) = 0 Called when an entity is destroyed, allows the array to clean up. |
| virtual bool | Has (Entity entity) const = 0 Returns whether an entity has a component in this array. |
| virtual void | Remove (Entity entity) = 0 Removes the component of an entity from this array. |
| virtual | ~IComponentArray () = default |
Detailed Description¶
Template parameters:
TThe type of component to store.
Public Attributes Documentation¶
variable m_ComponentMap¶
Public Functions Documentation¶
function Clear¶
Removes the components of every entity from this array.
Implements Engine::IComponentArray::Clear
function EntityDestroyed¶
Automatically cleans up components when an entity is destroyed.
Parameters:
entityThe entity ID.
Implements Engine::IComponentArray::EntityDestroyed
function GetData¶
Retrieves the component for a given entity.
Parameters:
entityThe entity ID.
Returns:
Reference to the component data.
Exception:
- ErrorEcs if the entity has no component of this type.
function Has¶
Returns whether an entity has a component in this array.
Implements Engine::IComponentArray::Has
function HasData¶
function InsertData¶
Inserts a component for a given entity.
Parameters:
entityThe entity ID.componentThe component data.
function Remove¶
Removes the component of an entity from this array.
Implements Engine::IComponentArray::Remove
function RemoveData¶
Removes a component for a given entity.
Parameters:
entityThe entity ID.
function begin [½]¶
function begin [2/2]¶
function clear¶
function end [½]¶
function end [2/2]¶
function size¶
The documentation for this class was generated from the following file /home/runner/work/r-type/r-type/Engine/include/ECS/Registry.hpp