Oolite 1.91.0.7646-241128-10e222e
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 "OOCocoa.h"
36#import "OOTypes.h"
37
38
39@interface OOScriptTimer: NSObject
40{
41@private
45 BOOL _hasBeenRun; // Needed for one-shot timers.
46}
47
48- (id) initWithNextTime:(OOTimeAbsolute)nextTime
49 interval:(OOTimeDelta)interval;
50
51// Sets nextTime to current time + delay.
52- (id) initOneShotTimerWithDelay:(OOTimeDelta)delay;
53
54- (OOTimeAbsolute)nextTime;
55- (BOOL)setNextTime:(OOTimeAbsolute)nextTime; // Only works when timer is not scheduled.
56- (OOTimeDelta)interval;
57- (void)setInterval:(OOTimeDelta)interval;
58
59// Subclass responsibility:
60- (void) timerFired;
61
62- (BOOL) scheduleTimer;
63- (void) unscheduleTimer;
64- (BOOL) isScheduled;
65
66
67+ (void) updateTimers;
68+ (void) noteGameReset;
69
70
71- (BOOL) isValidForScheduling;
72
73- (NSComparisonResult) compareByNextFireTime:(OOScriptTimer *)other;
74
75@end
double OOTimeDelta
Definition OOTypes.h:224
double OOTimeAbsolute
Definition OOTypes.h:223
OOTimeAbsolute _nextTime
OOTimeDelta _interval