Main class for any object in game, stores associations, labeling and components.
More...
#include <Entity.h>
|
| | Entity (Manager &mManager) |
| |
|
void | update (uint_fast16_t diffTime) const |
| | Call each frame to update all components.
|
| |
| bool | isActive () const |
| |
| void | destroy () |
| |
| Manager & | getManager () |
| |
| template<typename T> |
| bool | hasComponent () const |
| |
| template<typename T, typename... TArgs> |
| T & | addComponent (TArgs &&...mArgs) |
| | Adds specified type as component and calls Component::init()
|
| |
| template<typename T> |
| T & | getComponent () const |
| | Access a specific component of an entity.
|
| |
| template<typename T> |
| std::shared_ptr< T > | getComponentAsPointer () const |
| | Access a specific component of an entity as a pointer.
|
| |
Main class for any object in game, stores associations, labeling and components.
The entity class is the primary class each object in the game needs to use. Add components to assign functionality.
- Todo
More detailed description
Some functions in entity class are only supposed to be called in specific context, which might be valid uses for friend keyword. Example: Entity() should only be called from Manager::addEntity(). Verify each functions intended use/scope.
◆ GroupLabel
Some premade Entity groups used to avoid checking all entities for everything all of the time.
| Enumerator |
|---|
| MAPTILES | Entity using TileComponent, internal use.
|
| PLAYERS | Primary entity in player control, used to be able to interact with pickupables.
|
| COLLIDERS | Fixed collider entity, e.g. a wall.
|
| PROJECTILE | - Todo
- Document
|
| HEARTS | - Todo
- Document
|
| POWERUPS | - Todo
- Document
|
◆ Entity()
| Entity::Entity |
( |
Manager & | mManager | ) |
|
|
inlineexplicit |
◆ addComponent()
template<typename T, typename... TArgs>
| T & Entity::addComponent |
( |
TArgs &&... | mArgs | ) |
|
|
inline |
Adds specified type as component and calls Component::init()
- Parameters
-
| mArgs | Constructor arguments of component |
◆ destroy()
◆ getComponent()
template<typename T>
| T & Entity::getComponent |
( |
| ) |
const |
|
inline |
Access a specific component of an entity.
- Template Parameters
-
| T | Type of component to access |
- Returns
- Reference to component of type T <
- Todo
- : rewrite to use optionals
◆ getComponentAsPointer()
template<typename T>
| std::shared_ptr< T > Entity::getComponentAsPointer |
( |
| ) |
const |
|
inline |
Access a specific component of an entity as a pointer.
- Template Parameters
-
| T | Type of component to access |
- Returns
- Pointer to component of type T
◆ getManager()
◆ hasComponent()
template<typename T>
| bool Entity::hasComponent |
( |
| ) |
const |
|
inline |
◆ isActive()
| bool Entity::isActive |
( |
| ) |
const |
|
inline |
The documentation for this class was generated from the following files: