Planeshift
psGameEvent Class Referenceabstract

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

#include <gameevent.h>

Public Member Functions

virtual bool CheckTrigger ()
 Called right before a Trigger is called. More...
 
const char * GetType ()
 Return the type that this event where created with. More...
 
virtual bool IsValid ()
 Return the valid flag. More...
 
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. More...
 
void QueueEvent ()
 Publish the game event to the local program. More...
 
virtual void SetValid (bool valid)
 Set the valid flag. More...
 
virtual csString ToString () const
 Return a string with information about the event. More...
 
virtual void Trigger ()=0
 Abstract event processing function. More...
 
virtual ~psGameEvent ()
 

Public Attributes

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

Static Public Attributes

static EventManagereventmanager
 
static int nextid
 id counter sequence More...
 

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 ( )
inlinevirtual

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.

Definition at line 109 of file gameevent.h.

virtual bool psGameEvent::IsValid ( )
inlinevirtual

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)
inlinevirtual

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
inlinevirtual

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 PerceptOperation::DelayedPerceptOperationGameEvent, psNPCTick, and psServerConsoleCommand.

Definition at line 122 of file gameevent.h.

Member Data Documentation

csTicks psGameEvent::delayticks

delay before the event starts

Definition at line 43 of file gameevent.h.

EventManager* psGameEvent::eventmanager
static

Definition at line 40 of file gameevent.h.

int psGameEvent::id

id value combined with ticks ensures uniqueness for tree

Definition at line 44 of file gameevent.h.

int psGameEvent::nextid
static

id counter sequence

Definition at line 45 of file gameevent.h.

csTicks psGameEvent::triggerticks

ticks value when event should be triggered.

Definition at line 42 of file gameevent.h.

bool psGameEvent::valid

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

Definition at line 46 of file gameevent.h.


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