An Entity is a collection of components with a unique ID. More...
#include <Entity.h>
Public Member Functions | |
| Entity () | |
| Default constructor. More... | |
| Identifier | getId () const |
| Returns the ID of the entity. | |
| template<typename Component > | |
| bool | has () const |
| Returns whether the entity has a component of type T. | |
| template<typename T , typename V , typename... Types> | |
| bool | has () const |
| Returns whether the entity has all the components of the given types. | |
| template<typename Component , typename... Args> | |
| void | addComponent (Args &&...args) |
| Attaches a component to the entity. More... | |
| template<typename Component > | |
| void | removeComponent () |
| Removes the component of type T from the entity. More... | |
| template<typename Component > | |
| Component * | get () |
| Returns a pointer to the entity's component of the specified type. More... | |
| bool | isDeleted () const |
| Returns whether this entity is marked for deletion upon the next pass of the garbage collector. | |
| void | markForDeletion () |
| Marks the entity for deletion. More... | |
| bool | operator== (const Entity &other) |
| Returns true if the IDs of the entities are the same. | |
| bool | operator!= (const Entity &other) |
| Returns true if the IDs of the entities are different. | |
| bool | operator< (const Entity &other) |
| Returns true if the ID of this entity is smaller than the other. | |
An Entity is a collection of components with a unique ID.
An Entity can only have one component of each type at the same time.
| Entity::Entity | ( | ) |
Default constructor.
Sets the ID of the entity to the next available ID.
| void lz::Entity::addComponent | ( | Args &&... | args | ) |
Attaches a component to the entity.
The component will be constructed with the arguments passed and attached to the entity's pool of components. Therefore, the component must have a constructor that matches the arguments passed.
If the entity already has a component of the specified type, an exception will be thrown.
| Component * lz::Entity::get | ( | ) |
Returns a pointer to the entity's component of the specified type.
If the entity does not hold a component of that type, a nullptr will be returned.
|
inline |
Marks the entity for deletion.
An entity marked for deletion will be cleared from memory on the next pass of the ECS engine garbage collector.
| void lz::Entity::removeComponent | ( | ) |
Removes the component of type T from the entity.
If the entity does not have a component of the specified type, an exception is thrown.
1.8.6