clarified and fixed the meaning of timelimit/timeleft when no frames have been processed
3 * =============================================================================
5 * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
6 * =============================================================================
8 * This program is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License, version 3.0, as published by the
10 * Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * You should have received a copy of the GNU General Public License along with
18 * this program. If not, see <http://www.gnu.org/licenses/>.
20 * As a special exception, AlliedModders LLC gives you permission to link the
21 * code of this program (as well as its derivative works) to "Half-Life 2," the
22 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
23 * by the Valve Corporation. You must obey the GNU General Public License in
24 * all respects for all other code used. Additionally, AlliedModders LLC grants
25 * this exception to all derivative works. AlliedModders LLC defines further
26 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
27 * or <http://www.sourcemod.net/license.php>.
32 #ifndef _INCLUDE_SOURCEMOD_TIMER_SYSTEM_H_
33 #define _INCLUDE_SOURCEMOD_TIMER_SYSTEM_H_
36 * @file ITimerSystem.h
37 * @brief Contains functions for creating and managing timers.
41 #include <IShareSys.h>
42 #include <IForwardSys.h>
44 #define SMINTERFACE_TIMERSYS_NAME "ITimerSys"
45 #define SMINTERFACE_TIMERSYS_VERSION 3
52 * @brief Interface for map timers.
58 * Returns the current map time limit in seconds.
60 * @return Time limit, in seconds, or
61 * 0 if there is no limit.
63 virtual int GetMapTimeLimit() =0;
66 * Extends the map limit (either positively or negatively) in seconds.
68 * @param extra_time Time to extend map by. If 0, the map will
69 * be set to have no time limit.
71 virtual void ExtendMapTimeLimit(int extra_time) =0;
74 * Tells the map timer whether it is being used or not.
76 * Map timers are automatically enabled when they are set, and
77 * automatically disabled if being un-set.
79 * @param enabled True if enabling, false if disabling.
81 virtual void SetMapTimerStatus(bool enabled) =0;
85 * @brief Event callbacks for when a timer is executed.
91 * @brief Called when a timer is executed.
93 * @param pTimer Pointer to the timer instance.
94 * @param pData Private pointer passed from host.
95 * @return Pl_Stop to stop timer, Pl_Continue to continue.
97 virtual ResultType OnTimer(ITimer *pTimer, void *pData) =0;
100 * @brief Called when the timer has been killed.
102 * @param pTimer Pointer to the timer instance.
103 * @param pData Private data pointer passed from host.
105 virtual void OnTimerEnd(ITimer *pTimer, void *pData) =0;
108 #define TIMER_FLAG_REPEAT (1<<0) /**< Timer will repeat until stopped */
109 #define TIMER_FLAG_NO_MAPCHANGE (1<<1) /**< Timer will not carry over mapchanges */
111 class ITimerSystem : public SMInterface
114 const char *GetInterfaceName()
116 return SMINTERFACE_TIMERSYS_NAME;
118 unsigned int GetInterfaceVersion()
120 return SMINTERFACE_TIMERSYS_VERSION;
124 * @brief Creates a timed event.
126 * @param pCallbacks Pointer to ITimedEvent callbacks.
127 * @param fInterval Interval, in seconds, of the timed event to occur.
128 * The smallest allowed interval is 0.1 seconds.
129 * @param pData Private data to pass on to the timer.
130 * @param flags Extra flags to pass on to the timer.
131 * @return An ITimer pointer on success, NULL on
134 virtual ITimer *CreateTimer(ITimedEvent *pCallbacks,
140 * @brief Kills a timer.
142 * @param pTimer Pointer to the ITimer structure.
145 virtual void KillTimer(ITimer *pTimer) =0;
148 * @brief Arbitrarily fires a timer. If the timer is not a repeating
149 * timer, this will also kill the timer.
151 * @param pTimer Pointer to the ITimer structure.
152 * @param delayExec If true, and the timer is repeating, the
153 * next execution will be delayed by its
157 virtual void FireTimerOnce(ITimer *pTimer, bool delayExec=false) =0;
160 * @brief Sets the interface for dealing with map time limits.
162 * @param pMapTimer Map timer interface pointer.
163 * @return Old pointer.
165 virtual IMapTimer *SetMapTimer(IMapTimer *pTimer) =0;
168 * @brief Notification that the map's time left has changed
169 * via a change in the time limit or a change in the game rules (
170 * such as mp_restartgame).
172 virtual void MapTimeLeftChanged() =0;
175 * @brief Returns the current universal tick time. This
176 * replacement for gpGlobals->curtime and engine->Time() correctly
177 * keeps track of ticks.
179 * During simulation, it is incremented by the difference between
180 * gpGlobals->curtime and the last simulated tick. Otherwise,
181 * it is incremented by the interval per tick.
183 * It is not reset past map changes.
185 * @return Universal ticked time.
187 virtual float GetTickedTime() =0;
190 * @brief Notification that the "starting point" in the game has has
191 * changed. This does not invoke MapTimeLeftChanged() automatically.
193 * @param offset Optional offset to add to the new time.
195 virtual void NotifyOfGameStart(float offset = 0.0f) =0;
198 * @brief Returns the time left in the map.
200 * @param pTime Pointer to store time left, in seconds.
201 * If there is no time limit, the number will
203 * @return True on success, false if no support.
205 virtual bool GetMapTimeLeft(float *pTime) =0;
209 #endif //_INCLUDE_SOURCEMOD_TIMER_SYSTEM_H_