NSTimer: Add SetupTimer(entity, void(), float, bool) and RunTimer() methods.
This commit is contained in:
parent
267a956ec9
commit
27529eb3a6
2 changed files with 33 additions and 0 deletions
|
@ -26,6 +26,13 @@ NSTimer:NSEntity
|
|||
|
||||
virtual void(void) _TimerThink;
|
||||
virtual void(void) _TempTimerThink;
|
||||
|
||||
/* creates and sets up a new timer, starts immediately */
|
||||
static NSTimer(entity, void(), float, bool) ScheduleTimer;
|
||||
/* self garbage collecting version of the above */
|
||||
static NSTimer(entity, void(), float, bool) TemporaryTimer;
|
||||
|
||||
/* when you want to set up a timer ahead of time, but only run it manually */
|
||||
virtual void(void) RunTimer;
|
||||
static NSTimer(entity, void(), float, bool) SetupTimer;
|
||||
};
|
|
@ -99,4 +99,30 @@ NSTimer::TemporaryTimer(entity receiver, void() call, float interval, bool repea
|
|||
ret.think = NSTimer::_TempTimerThink;
|
||||
ret.nextthink = time + interval;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
NSTimer::RunTimer(void)
|
||||
{
|
||||
think = NSTimer::_TimerThink;
|
||||
nextthink = time + m_flTime;
|
||||
}
|
||||
|
||||
NSTimer
|
||||
NSTimer::SetupTimer(entity receiver, void() call, float interval, bool repeats)
|
||||
{
|
||||
NSTimer ret;
|
||||
|
||||
if (this)
|
||||
ret = this;
|
||||
else {
|
||||
ret = spawn(NSTimer);
|
||||
this = ret;
|
||||
}
|
||||
|
||||
ret.m_eReceiver = receiver;
|
||||
ret.m_flTime = interval;
|
||||
ret.m_vFunc = call;
|
||||
ret.m_bRepeats = repeats;
|
||||
return ret;
|
||||
}
|
Loading…
Reference in a new issue