110 Timer(
float interval,
bool bLoop,
const ExecutorPtr& executor,
bool bKillAfterCall =
false);
111 Timer(
float interval,
bool bLoop, std::function<
void (
void)> func,
bool bKillAfterCall =
false);
113 void setTimer(
float interval,
bool bLoop,
const ExecutorPtr& executor,
bool bKillAfterCall =
false);
114 void setTimer(
float interval,
bool bLoop, std::function<
void (
void)> func,
bool bKillAfterCall =
false);
121 { this->bActive_ =
true; this->time_ = this->interval_; }
124 { this->bActive_ =
false; this->time_ = this->interval_; }
127 { this->bActive_ =
false; }
130 { this->bActive_ =
true; }
133 {
return this->bActive_; }
136 {
return static_cast<float>(this->time_ / 1000000.0f); }
139 {
if (time > 0.0f) this->time_ +=
static_cast<long long>(time * 1000000.0f); }
142 {
if (time > 0.0f) this->time_ -=
static_cast<long long>(time * 1000000.0f); }
145 { this->interval_ =
static_cast<long long>(interval * 1000000.0f); }
148 { this->bLoop_ = bLoop; }
150 void tick(
const Clock& time);
153 virtual float getTimeFactor();
180 RealTimer(
float interval,
bool bLoop,
const ExecutorPtr& executor,
bool bKillAfterCall =
false);
183 virtual float getTimeFactor()
override;
long long interval_
The time-interval in micro seconds.
Definition: Timer.h:162
void setLoop(bool bLoop)
Defines if the timer call the executor every interval seconds or only once.
Definition: Timer.h:147
Listable stores the entries of all object lists pointing to this instance.
Definition: Listable.h:50
::std::string string
Definition: gtest-port.h:756
void removeTime(float time)
Decreases the remaining time of the timer by the given amount of time (in seconds) ...
Definition: Timer.h:141
void startTimer()
Re-starts the timer: The executor will be called after interval seconds.
Definition: Timer.h:120
bool bKillAfterCall_
If true the timer gets deleted after it expired and called the executor.
Definition: Timer.h:165
void killdelay(unsigned int handle)
Console-command: Kills a delayed command with given handle.
Definition: Timer.cc:125
void pauseTimer()
Pauses the timer - it will continue with the actual state if you call unpauseTimer().
Definition: Timer.h:126
void killdelays()
Console-command: Kills all scheduled commands that were delayed using delay().
Definition: Timer.cc:114
bool bActive_
If true, the timer ticks and calls the executor if the time's up.
Definition: Timer.h:164
void addTime(float time)
Increases the remaining time of the timer by the given amount of time (in seconds).
Definition: Timer.h:138
long long time_
Internal variable, counting the time untill the next executor-call.
Definition: Timer.h:167
bool isActive() const
Returns true if the timer is active (neither stopped nor paused).
Definition: Timer.h:132
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION_MULTI() command(const std::string &fragment)
Returns a list of commands and groups and also supports auto-completion of the arguments of these com...
Definition: ArgumentCompletionFunctions.cc:178
unsigned int delayreal(float delay, const std::string &command)
Console-command: Calls another console command after delay seconds (real time)
Definition: Timer.cc:76
std::function< void(void)> function_
Definition: Timer.h:159
Typedefs and definitions of ExecutorPtr, ExecutorStaticPtr, and ExecutorMemberPtr.
void stopTimer()
Stops the timer.
Definition: Timer.h:123
unsigned int delay(float delay, const std::string &command)
Console-command: Calls another console command after delay seconds (game time).
Definition: Timer.cc:65
void executeDelayedCommand(Timer *timer, const std::string &command)
Helper function for delay(), executes the command and destroys the timer.
Definition: Timer.cc:104
Declaration of Listable, the base of all classes whose instances can be stored in object lists...
void setInterval(float interval)
Changes the calling interval.
Definition: Timer.h:144
bool bLoop_
If true, the executor gets called every interval seconds.
Definition: Timer.h:163
bool isStdFunction_
Definition: Timer.h:161
Simple real time clock based on Ogre::Timer.
Definition: Clock.h:57
float getRemainingTime() const
Returns the remaining time until the timer calls the executor.
Definition: Timer.h:135
Timer is a helper class that executes a function after a given amount of seconds in game-time...
Definition: Timer.h:105
unsigned int addDelayedCommand(Timer *timer, float delay, const std::string &command)
Helper function, used by delay() and delayreal() to add a delayed command.
Definition: Timer.cc:88
std::shared_ptr< Executor > ExecutorPtr
Definition: ExecutorPtr.h:55
RealTimer is a helper class that executes a function after a given amount of seconds in real-time...
Definition: Timer.h:176
void unpauseTimer()
Unpauses the timer - continues with the given state.
Definition: Timer.h:129
ExecutorPtr executor_
The executor of the function that will be called when the time expires.
Definition: Timer.h:158