NSTimer: add method StopTimer() and invalidate any thinks during OnRemoveEntity()
This commit is contained in:
parent
0078d83d80
commit
baadd35ffd
2 changed files with 21 additions and 0 deletions
|
@ -42,4 +42,9 @@ public:
|
|||
|
||||
/** When called, sets up a timer that has to be run manually later. */
|
||||
static NSTimer SetupTimer(entity, void(), float, bool);
|
||||
|
||||
/** Invalidates the timer when called. */
|
||||
nonvirtual void StopTimer(void);
|
||||
|
||||
virtual void OnRemoveEntity(void);
|
||||
};
|
|
@ -125,4 +125,20 @@ NSTimer::SetupTimer(entity receiver, void() call, float interval, bool repeats)
|
|||
ret.m_vFunc = call;
|
||||
ret.m_bRepeats = repeats;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
NSTimer::OnRemoveEntity(void)
|
||||
{
|
||||
nextthink = 0.0f;
|
||||
think = __NULL__;
|
||||
}
|
||||
|
||||
void
|
||||
NSTimer::StopTimer(void)
|
||||
{
|
||||
if (this) {
|
||||
nextthink = 0.0f;
|
||||
think = __NULL__;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue