TrinityCore
Loading...
Searching...
No Matches
EventMap Class Reference

#include <EventMap.h>

Classes

struct  Event
 

Public Member Functions

 EventMap ()
 
Reset

Removes all scheduled events and resets time and phase.

void Reset ()
 
Update

Updates the timer of the event map.

Parameters
timeValue in ms to be added to time.
void Update (uint32 time)
 
void Update (Milliseconds time)
 
GetPhaseMask
Returns
Active phases as mask.
PhaseMask GetPhaseMask () const
 
Empty
Returns
True, if there are no events scheduled.
bool Empty () const
 
SetPhase

Sets the phase of the map (absolute).

Parameters
phasePhase which should be set. Values: 1 - 8. 0 resets phase.
void SetPhase (PhaseIndex phase)
 
AddPhase

Activates the given phase (absolute).

Parameters
phasePhase which should be activated. Values: 1 - 8
void AddPhase (PhaseIndex phase)
 
RemovePhase

Deactivates the given phase (absolute).

Parameters
phasePhase which should be deactivated. Values: 1 - 8.
void RemovePhase (PhaseIndex phase)
 
ScheduleEvent

Creates new event entry in map.

Parameters
eventIdThe id of the new event.
minTimeThe minimum time until the event occurs as std::chrono type.
maxTimeThe maximum time until the event occurs as std::chrono type.
groupThe group which the event is associated to. Has to be between 1 and 8. 0 means it has no group.
phaseThe phase in which the event can occur. Has to be between 1 and 8. 0 means it can occur in all phases.
void ScheduleEvent (EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
 
void ScheduleEvent (EventId eventId, Milliseconds minTime, Milliseconds maxTime, GroupIndex group=0u, PhaseIndex phase=0u)
 
RescheduleEvent

Cancels the given event and reschedules it.

Parameters
eventIdThe id of the event.
minTimeThe minimum time until the event occurs as std::chrono type.
maxTimeThe maximum time until the event occurs as std::chrono type.
groupThe group which the event is associated to. Has to be between 1 and 8. 0 means it has no group.
phaseThe phase in which the event can occur. Has to be between 1 and 8. 0 means it can occur in all phases.
void RescheduleEvent (EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
 
void RescheduleEvent (EventId eventId, Milliseconds minTime, Milliseconds maxTime, GroupIndex group=0u, PhaseIndex phase=0u)
 
RepeatEvent

Repeats the most recently executed event.

Parameters
minTimeThe minimum time until the event occurs as std::chrono type.
maxTimeThe maximum time until the event occurs as std::chrono type.
void Repeat (Milliseconds time)
 
void Repeat (Milliseconds minTime, Milliseconds maxTime)
 
ExecuteEvent

Returns the next event to execute and removes it from map.

Returns
Id of the event to execute.
EventId ExecuteEvent ()
 
DelayEvents

Delay all events of the same group.

Parameters
delayAmount of delay as std::chrono type.
groupGroup of the events.
void DelayEvents (Milliseconds delay)
 
void DelayEvents (Milliseconds delay, GroupIndex group)
 
SetMinimalDelay

Increase event delay if smaller than given delay.

Parameters
eventIdThe id of the event.
delayMinimum delay for given event.
void SetMinimalDelay (EventId eventId, Milliseconds delay)
 
CancelEvent

Cancels all events of the specified id.

Parameters
eventIdEvent id to cancel.
void CancelEvent (EventId eventId)
 
CancelEventGroup

Cancel events belonging to specified group.

Parameters
groupGroup to cancel.
void CancelEventGroup (GroupIndex group)
 
IsInPhase

Returns whether event map is in specified phase or not.

Parameters
phaseWanted phase.
Returns
True, if phase of event map contains specified phase.
bool IsInPhase (PhaseIndex phase) const
 
GetTimeUntilEvent

Returns time as std::chrono type until next event.

Parameters
eventIdThe id of the event.
Returns
Time of next event. If event is not scheduled returns Milliseconds::max()
Time of next event.
Milliseconds GetTimeUntilEvent (EventId eventId) const
 
HasEventScheduled

Returns whether an event is scheduled

Parameters
eventIdThe id of the event.
Returns
True if event is scheduled
bool HasEventScheduled (EventId eventId) const
 

Private Types

using EventId = uint16
 
using GroupIndex = uint8
 
using GroupMask = uint8
 
using PhaseIndex = uint8
 
using PhaseMask = uint8
 
using EventStore = std::multimap< TimePoint, Event >
 

Private Attributes

_time

Internal timer.

This does not represent the real date/time value. It's more like a stopwatch: It can run, it can be stopped, it can be resetted and so on. Events occur when this timer has reached their time value. Its value is changed in the Update method.

TimePoint _time
 
_phaseMask

Phase mask of the event map.

Contains the phases the event map is in. Multiple phases from 1 to 8 can be set with SetPhase or AddPhase. RemovePhase deactives a phase.

PhaseMask _phaseMask
 
_eventMap

Internal event storage map. Contains the scheduled events.

See typedef at the beginning of the class for more details.

EventStore _eventMap
 
_lastEvent

Stores information on the most recently executed event

Event _lastEvent
 

Detailed Description

Definition at line 25 of file EventMap.h.

Member Typedef Documentation

◆ EventId

using EventMap::EventId = uint16
private

Definition at line 27 of file EventMap.h.

◆ EventStore

using EventMap::EventStore = std::multimap<TimePoint, Event>
private

Internal storage type. Key: Time as TimePoint when the event should occur.

Definition at line 51 of file EventMap.h.

◆ GroupIndex

using EventMap::GroupIndex = uint8
private

Definition at line 28 of file EventMap.h.

◆ GroupMask

using EventMap::GroupMask = uint8
private

Definition at line 29 of file EventMap.h.

◆ PhaseIndex

using EventMap::PhaseIndex = uint8
private

Definition at line 30 of file EventMap.h.

◆ PhaseMask

using EventMap::PhaseMask = uint8
private

Definition at line 31 of file EventMap.h.

Constructor & Destructor Documentation

◆ EventMap()

EventMap::EventMap ( )
inline

Definition at line 54 of file EventMap.h.

Member Function Documentation

◆ AddPhase()

void EventMap::AddPhase ( PhaseIndex  phase)
inline

Definition at line 112 of file EventMap.h.

◆ CancelEvent()

void EventMap::CancelEvent ( EventId  eventId)

Definition at line 151 of file EventMap.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ CancelEventGroup()

void EventMap::CancelEventGroup ( GroupIndex  group)

Definition at line 165 of file EventMap.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DelayEvents() [1/2]

void EventMap::DelayEvents ( Milliseconds  delay)

Definition at line 95 of file EventMap.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DelayEvents() [2/2]

void EventMap::DelayEvents ( Milliseconds  delay,
GroupIndex  group 
)

Definition at line 109 of file EventMap.cpp.

+ Here is the call graph for this function:

◆ Empty()

bool EventMap::Empty ( ) const
inline

Definition at line 95 of file EventMap.h.

+ Here is the caller graph for this function:

◆ ExecuteEvent()

EventMap::EventId EventMap::ExecuteEvent ( )

Definition at line 73 of file EventMap.cpp.

+ Here is the call graph for this function:

◆ GetPhaseMask()

PhaseMask EventMap::GetPhaseMask ( ) const
inline

Definition at line 86 of file EventMap.h.

+ Here is the caller graph for this function:

◆ GetTimeUntilEvent()

Milliseconds EventMap::GetTimeUntilEvent ( EventId  eventId) const

Definition at line 179 of file EventMap.cpp.

+ Here is the caller graph for this function:

◆ HasEventScheduled()

bool EventMap::HasEventScheduled ( EventId  eventId) const

Definition at line 188 of file EventMap.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ IsInPhase()

bool EventMap::IsInPhase ( PhaseIndex  phase) const
inline

Definition at line 236 of file EventMap.h.

+ Here is the caller graph for this function:

◆ RemovePhase()

void EventMap::RemovePhase ( PhaseIndex  phase)
inline

Definition at line 123 of file EventMap.h.

◆ Repeat() [1/2]

void EventMap::Repeat ( Milliseconds  minTime,
Milliseconds  maxTime 
)

Definition at line 68 of file EventMap.cpp.

+ Here is the call graph for this function:

◆ Repeat() [2/2]

void EventMap::Repeat ( Milliseconds  time)

Definition at line 63 of file EventMap.cpp.

◆ RescheduleEvent() [1/2]

void EventMap::RescheduleEvent ( EventId  eventId,
Milliseconds  minTime,
Milliseconds  maxTime,
GroupIndex  group = 0u,
PhaseIndex  phase = 0u 
)

Definition at line 58 of file EventMap.cpp.

+ Here is the call graph for this function:

◆ RescheduleEvent() [2/2]

void EventMap::RescheduleEvent ( EventId  eventId,
Milliseconds  time,
GroupIndex  group = 0u,
PhaseIndex  phase = 0u 
)

Definition at line 52 of file EventMap.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Reset()

void EventMap::Reset ( )

Definition at line 21 of file EventMap.cpp.

◆ ScheduleEvent() [1/2]

void EventMap::ScheduleEvent ( EventId  eventId,
Milliseconds  minTime,
Milliseconds  maxTime,
GroupIndex  group = 0u,
PhaseIndex  phase = 0u 
)

Definition at line 47 of file EventMap.cpp.

+ Here is the call graph for this function:

◆ ScheduleEvent() [2/2]

void EventMap::ScheduleEvent ( EventId  eventId,
Milliseconds  time,
GroupIndex  group = 0u,
PhaseIndex  phase = 0u 
)

Definition at line 36 of file EventMap.cpp.

◆ SetMinimalDelay()

void EventMap::SetMinimalDelay ( EventId  eventId,
Milliseconds  delay 
)

Definition at line 130 of file EventMap.cpp.

+ Here is the call graph for this function:

◆ SetPhase()

void EventMap::SetPhase ( PhaseIndex  phase)

Definition at line 28 of file EventMap.cpp.

◆ Update() [1/2]

void EventMap::Update ( Milliseconds  time)
inline

Definition at line 77 of file EventMap.h.

◆ Update() [2/2]

void EventMap::Update ( uint32  time)
inline

Definition at line 67 of file EventMap.h.

Member Data Documentation

◆ _eventMap

EventStore EventMap::_eventMap
private

Definition at line 288 of file EventMap.h.

◆ _lastEvent

Event EventMap::_lastEvent
private

Definition at line 294 of file EventMap.h.

◆ _phaseMask

PhaseMask EventMap::_phaseMask
private

Definition at line 279 of file EventMap.h.

◆ _time

TimePoint EventMap::_time
private

Definition at line 269 of file EventMap.h.


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