stmm-games-doc  0.32.0
Classes | Public Member Functions | Protected Member Functions | List of all members
stmg::MockEvent Class Reference
Inheritance diagram for stmg::MockEvent:
Inheritance graph
[legend]

Classes

struct  Init
 

Public Member Functions

 MockEvent (Init &&oInit) noexcept
 Constructor. More...
 
 MockEvent (Init &&oInit, std::function< void(Level &oLevel)> &&oTriggerFunction) noexcept
 Constructor with custom function. More...
 
void setVariable (int32_t nVarId, int32_t nTeam, int32_t nMate, int32_t nValue) noexcept
 Sets a variable when triggered (before inform listeners is called). More...
 
void setTriggerValue (int32_t nGroup, int32_t nValue, int32_t nSkipTicks) noexcept
 Set the value the trigger function should send. More...
 
void trigger (int32_t, int32_t, Event *p0TriggeringEvent) noexcept override
 The common triggering function. More...
 
- Public Member Functions inherited from stmg::Event
virtual ~Event () noexcept=default
 
virtual void addMsgFilter (int32_t nInFromMsg, int32_t nInToMsg, int32_t nInFromValue, int32_t nInToValue, bool bOutMsgDefined, int32_t nOutMsg, MSG_FILTER_VALUE_OP eOutValueOperator, int32_t nOutValueOperand, int32_t nOutValueAdd) noexcept
 Add a message filter. More...
 
virtual void addListener (int32_t nGroupId, Event *p0ListenerEvent, int32_t nMsg) noexcept
 Adds a listener to the event. More...
 
bool isActive () const noexcept
 Tells whether the event is active. More...
 
int32_t getTriggerTime () const noexcept
 The triggering time. More...
 
int32_t getPriority () const noexcept
 The priority. More...
 
int32_t getDebugTag () const noexcept
 The debug tag. More...
 

Protected Member Functions

void reInit (Init &&oInit) noexcept
 Reinitialization. More...
 
void reInit (Init &&oInit, std::function< void(Level &oLevel)> &&oTriggerFunction) noexcept
 Reinitialization with custom function. More...
 
- Protected Member Functions inherited from stmg::Event
 Event (Init &&oInit) noexcept
 Constructor. More...
 
void reInit (Init &&oInit) noexcept
 Reinitialization. More...
 
virtual void informListeners (int32_t nGroupId, int32_t nValue) noexcept
 Calls the trigger function of a group of listeners. More...
 
const Levellevel () const noexcept
 The level this event belongs to. More...
 
Levellevel () noexcept
 The level this event belongs to. More...
 

Additional Inherited Members

- Public Types inherited from stmg::Event
enum  MSG_FILTER_VALUE_OP {
  MSG_FILTER_VALUE_OP_FIRST = 0, MSG_FILTER_VALUE_OP_UNCHANGED = 0, MSG_FILTER_VALUE_OP_SET = 1, MSG_FILTER_VALUE_OP_MULT_ADD = 2,
  MSG_FILTER_VALUE_OP_DIV_ADD = 3, MSG_FILTER_VALUE_OP_PERCENT_ADD = 4, MSG_FILTER_VALUE_OP_PERMILL_ADD = 5, MSG_FILTER_VALUE_OP_MOD_ADD = 6,
  MSG_FILTER_VALUE_OP_MIN_ADD = 7, MSG_FILTER_VALUE_OP_MAX_ADD = 8, MSG_FILTER_VALUE_OP_LAST = 8
}
 Value filter. More...
 
enum  { LISTENER_GROUP_FINISHED = 0 }
 

Constructor & Destructor Documentation

◆ MockEvent() [1/2]

stmg::MockEvent::MockEvent ( Init &&  oInit)
explicitnoexcept

Constructor.

Parameters
oInitThe initialization data.

◆ MockEvent() [2/2]

stmg::MockEvent::MockEvent ( Init &&  oInit,
std::function< void(Level &oLevel)> &&  oTriggerFunction 
)
noexcept

Constructor with custom function.

The function is called when the event is triggered. See Level::activateEvent().

Parameters
oInitThe initialization data.
oTriggerFunctionThe trigger function.

Member Function Documentation

◆ reInit() [1/2]

void stmg::MockEvent::reInit ( Init &&  oInit)
protectednoexcept

Reinitialization.

Parameters
oInitThe initialization data.

◆ reInit() [2/2]

void stmg::MockEvent::reInit ( Init &&  oInit,
std::function< void(Level &oLevel)> &&  oTriggerFunction 
)
protectednoexcept

Reinitialization with custom function.

Parameters
oInitThe initialization data.
oTriggerFunctionThe trigger function.

◆ setTriggerValue()

void stmg::MockEvent::setTriggerValue ( int32_t  nGroup,
int32_t  nValue,
int32_t  nSkipTicks 
)
noexcept

Set the value the trigger function should send.

Parameters
nGroupThe group that should be triggered.
nValueThe value passed.
nSkipTicksHow many ticks to the triggering.

◆ setVariable()

void stmg::MockEvent::setVariable ( int32_t  nVarId,
int32_t  nTeam,
int32_t  nMate,
int32_t  nValue 
)
noexcept

Sets a variable when triggered (before inform listeners is called).

This is useful because variables can only be set within a game tick.

If a variable is set more than once only the last matters.

Parameters
nVarIdThe variable id. Must be valid.
nTeamThe team. If -1 it is a game variable.
nMateThe mate. If -1 it is a game or team variable.
nValueThe new value.

◆ trigger()

void stmg::MockEvent::trigger ( int32_t  ,
int32_t  ,
Event p0TriggeringEvent 
)
overridevirtualnoexcept

The common triggering function.

Triggers the group and value set in setTriggerValue(). Note that if this event is triggered by another event it won't do anything.

Implements stmg::Event.