Nox Engine
 
Loading...
Searching...
No Matches
Entity Struct Reference

A general-purpose object in the game world. More...

#include <ECS.h>

Collaboration diagram for Entity:
Collaboration graph

Public Member Functions

 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>
TaddComponent (TArgs &&... mArgs)
 Adds a component to the entity.
 
template<typename T >
TgetComponent () const
 Retrieves a component from the entity.
 

Detailed Description

A general-purpose object in the game world.

An Entity is a container for components and does not have logic of its own.

Constructor & Destructor Documentation

◆ Entity()

Entity::Entity ( Manager memManager,
std::string  _id 
)

Constructs an Entity.

Parameters
memManagerA reference to the main manager.
_idA unique string identifier for the entity.
Here is the call graph for this function:

Member Function Documentation

◆ addComponent()

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

Adds a component to the entity.

Template Parameters
TThe component type to add.
TArgsThe types of arguments for the component's constructor.
Parameters
mArgsThe arguments for the component's constructor.
Returns
A reference to the newly added component.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ addGroup()

void Entity::addGroup ( GroupID  memGroup)

Adds the entity to a specific group.

Parameters
memGroupThe GroupID to add to.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ delComponent()

template<typename T >
void Entity::delComponent ( )
inline

Removes a component of a specific type from the entity.

Template Parameters
TThe component type to remove.
Here is the call graph for this function:

◆ delGroup()

void Entity::delGroup ( GroupID  memGroup)

Removes the entity from a specific group.

Parameters
memGroupThe GroupID to remove from.
Here is the call graph for this function:

◆ getComponent()

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

Retrieves a component from the entity.

Template Parameters
TThe component type to retrieve.
Returns
A reference to the component.
Exceptions
std::runtime_errorif the component does not exist.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getID()

std::string Entity::getID ( ) const

Gets the entity's string identifier.

Returns
The entity's ID.
Here is the caller graph for this function:

◆ hasComponent()

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

Checks if the entity has a component of a specific type.

Template Parameters
TThe component type to check for.
Returns
True if the component exists, false otherwise.
Here is the call graph for this function:

◆ hasGroup()

bool Entity::hasGroup ( GroupID  memGroup)

Checks if the entity belongs to a specific group.

Parameters
memGroupThe GroupID to check.
Returns
True if the entity is in the group, false otherwise.
Here is the call graph for this function:

◆ 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: