+ /// Get the iteration index for interval timers.
+ int Iteration() const {
+ return (data && data->target > Time()) ? std::floor(data->time / data->target) : Time();
+ }
+ /// Check if the timer reached its interval or countdown goal this iteration.
+ bool JustHit() const {
+ return data && data->justHit;
+ }
+
+ /// Unset the timer (does not stop other handles for a shared timer).
+ void Clear() {
+ if (data) {
+ --data->refCount;
+ data = 0;
+ }
+ }
+ /// Reset the timer, do not stop it if it's running.
+ void Reset() {
+ if (data) data->time = Time();
+ }
+ /// Restart the timer.
+ /// Only works if the timer was started at least once.
+ void Restart() {
+ if (data) {
+ if (data->target > Time() && data->justHit) {
+ data->time -= data->target;
+ } else {
+ data->time = Time();
+ }
+ }
+ }