2022-08-25 18:51:51 -07:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2022 Vera Visions LLC.
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
|
|
|
|
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2022-10-14 13:08:47 -07:00
|
|
|
/** This class provides a way to trigger a function in the future.
|
|
|
|
It has the ability to clean itself up afterwards, too. */
|
2022-08-25 18:51:51 -07:00
|
|
|
class
|
|
|
|
NSTimer:NSEntity
|
|
|
|
{
|
2022-10-14 13:08:47 -07:00
|
|
|
private:
|
2022-08-25 18:51:51 -07:00
|
|
|
entity m_eReceiver;
|
|
|
|
virtual void(void) m_vFunc = 0;
|
|
|
|
float m_flTime;
|
|
|
|
bool m_bRepeats;
|
|
|
|
|
2022-10-14 13:08:47 -07:00
|
|
|
virtual void _TimerThink(void);
|
|
|
|
virtual void _TempTimerThink(void);
|
2022-08-27 11:21:11 -07:00
|
|
|
|
2022-10-14 13:08:47 -07:00
|
|
|
public:
|
|
|
|
void NSTimer(void);
|
2022-08-27 11:21:11 -07:00
|
|
|
|
2022-10-14 13:08:47 -07:00
|
|
|
/** When called, creates and sets up a new timer, starts immediately. */
|
|
|
|
static NSTimer ScheduleTimer(entity, void(), float, bool);
|
|
|
|
|
|
|
|
/** When called, creates a self garbage collecting version of a timer. */
|
|
|
|
static NSTimer TemporaryTimer(entity, void(), float, bool);
|
|
|
|
|
|
|
|
/** Runs the timer that's set up. */
|
|
|
|
virtual void RunTimer(void);
|
|
|
|
|
|
|
|
/** When called, sets up a timer that has to be run manually later. */
|
|
|
|
static NSTimer SetupTimer(entity, void(), float, bool);
|
2022-08-25 18:51:51 -07:00
|
|
|
};
|