The time event executes the attached script or callback at a certain point in game-time. More...
#include <time_event.h>
Public Member Functions | |
u_int32 | time () const |
Get the event's "alarm" time, i.e. | |
Initialization | |
time_event (const string &time, bool absolute=false) | |
Create a new time event. | |
time_event () | |
Standard constructor. | |
time_event (const u_int32 &time) | |
Create a new time event. | |
void | set_repeat (const string &interval, s_int32 count=-1) |
Set whether the event should be raised at fixed intervals. | |
Event Handling | |
bool | equals (const event *evnt) |
Compare two time events for equality. | |
s_int32 | execute (const event *evnt) |
Executes the script associated with this time event. | |
Loading / Saving | |
void | put_state (ogzstream &out) const |
Saves the basic event data (such as the type or script data) to a file. | |
bool | get_state (igzstream &in) |
Loads the basic event date from a file. | |
Pausing / Resuming execution | |
void | pause () |
Disable the event temporarily. | |
void | resume () |
Re-enable an event that has been paused. |
The time event executes the attached script or callback at a certain point in game-time.
This point can either be relative to the current time, or absolute in time. In any case, this point should be in the future. Time event with an alarm time in the past will be triggered at once.
Definition at line 34 of file time_event.h.
time_event::time_event | ( | const string & | time, | |
bool | absolute = false | |||
) |
Create a new time event.
time | The time when the event should be raised. The string specifies week, day, hour, minute and 1/10 minute in the format "<number>w<number>d<number>h<number>m<number>t". If a number is 0, it can be omitted. | |
absolute | Decides whether the given time is relative from now on, or an absolute time |
Definition at line 33 of file time_event.cc.
time_event::time_event | ( | ) | [inline] |
Standard constructor.
Definition at line 58 of file time_event.h.
time_event::time_event | ( | const u_int32 & | time | ) | [inline] |
Create a new time event.
This constructor is primarily used for raising time events.
time | The "alarm" time in gametime minutes. |
Definition at line 70 of file time_event.h.
void time_event::set_repeat | ( | const string & | interval, | |
s_int32 | count = -1 | |||
) |
Set whether the event should be raised at fixed intervals.
interval | The time between two occurences of the event. | |
count | The number of times the event shall be repeated. Specify -1 to repeat it an unlimited number of times. |
Definition at line 43 of file time_event.cc.
bool time_event::equals | ( | const event * | evnt | ) | [inline, virtual] |
Compare two time events for equality.
evnt | The time event to compare this to. |
Implements event.
Definition at line 99 of file time_event.h.
s_int32 time_event::execute | ( | const event * | evnt | ) | [virtual] |
Executes the script associated with this time event.
If the event repeats it is re-registered with the event handler.
evnt | The event that triggered this time event. |
Implements event.
Definition at line 50 of file time_event.cc.
void time_event::put_state | ( | ogzstream & | out | ) | const [virtual] |
Saves the basic event data (such as the type or script data) to a file.
out | file where to save the event. |
Reimplemented from event.
Definition at line 102 of file time_event.cc.
bool time_event::get_state | ( | igzstream & | in | ) | [virtual] |
Loads the basic event date from a file.
in | file to load the event from. |
Reimplemented from event.
Definition at line 114 of file time_event.cc.
void time_event::pause | ( | ) | [virtual] |
Disable the event temporarily.
As long as it in this state, the event will neither be executed, nor will its repeat-count change.
The alarm time of relative time events will be prolongued be the time the event was paused. Absolute events will only be deferred until they are resumed.
Reimplemented from event.
Definition at line 84 of file time_event.cc.
void time_event::resume | ( | ) | [virtual] |
Re-enable an event that has been paused.
Absolute events that are past their alarm time are executed at once.
Reimplemented from event.
Definition at line 93 of file time_event.cc.
u_int32 time_event::time | ( | ) | const [inline] |
Get the event's "alarm" time, i.e.
the time when it needs to be executed.
Definition at line 169 of file time_event.h.