Saga
Saga Game Engine
|
Container for a specific Component type. More...
#include <componentContainer.h>
Public Member Functions | |
virtual | ~ComponentContainer () |
Destroy the Component Container object. | |
template<typename... Args> | |
Component * | emplace (const Entity entity, Args &&...args) |
Emplace a component onto an entity. This created. | |
std::vector< Component >::iterator | begin () |
std::vector< Component >::iterator | end () |
std::vector< Component >::const_iterator | begin () const |
std::vector< Component >::const_iterator | end () const |
Component * | getComponent (const Entity entity) |
Get a pointer to a Component attached to an entity. | |
bool | hasComponent (const Entity entity) |
Determine if an entity has this type of Component attached. | |
Entity | getEntity (Component *component) |
Get an Entity with this specific component. | |
void | removeComponent (const Entity entity) |
Remove a component from an entity. This also allows the slot used for the component to be free to used for when new components gets added. | |
int | getActiveCnt () |
int | getLastReallocated () override |
Get the last time the component container resize the vector containing all the components. | |
Public Member Functions inherited from Saga::IComponentContainer | |
virtual | ~IComponentContainer ()=default |
Destroy the IComponentContainer object. | |
virtual void | onEntityDestroyed (Entity entity)=0 |
Handler for when an entity is deleted. This should remove the entity from the Container, as well as the associated component if it exists. | |
virtual int | getLastReallocated ()=0 |
Get the last time the container was changed. Useful for cacheing references from the container. | |
Container for a specific Component type.
Component | the component this container manages. |
|
inlinevirtual |
Destroy the Component Container object.
std::vector< Component >::iterator Saga::ComponentContainer< Component >::begin |
std::vector< Component >::const_iterator Saga::ComponentContainer< Component >::begin |
Component * Saga::ComponentContainer< Component >::emplace | ( | const Entity | entity, |
Args &&... | args | ||
) |
Emplace a component onto an entity. This created.
Args | the argument types that the component's constructor accepts. |
entity | the entity to add the component into. |
args | the arguments used to construct the component. |
std::invalid_argument | if the entity already has this component attached. |
std::vector< Component >::iterator Saga::ComponentContainer< Component >::end |
std::vector< Component >::const_iterator Saga::ComponentContainer< Component >::end |
|
inline |
Component * Saga::ComponentContainer< Component >::getComponent | ( | const Entity | entity | ) |
Get a pointer to a Component attached to an entity.
entity |
Entity Saga::ComponentContainer< Component >::getEntity | ( | Component * | component | ) |
Get an Entity with this specific component.
component |
|
inlineoverridevirtual |
Get the last time the component container resize the vector containing all the components.
Implements Saga::IComponentContainer.
bool Saga::ComponentContainer< Component >::hasComponent | ( | const Entity | entity | ) |
Determine if an entity has this type of Component attached.
entity |
void Saga::ComponentContainer< Component >::removeComponent | ( | const Entity | entity | ) |
Remove a component from an entity. This also allows the slot used for the component to be free to used for when new components gets added.
entity |