Planeshift
Public Member Functions | Public Attributes | Static Public Attributes

psGameEvent Class Reference

All scheduled events must inherit from this class. More...

#include <gameevent.h>

List of all members.

Public Member Functions

virtual bool CheckTrigger ()
 Called right before a Trigger is called.
const char * GetType ()
 Return the type that this event where created with.
virtual bool IsValid ()
 Return the valid flag.
bool operator< (const psGameEvent &other) const
bool operator== (const psGameEvent &other) const
bool operator> (const psGameEvent &other) const
 psGameEvent (csTicks ticks, int offsetticks, const char *newType)
 Construct a new game event.
void QueueEvent ()
 Publish the game event to the local program.
virtual void SetValid (bool valid)
 Set the valid flag.
virtual csString ToString () const
 Return a string with information about the event.
virtual void Trigger ()=0
 Abstract event processing function.
virtual ~psGameEvent ()

Public Attributes

csTicks delayticks
 delay before the event starts
int id
 id value combined with ticks ensures uniqueness for tree
csTicks triggerticks
 ticks value when event should be triggered.
bool valid
 Set this to false if the trigger should not be fired.

Static Public Attributes

static EventManagereventmanager
static int nextid
 id counter sequence

Detailed Description

All scheduled events must inherit from this class.

These events are queued by the EventManager and are passed to the various subscribed handlers at the appropriate time.

Definition at line 36 of file gameevent.h.


Constructor & Destructor Documentation

psGameEvent::psGameEvent ( csTicks  ticks,
int  offsetticks,
const char *  newType 
)

Construct a new game event.

Set ticks to 0 if the event should be fired at offset ticks from current time.

virtual psGameEvent::~psGameEvent ( ) [virtual]

Member Function Documentation

virtual bool psGameEvent::CheckTrigger ( ) [inline, virtual]

Called right before a Trigger is called.

Default implementation use the valid flag to determin if the Trigger should be calle.Could be overridden to allow for other conditions.

This function allows psGEMEvents to disconnect themselves

Reimplemented in psEndSongEvent.

Definition at line 69 of file gameevent.h.

const char* psGameEvent::GetType ( ) [inline]

Return the type that this event where created with.

Used for debugging.

Reimplemented in psWeatherGameEvent.

Definition at line 109 of file gameevent.h.

virtual bool psGameEvent::IsValid ( ) [inline, virtual]

Return the valid flag.

Returns:
The valid flag.

Reimplemented in psActionTimeoutGameEvent.

Definition at line 100 of file gameevent.h.

bool psGameEvent::operator< ( const psGameEvent other) const [inline]

Definition at line 133 of file gameevent.h.

bool psGameEvent::operator== ( const psGameEvent other) const [inline]

Definition at line 127 of file gameevent.h.

bool psGameEvent::operator> ( const psGameEvent other) const [inline]

Definition at line 143 of file gameevent.h.

void psGameEvent::QueueEvent ( )

Publish the game event to the local program.

virtual void psGameEvent::SetValid ( bool  valid) [inline, virtual]

Set the valid flag.

Setting of valid to false will if the CheckTrigger isn't overridden cause the Trigger not to be called.

Parameters:
validThe new value of the valid flag.

Definition at line 90 of file gameevent.h.

virtual csString psGameEvent::ToString ( ) const [inline, virtual]

Return a string with information about the event.

Used for debugging to be able to identify things like way did this event take so long to execute.

TODO: Make this function abstract. But for now return "".

Reimplemented in psServerConsoleCommand, psNPCTick, and PerceptOperation::DelayedPerceptOperationGameEvent.

Definition at line 122 of file gameevent.h.

virtual void psGameEvent::Trigger ( ) [pure virtual]

Member Data Documentation

delay before the event starts

Definition at line 43 of file gameevent.h.

Definition at line 40 of file gameevent.h.

id value combined with ticks ensures uniqueness for tree

Definition at line 44 of file gameevent.h.

id counter sequence

Definition at line 45 of file gameevent.h.

ticks value when event should be triggered.

Definition at line 42 of file gameevent.h.

Set this to false if the trigger should not be fired.

Reimplemented in psActionTimeoutGameEvent, and CacheManager::psCacheExpireEvent.

Definition at line 46 of file gameevent.h.


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