A general-purpose object in the game world.
More...
#include <ECS.h>
|
| | Entity (Manager &memManager, std::string _id) |
| | Constructs an Entity.
|
| |
|
void | update () |
| | Calls the update method on all of its components.
|
| |
|
void | draw () |
| | Calls the draw method on all of its components.
|
| |
| bool | isActive () const |
| | Checks if the entity is currently active.
|
| |
| std::string | getID () const |
| | Gets the entity's string identifier.
|
| |
|
void | enable () |
| | Activates the entity, enabling its update and draw calls.
|
| |
|
void | disable () |
| | Deactivates the entity, disabling its update and draw calls.
|
| |
|
void | refresh () |
| | Marks the entity to be refreshed in the manager's group lists.
|
| |
|
void | reload () |
| | Calls the reload method on all of its components.
|
| |
| bool | hasGroup (GroupID memGroup) |
| | Checks if the entity belongs to a specific group.
|
| |
| void | delGroup (GroupID memGroup) |
| | Removes the entity from a specific group.
|
| |
| void | addGroup (GroupID memGroup) |
| | Adds the entity to a specific group.
|
| |
| template<typename T > |
| bool | hasComponent () const |
| | Checks if the entity has a component of a specific type.
|
| |
| template<typename T > |
| void | delComponent () |
| | Removes a component of a specific type from the entity.
|
| |
|
void | deleteAllComponents () |
| | Removes all components from the entity.
|
| |
| template<typename T , typename... TArgs> |
| T & | addComponent (TArgs &&... mArgs) |
| | Adds a component to the entity.
|
| |
| template<typename T > |
| T & | getComponent () const |
| | Retrieves a component from the entity.
|
| |
A general-purpose object in the game world.
An Entity is a container for components and does not have logic of its own.
◆ Entity()
| Entity::Entity |
( |
Manager & |
memManager, |
|
|
std::string |
_id |
|
) |
| |
Constructs an Entity.
- Parameters
-
| memManager | A reference to the main manager. |
| _id | A unique string identifier for the entity. |
◆ addComponent()
| T & Entity::addComponent |
( |
TArgs &&... |
mArgs | ) |
|
|
inline |
Adds a component to the entity.
- Template Parameters
-
| T | The component type to add. |
| TArgs | The types of arguments for the component's constructor. |
- Parameters
-
| mArgs | The arguments for the component's constructor. |
- Returns
- A reference to the newly added component.
◆ addGroup()
| void Entity::addGroup |
( |
GroupID |
memGroup | ) |
|
Adds the entity to a specific group.
- Parameters
-
| memGroup | The GroupID to add to. |
◆ delComponent()
| void Entity::delComponent |
( |
| ) |
|
|
inline |
Removes a component of a specific type from the entity.
- Template Parameters
-
| T | The component type to remove. |
◆ delGroup()
| void Entity::delGroup |
( |
GroupID |
memGroup | ) |
|
Removes the entity from a specific group.
- Parameters
-
| memGroup | The GroupID to remove from. |
◆ getComponent()
| T & Entity::getComponent |
( |
| ) |
const |
|
inline |
Retrieves a component from the entity.
- Template Parameters
-
| T | The component type to retrieve. |
- Returns
- A reference to the component.
- Exceptions
-
| std::runtime_error | if the component does not exist. |
◆ getID()
| std::string Entity::getID |
( |
| ) |
const |
Gets the entity's string identifier.
- Returns
- The entity's ID.
◆ hasComponent()
| bool Entity::hasComponent |
( |
| ) |
const |
|
inline |
Checks if the entity has a component of a specific type.
- Template Parameters
-
| T | The component type to check for. |
- Returns
- True if the component exists, false otherwise.
◆ hasGroup()
| bool Entity::hasGroup |
( |
GroupID |
memGroup | ) |
|
Checks if the entity belongs to a specific group.
- Parameters
-
| memGroup | The GroupID to check. |
- Returns
- True if the entity is in the group, false otherwise.
◆ isActive()
| bool Entity::isActive |
( |
| ) |
const |
Checks if the entity is currently active.
- Returns
- True if active, false otherwise.
The documentation for this struct was generated from the following files:
- include/ECS.h
- src/ECS.cpp