C4 Engine Terathon Software C4 Engine API Documentation

• Time Manager

API Links
Developer Links

class Timer

Defined in:  C4Time.h
A deferred task which signals the expiration of a specific amount of time.
Definition

class Timer : public DeferredTask

Member Functions
Timer::GetTime Returns the length of time until the timer is triggered.
Timer::SetTime Sets the length of time which should pass before the timer is triggered.
Constructor

Timer(long time, CompletionProc *proc, void *data = nullptr);

Parameters
time The length of time, in milliseconds, which should pass before the timer is triggered.
proc The procedure to invoke when the task is triggered.
data The data which is passed to the trigger procedure as its second parameter.
Description
The Timer class encapsulates a deferred task which is triggered after the time specified by the time parameter. Once a timer is registered using the TimeMgr::AddTask function, its remaining time is reduced each frame until it reaches zero, at which point its callback procedure is invoked. The callback procedure specified by the proc parameter should have the following prototype.

typedef void CompletionProc(DeferredTask *, void *);

Base Classes
DeferredTask Timer objects provide a trigger for DeferredTask objects.