CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::EntityActionManager Class Referencefinal

#include <CeresEngine/Entity/ActionManager.hpp>

Public Member Functions

 EntityActionManager ()=default
 
 EntityActionManager (const EntityActionManager &)=delete
 
EntityActionManageroperator= (const EntityActionManager &)=delete
 
 EntityActionManager (EntityActionManager &&)=delete
 
EntityActionManageroperator= (EntityActionManager &&)=delete
 
 ~EntityActionManager ()=default
 
template<CEntityAction Action, typename... Args>
bool canAct (Entity entity, Args &&... args) noexcept(std::is_nothrow_constructible_v< Action, Args... >)
 Checks if the action manager has an action handler that can handle the given action.
 
template<CEntityAction Action>
bool canAct (Entity entity, const Action &action) noexcept
 Checks if the action manager has an action handler that can handle the given action.
 
template<CEntityAction Action, typename... Args>
Action::ReturnType act (Entity entity, Args &&... args)
 Dispatches an action to a handler.
 
template<CEntityAction Action>
Action::ReturnType act (Entity entity, const Action &action)
 Dispatches an action to a handler.
 
template<CEntityAction A>
void add (EntityActionHandler< A > &actionHandler)
 Adds a new action handler.
 
void add (EntityActionID actionID, AbstractActionHandler &actionHandler)
 Adds a new action handler.
 
template<CEntityAction A>
void remove (EntityActionHandler< A > &actionHandler)
 Removes an existing action handler.
 
void remove (EntityActionID actionID, AbstractActionHandler &actionHandler)
 Adds a new action handler.
 

Private Attributes

HashMap< EntityActionID, Vector< AbstractActionHandler * > > mActionHandlers
 The map of action handlers.
 

Constructor & Destructor Documentation

◆ EntityActionManager() [1/3]

CeresEngine::EntityActionManager::EntityActionManager ( )
default

◆ EntityActionManager() [2/3]

CeresEngine::EntityActionManager::EntityActionManager ( const EntityActionManager )
delete

◆ EntityActionManager() [3/3]

CeresEngine::EntityActionManager::EntityActionManager ( EntityActionManager &&  )
delete

◆ ~EntityActionManager()

CeresEngine::EntityActionManager::~EntityActionManager ( )
default

Member Function Documentation

◆ act() [1/2]

template<CEntityAction Action, typename... Args>
Action::ReturnType CeresEngine::EntityActionManager::act ( Entity  entity,
Args &&...  args 
)

Dispatches an action to a handler.

Template Parameters
Actionthe action type to be dispatched
Argsthe action constructor argument types
Parameters
entityThe entity to be acted on
argsThe action constructor arguments
Returns
The value returned by the handler

◆ act() [2/2]

template<CEntityAction Action>
Action::ReturnType CeresEngine::EntityActionManager::act ( Entity  entity,
const Action &  action 
)

Dispatches an action to a handler.

Template Parameters
Actionthe action type to be dispatched
Parameters
entityThe entity to be acted on
actionThe action constructor arguments
Returns
The value returned by the handler

◆ add() [1/2]

template<CEntityAction A>
void CeresEngine::EntityActionManager::add ( EntityActionHandler< A > &  actionHandler)
inline

Adds a new action handler.

Template Parameters
Athe action type
Parameters
actionHandlerThe action handler instance

◆ add() [2/2]

void CeresEngine::EntityActionManager::add ( EntityActionID  actionID,
AbstractActionHandler actionHandler 
)

Adds a new action handler.

Parameters
actionIDThe action ID that the action handler supports
actionHandlerA pointer to the action handler

◆ canAct() [1/2]

template<CEntityAction Action, typename... Args>
bool CeresEngine::EntityActionManager::canAct ( Entity  entity,
Args &&...  args 
) const
noexcept

Checks if the action manager has an action handler that can handle the given action.

The action is constructed in-place.

Template Parameters
Actionthe action type to be checked
Argsthe constructor argument types
Parameters
entityThe entity to check the action for
argsThe constructor arguments
Returns
true if act can be called, false otherwise.

◆ canAct() [2/2]

template<CEntityAction Action>
bool CeresEngine::EntityActionManager::canAct ( Entity  entity,
const Action &  action 
)
noexcept

Checks if the action manager has an action handler that can handle the given action.

Template Parameters
Actionthe action type to be checked
Parameters
entityThe entity to check the action for
actionThe action to be checked
Returns
true if act can be called, false otherwise.

◆ operator=() [1/2]

EntityActionManager & CeresEngine::EntityActionManager::operator= ( const EntityActionManager )
delete

◆ operator=() [2/2]

EntityActionManager & CeresEngine::EntityActionManager::operator= ( EntityActionManager &&  )
delete

◆ remove() [1/2]

template<CEntityAction A>
void CeresEngine::EntityActionManager::remove ( EntityActionHandler< A > &  actionHandler)
inline

Removes an existing action handler.

Template Parameters
Athe action type
Parameters
actionHandlerThe action handler instance

◆ remove() [2/2]

void CeresEngine::EntityActionManager::remove ( EntityActionID  actionID,
AbstractActionHandler actionHandler 
)

Adds a new action handler.

Parameters
actionIDThe action ID that the action handler supports
actionHandlerA pointer to the action handler

Member Data Documentation

◆ mActionHandlers

HashMap<EntityActionID, Vector<AbstractActionHandler*> > CeresEngine::EntityActionManager::mActionHandlers
private

The map of action handlers.


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