Oolite
Loading...
Searching...
No Matches
OOScriptTimer.h
Go to the documentation of this file.
1/*
2
3OOScriptTimer.h
4
5Abstract base class for script timers. An OOScriptTimer does nothing when it
6fires; subclasses should override the -timerFired method.
7
8Timers are immutable. They are retained by the timer subsystem while scheduled.
9A timer with a negative interval will only fire once. A negative nexttime when
10inited will cause the timer to fire after the specified interval. A persistent
11timer will remain if the player dies and respawns; non-persistent timers will
12be removed.
13
14
15Oolite
16Copyright (C) 2004-2013 Giles C Williams and contributors
17
18This program is free software; you can redistribute it and/or
19modify it under the terms of the GNU General Public License
20as published by the Free Software Foundation; either version 2
21of the License, or (at your option) any later version.
22
23This program is distributed in the hope that it will be useful,
24but WITHOUT ANY WARRANTY; without even the implied warranty of
25MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26GNU General Public License for more details.
27
28You should have received a copy of the GNU General Public License
29along with this program; if not, write to the Free Software
30Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
31MA 02110-1301, USA.
32
33*/
34
35#import "OOFoundation.h"
36#import "OOTypes.h"
37
38@interface OOScriptTimer : NSObject {
39@private
43 BOOL _hasBeenRun; // Needed for one-shot timers.
44}
45
46- (id)initWithNextTime:(OOTimeAbsolute)nextTime
47 interval:(OOTimeDelta)interval;
48
49// Sets nextTime to current time + delay.
50- (id)initOneShotTimerWithDelay:(OOTimeDelta)delay;
51
52- (OOTimeAbsolute)nextTime;
53- (BOOL)setNextTime:(OOTimeAbsolute)nextTime; // Only works when timer is not scheduled.
54- (OOTimeDelta)interval;
55- (void)setInterval:(OOTimeDelta)interval;
56
57// Subclass responsibility:
58- (void)timerFired;
59
60- (BOOL)scheduleTimer;
61- (void)unscheduleTimer;
62- (BOOL)isScheduled;
63
64+ (void)updateTimers;
65+ (void)noteGameReset;
66
67- (BOOL)isValidForScheduling;
68
69- (NSComparisonResult)compareByNextFireTime:(OOScriptTimer*)other;
70
71@end
double OOTimeDelta
Definition OOTypes.h:193
double OOTimeAbsolute
Definition OOTypes.h:192
OOTimeAbsolute _nextTime
OOTimeDelta _interval