41 EventMap() : _time(0), _phase(0), _lastEvent(0) { }
83 return _eventMap.empty();
91 void SetPhase(
uint8 phase);
100 if (phase && phase <= 8)
101 _phase |=
uint8(1 << (phase - 1));
111 if (phase && phase <= 8)
112 _phase &=
uint8(~(1 << (phase - 1)));
125 ScheduleEvent(eventId,
uint32(time.count()), group, phase);
148 RescheduleEvent(eventId,
uint32(time.count()), group, phase);
161 CancelEvent(eventId);
162 ScheduleEvent(eventId, time, group, phase);
172 Repeat(
uint32(time.count()));
182 _eventMap.insert(EventStore::value_type(_time + time, _lastEvent));
193 Repeat(
uint32(minTime.count()),
uint32(maxTime.count()));
204 Repeat(
urand(minTime, maxTime));
221 DelayEvents(
uint32(delay.count()));
231 _time = delay < _time ? _time - delay : 0;
242 DelayEvents(
uint32(delay.count()), group);
258 void CancelEvent(
uint32 eventId);
265 void CancelEventGroup(
uint32 group);
281 return Empty() ? 0 : _eventMap.begin()->first;
292 return phase <= 8 && (!phase || _phase & (1 << (phase - 1)));
342 #endif // _EVENT_MAP_H_
void RescheduleEvent(uint32 eventId, uint32 time, uint32 group=0, uint8 phase=0)
Definition: EventMap.h:159
void Repeat(uint32 minTime, uint32 maxTime)
Definition: EventMap.h:202
void DelayEvents(uint32 delay)
Definition: EventMap.h:229
std::multimap< uint32, uint32 > EventStore
Definition: EventMap.h:38
void DelayEvents(Milliseconds const &delay, uint32 group)
Definition: EventMap.h:240
uint32 GetTimer() const
Definition: EventMap.h:63
void Repeat(uint32 time)
Definition: EventMap.h:180
uint8 _phase
Definition: EventMap.h:324
bool IsInPhase(uint8 phase) const
Definition: EventMap.h:290
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition: Duration.h:24
bool Empty() const
Definition: EventMap.h:81
uint8 GetPhaseMask() const
Definition: EventMap.h:72
uint32 urand(uint32 min, uint32 max)
Definition: Random.cpp:45
Definition: EventMap.h:25
uint32 _time
Definition: EventMap.h:314
uint32_t uint32
Definition: Define.h:150
void Repeat(Milliseconds const &time)
Definition: EventMap.h:170
void ScheduleEvent(uint32 eventId, Milliseconds const &time, uint32 group=0, uint8 phase=0)
Definition: EventMap.h:123
#define TC_COMMON_API
Definition: Define.h:116
void Update(uint32 time)
Definition: EventMap.h:54
void RescheduleEvent(uint32 eventId, Milliseconds const &time, uint32 group=0, uint8 phase=0)
Definition: EventMap.h:146
void RemovePhase(uint8 phase)
Definition: EventMap.h:109
uint8_t uint8
Definition: g3dmath.h:164
void AddPhase(uint8 phase)
Definition: EventMap.h:98
uint32 GetNextEventTime() const
Definition: EventMap.h:279
void Repeat(Milliseconds const &minTime, Milliseconds const &maxTime)
Definition: EventMap.h:191
uint8_t uint8
Definition: Define.h:152
uint32 _lastEvent
Definition: EventMap.h:339
EventMap()
Definition: EventMap.h:41
uint32_t uint32
Definition: g3dmath.h:168
void DelayEvents(Milliseconds const &delay)
Definition: EventMap.h:219
EventStore _eventMap
Definition: EventMap.h:333