Acheron
Loading...
Searching...
No Matches
acheron::ecs::ComponentArray< T > Class Template Reference

Container for components. More...

#include <component_array.hpp>

Inheritance diagram for acheron::ecs::ComponentArray< T >:
acheron::ecs::IComponentArray

Public Member Functions

void InsertData (Entity entity, T component)
 Add a component and its data to an entity.
bool HasData (Entity entity) const
 Checks if en entity has a component.
void RemoveData (Entity entity)
 Removes a component and its data associated with an entity.
T & GetData (Entity entity)
 Gets component data from an entity.
void EntityDespawned (Entity entity) override
 Called when an entity is despawned to remove all its component data.

Detailed Description

template<typename T>
class acheron::ecs::ComponentArray< T >

Container for components.

This class handles the association with entities and components, and holds the data for components

Template Parameters
TThe component type

Member Function Documentation

◆ EntityDespawned()

template<typename T>
void acheron::ecs::ComponentArray< T >::EntityDespawned ( Entity entity)
inlineoverridevirtual

Called when an entity is despawned to remove all its component data.

Parameters
entityEntity that was despawned

Reimplemented from acheron::ecs::IComponentArray.

◆ GetData()

template<typename T>
T & acheron::ecs::ComponentArray< T >::GetData ( Entity entity)
inline

Gets component data from an entity.

Parameters
entityEntity to retrieve the data from
Returns
The component data associated with the entity

◆ HasData()

template<typename T>
bool acheron::ecs::ComponentArray< T >::HasData ( Entity entity) const
inline

Checks if en entity has a component.

Parameters
entityThe entity to check
Returns
If component has entity

◆ InsertData()

template<typename T>
void acheron::ecs::ComponentArray< T >::InsertData ( Entity entity,
T component )
inline

Add a component and its data to an entity.

Parameters
entityThe entity to apply the component to
componentThe component to apply to the entity
Exceptions
AssertFail if the entity already has component T on it

◆ RemoveData()

template<typename T>
void acheron::ecs::ComponentArray< T >::RemoveData ( Entity entity)
inline

Removes a component and its data associated with an entity.

Parameters
entityThe entity to remove the component from
Exceptions
AssertFail if the component doesnt exist on the entity

The documentation for this class was generated from the following file: