Skip to content

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

See 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:

  • T The type of component to store.

Public Attributes Documentation

variable m_ComponentMap

std::unordered_map<Entity, T> Engine::ComponentArray< T >::m_ComponentMap;

Public Functions Documentation

function Clear

Removes the components of every entity from this array.

inline virtual void Engine::ComponentArray::Clear () override

Implements Engine::IComponentArray::Clear


function EntityDestroyed

Automatically cleans up components when an entity is destroyed.

inline virtual void Engine::ComponentArray::EntityDestroyed (
    Entity entity
) override

Parameters:

  • entity The entity ID.

Implements Engine::IComponentArray::EntityDestroyed


function GetData

Retrieves the component for a given entity.

inline T & Engine::ComponentArray::GetData (
    Entity entity
) 

Parameters:

  • entity The 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.

inline virtual bool Engine::ComponentArray::Has (
    Entity entity
) override const

Implements Engine::IComponentArray::Has


function HasData

inline bool Engine::ComponentArray::HasData (
    Entity entity
) const

function InsertData

Inserts a component for a given entity.

inline void Engine::ComponentArray::InsertData (
    Entity entity,
    T component
) 

Parameters:

  • entity The entity ID.
  • component The component data.

function Remove

Removes the component of an entity from this array.

inline virtual void Engine::ComponentArray::Remove (
    Entity entity
) override

Implements Engine::IComponentArray::Remove


function RemoveData

Removes a component for a given entity.

inline void Engine::ComponentArray::RemoveData (
    Entity entity
) 

Parameters:

  • entity The entity ID.

function begin [½]

inline auto Engine::ComponentArray::begin () 

function begin [2/2]

inline auto Engine::ComponentArray::begin () const

function clear

inline void Engine::ComponentArray::clear () 

function end [½]

inline auto Engine::ComponentArray::end () 

function end [2/2]

inline auto Engine::ComponentArray::end () const

function size

inline size_t Engine::ComponentArray::size () const


The documentation for this class was generated from the following file /home/runner/work/r-type/r-type/Engine/include/ECS/Registry.hpp