VEGO-Engine  0.1
Loading...
Searching...
No Matches
Entity Class Reference

Main class for any object in game, stores associations, labeling and components. More...

#include <Entity.h>

Public Types

enum class  GroupLabel {
  MAPTILES , PLAYERS , COLLIDERS , PROJECTILE ,
  HEARTS , POWERUPS
}
 Some premade Entity groups used to avoid checking all entities for everything all of the time. More...
 

Public Member Functions

 Entity (Manager &mManager)
 
void update (uint_fast16_t diffTime) const
 Call each frame to update all components.
 
bool isActive () const
 
void destroy ()
 
ManagergetManager ()
 
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.
 

Detailed Description

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.

Member Enumeration Documentation

◆ GroupLabel

enum class Entity::GroupLabel
strong

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

Constructor & Destructor Documentation

◆ Entity()

Entity::Entity ( Manager & mManager)
inlineexplicit
Todo
Document

Member Function Documentation

◆ addComponent()

template<typename T, typename... TArgs>
T & Entity::addComponent ( TArgs &&... mArgs)
inline

Adds specified type as component and calls Component::init()

Parameters
mArgsConstructor arguments of component

◆ destroy()

void Entity::destroy ( )
inline

Mark for destruction for Manager::refresh() and disables collision

See also
ColliderComponent

◆ getComponent()

template<typename T>
T & Entity::getComponent ( ) const
inline

Access a specific component of an entity.

Template Parameters
TType 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
TType of component to access
Returns
Pointer to component of type T

◆ getManager()

Manager & Entity::getManager ( )
inline
See also
Manager

◆ hasComponent()

template<typename T>
bool Entity::hasComponent ( ) const
inline
See also
Component

◆ isActive()

bool Entity::isActive ( ) const
inline
See also
destroy()

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