Adonthell
0.4
|
The time event executes the attached script or callback at a certain point in game-time. More...
#include <time_event.h>
Public Member Functions | |
Initialization | |
time_event (const string &time, bool absolute=false) | |
Create a new time event. More... | |
time_event () | |
Standard constructor. More... | |
time_event (const u_int32 &time) | |
Create a new time event. More... | |
void | set_repeat (const string &interval, s_int32 count=-1) |
Set whether the event should be raised at fixed intervals. More... | |
Event Handling | |
bool | equals (const event *evnt) |
Compare two time events for equality. More... | |
s_int32 | execute (const event *evnt) |
Executes the script associated with this time event. More... | |
Loading / Saving | |
void | put_state (ogzstream &out) const |
Saves the basic event data (such as the type or script data) to a file. More... | |
bool | get_state (igzstream &in) |
Loads the basic event date from a file. More... | |
![]() | |
event () | |
Constructor. More... | |
virtual | ~event () |
Destructor. More... | |
void | clear () |
Cleanup. More... | |
u_int8 | type () const |
Get the event's type. More... | |
const string & | id () const |
Get the event's id. More... | |
void | set_id (const string &id) |
Assign an id to the event, so it may be retrieved from an event_list later on, without having a pointer to it. More... | |
bool | registered () const |
Test whether the event is registered with the event handler. More... | |
void | set_registered (bool reg) |
Set whether the event is registered with the event handler. More... | |
void | set_list (event_list *list) |
Tell the whether it is kept in an event_list. More... | |
s_int32 | repeat () const |
Return whether this event should be repeated. More... | |
void | set_repeat (s_int32 count) |
Set whether this event should be repeated. More... | |
void | set_script (string filename, PyObject *args=NULL) |
Sets a script to be executed whenever the event occurs. More... | |
void | set_callback (PyObject *callback, PyObject *args=NULL) |
Sets a python function/method to be executed whenever the event occurs. More... | |
void | set_callback (const Functor0 &callback) |
Sets a C function/C++ method to be executed whenever the event occurs. More... | |
bool | is_paused () const |
Check whether the event is temporarily disabled or not. More... | |
Pausing / Resuming execution | |
void | pause () |
Disable the event temporarily. More... | |
void | resume () |
Re-enable an event that has been paused. More... | |
u_int32 | time () const |
Get the event's "alarm" time, i.e. More... | |
Additional Inherited Members | |
![]() | |
s_int32 | do_repeat () |
Decrease the event's repeat count and return the number of repeats left. More... | |
![]() | |
u_int8 | Type |
Event type - see enum above. More... | |
string | Id |
(Optional) Id of the event More... | |
u_int8 | Action |
What happens if the event occurs - see enum above. More... | |
bool | Registered |
Whether the event is registered with the event handler. More... | |
bool | Paused |
Whether the event temporarily disabled or not. More... | |
s_int32 | Repeat |
Defines how often the event should be repeated. More... | |
py_object * | Script |
The Python script accociated with this event. More... | |
PyObject * | Args |
The arguments passed to the script. More... | |
py_callback * | PyFunc |
Python callback that may be executed instead of the script. More... | |
Functor0 | Callback |
C++ callback that may be executed when the event gets triggered. More... | |
event_list * | List |
The event_list this event is kept in. More... | |
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 38 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 30 of file time_event.cc.
|
inline |
Standard constructor.
Definition at line 62 of file time_event.h.
|
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 74 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 40 of file time_event.cc.
|
inlinevirtual |
Compare two time events for equality.
evnt | The time event to compare this to. |
Implements event.
Definition at line 103 of file time_event.h.
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 47 of file time_event.cc.
|
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 99 of file time_event.cc.
|
virtual |
Loads the basic event date from a file.
in | file to load the event from. |
Reimplemented from event.
Definition at line 111 of file time_event.cc.
|
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 81 of file time_event.cc.
|
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 90 of file time_event.cc.
|
inline |
Get the event's "alarm" time, i.e.
the time when it needs to be executed.
Definition at line 173 of file time_event.h.