Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
EventMap Class Reference

#include <CreatureAIImpl.h>

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 to be added to time.
void Update (uint32 time)
GetTimer
Returns
Current timer value.
uint32 GetTimer () const
GetPhaseMask
Returns
Active phases as mask.
uint8 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 (uint8 phase)
AddPhase

Activates the given phase (bitwise).

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

Deactivates the given phase (bitwise).

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

Creates new event entry in map.

Parameters
eventIdThe id of the new event.
timeThe time in milliseconds until the event occurs.
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 (uint32 eventId, uint32 time, uint32 group=0, uint8 phase=0)
RescheduleEvent

Cancels the given event and reschedules it.

Parameters
eventIdThe id of the event.
timeThe time in milliseconds until the event occurs.
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 (uint32 eventId, uint32 time, uint32 group=0, uint8 phase=0)
RepeatEvent

Cancels the closest event and reschedules it.

Parameters
timeTime until the event occurs.
void RepeatEvent (uint32 time)
PopEvent

Remove the first event in the map.

void PopEvent ()
ExecuteEvent

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

Returns
Id of the event to execute.
uint32 ExecuteEvent ()
GetEvent

Returns the next event to execute.

Returns
Id of the event to execute.
uint32 GetEvent ()
DelayEvents

Delay all events of the same group.

Parameters
delayAmount of delay.
groupGroup of the events.
void DelayEvents (uint32 delay)
void DelayEvents (uint32 delay, uint32 group)
CancelEvent

Cancels all events of the specified id.

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

Cancel events belonging to specified group.

Parameters
groupGroup to cancel.
void CancelEventGroup (uint32 group)
GetNextEventTime
Returns
Time of next event.
uint32 GetNextEventTime (uint32 eventId) const
uint32 GetNextEventTime () const
IsInPhase

Returns wether event map is in specified phase or not.

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

Private Types

typedef std::multimap< uint32, uint32EventStore

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.

uint32 _time
_phase

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.

uint8 _phase
_eventMap

Internal event storage map. Contains the scheduled events.

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

EventStore _eventMap

Detailed Description

Definition at line 303 of file CreatureAIImpl.h.

Member Typedef Documentation

◆ EventStore

typedef std::multimap<uint32, uint32> EventMap::EventStore
private

Internal storage type. Key: Time as uint32 when the event should occur. Value: The event data as uint32.

Structure of event data:

  • Bit 0 - 15: Event Id.
  • Bit 16 - 23: Group
  • Bit 24 - 31: Phase
  • Pattern: 0xPPGGEEEE

Definition at line 316 of file CreatureAIImpl.h.

Constructor & Destructor Documentation

◆ EventMap()

EventMap::EventMap ( )
inline

Definition at line 319 of file CreatureAIImpl.h.

References _phase, and _time.

Member Function Documentation

◆ AddPhase()

void EventMap::AddPhase ( uint8 phase)
inline

Definition at line 387 of file CreatureAIImpl.h.

References _phase.

◆ CancelEvent()

void EventMap::CancelEvent ( uint32 eventId)
inline

Definition at line 552 of file CreatureAIImpl.h.

References _eventMap, and Empty().

Referenced by RescheduleEvent().

◆ CancelEventGroup()

void EventMap::CancelEventGroup ( uint32 group)
inline

Definition at line 571 of file CreatureAIImpl.h.

References _eventMap, and Empty().

◆ DelayEvents() [1/2]

void EventMap::DelayEvents ( uint32 delay)
inline

Definition at line 515 of file CreatureAIImpl.h.

References _time.

◆ DelayEvents() [2/2]

void EventMap::DelayEvents ( uint32 delay,
uint32 group )
inline

Definition at line 526 of file CreatureAIImpl.h.

References _eventMap, and Empty().

◆ Empty()

bool EventMap::Empty ( ) const
inline

◆ ExecuteEvent()

uint32 EventMap::ExecuteEvent ( )
inline

Definition at line 467 of file CreatureAIImpl.h.

References _eventMap, _phase, _time, and Empty().

◆ GetEvent()

uint32 EventMap::GetEvent ( )
inline

Definition at line 493 of file CreatureAIImpl.h.

References _eventMap, _phase, _time, and Empty().

◆ GetNextEventTime() [1/2]

uint32 EventMap::GetNextEventTime ( ) const
inline

Definition at line 607 of file CreatureAIImpl.h.

References _eventMap, and Empty().

◆ GetNextEventTime() [2/2]

uint32 EventMap::GetNextEventTime ( uint32 eventId) const
inline

Definition at line 591 of file CreatureAIImpl.h.

References _eventMap, and Empty().

◆ GetPhaseMask()

uint8 EventMap::GetPhaseMask ( ) const
inline

Definition at line 355 of file CreatureAIImpl.h.

References _phase.

◆ GetTimer()

uint32 EventMap::GetTimer ( ) const
inline

Definition at line 346 of file CreatureAIImpl.h.

References _time.

◆ IsInPhase()

bool EventMap::IsInPhase ( uint8 phase) const
inline

Definition at line 618 of file CreatureAIImpl.h.

References _phase.

◆ PopEvent()

void EventMap::PopEvent ( )
inline

Definition at line 456 of file CreatureAIImpl.h.

References _eventMap, and Empty().

◆ RemovePhase()

void EventMap::RemovePhase ( uint8 phase)
inline

Definition at line 398 of file CreatureAIImpl.h.

References _phase.

◆ RepeatEvent()

void EventMap::RepeatEvent ( uint32 time)
inline

Definition at line 442 of file CreatureAIImpl.h.

References _eventMap, Empty(), and ScheduleEvent().

◆ RescheduleEvent()

void EventMap::RescheduleEvent ( uint32 eventId,
uint32 time,
uint32 group = 0,
uint8 phase = 0 )
inline

Definition at line 431 of file CreatureAIImpl.h.

References CancelEvent(), and ScheduleEvent().

◆ Reset()

void EventMap::Reset ( )
inline

Definition at line 325 of file CreatureAIImpl.h.

References _eventMap, _phase, and _time.

◆ ScheduleEvent()

void EventMap::ScheduleEvent ( uint32 eventId,
uint32 time,
uint32 group = 0,
uint8 phase = 0 )
inline

Definition at line 412 of file CreatureAIImpl.h.

References _eventMap, and _time.

Referenced by RepeatEvent(), and RescheduleEvent().

◆ SetPhase()

void EventMap::SetPhase ( uint8 phase)
inline

Definition at line 374 of file CreatureAIImpl.h.

References _phase.

◆ Update()

void EventMap::Update ( uint32 time)
inline

Definition at line 337 of file CreatureAIImpl.h.

References _time.

Member Data Documentation

◆ _eventMap

◆ _phase

uint8 EventMap::_phase
private

◆ _time

uint32 EventMap::_time
private

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