Timer
A Timer Entity with Timeout, repetition and processing settings.
Timer is an Entity: attach it to the active tree and call Start or configure Autostart. OneShot selects one timeout or repetition. Subscribe before starting when the first Timeout matters.
ProcessMode controls tree-pause behavior; Paused applies to this timer itself. IgnoreTimeScale does not bypass paused processing conditions. For a one-shot wait without a separate Entity, use EntityTree.CreateTimer, which instead defaults to processAlways = true.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
TimerConstructor
public Timer();Creates a stopped Timer Entity outside the tree. Defaults: WaitTime = 1 second, ProcessCallback = Idle; Autostart, OneShot, Paused and IgnoreTimeScale are false. Add it to the active tree before Start.
Properties7
AutostartProperty
public bool Autostart { get; set; }Automatically starts the timer at Ready, then resets to false. This is not an immediate start command for an already ready object: use Start for that. Autostart is suppressed for the document being edited in the editor.
IgnoreTimeScaleProperty
public bool IgnoreTimeScale { get; set; }Selects unscaled time. Does not automatically allow processing when ProcessMode prohibits it under pause.
OneShotProperty
public bool OneShot { get; set; }If true, automatic expiry stops the countdown before Timeout. If false, expiry adds WaitTime and processing continues. The timer remains an Entity in the tree; this mode does not delete it.
PausedProperty
public bool Paused { get; set; }Pauses this Timer rather than the whole EntityTree. Tree ProcessMode conditions remain separate.
ProcessCallbackProperty
public Timer.TimerProcessCallback ProcessCallback { get; set; }Selects the update phase: Idle for process frames, Physics for physics ticks. Does not select a separate thread or bypass Paused or ProcessMode conditions.
TimeLeftProperty
public double TimeLeft { get; }Remaining countdown in seconds, clamped to a minimum of zero; read-only. A stopped timer reports 0; a paused timer retains its countdown. A zero value alone does not mean the Entity was deleted.
WaitTimeProperty
public double WaitTime { get; set; }Interval in seconds. Supply a finite positive number; a value <= 0 reports a native error and retains the previous interval, rather than guaranteeing a CLR exception. Changing this property neither starts the timer nor resets its remaining time. Very short intervals depend on the chosen update rate; this is not an independent high-precision system timer.
Methods16
GetTimeLeftdouble
public double GetTimeLeft();Returns TimeLeft without changing timer state. See the property contract for details.
doubleRemaining seconds, at least 0.
GetTimerProcessCallbackTimer.TimerProcessCallback
public Timer.TimerProcessCallback GetTimerProcessCallback();Returns ProcessCallback without changing timer state. See the property contract for details.
Timer.TimerProcessCallbackSelected Idle or Physics phase.
GetWaitTimedouble
public double GetWaitTime();Returns WaitTime without changing timer state. See the property contract for details.
doubleConfigured interval in seconds, not the current countdown.
HasAutostartbool
public bool HasAutostart();Returns Autostart without changing timer state. See the property contract for details.
boolCurrent Autostart value; cleared after automatic start.
IsIgnoringTimeScalebool
public bool IsIgnoringTimeScale();Returns IgnoreTimeScale without changing timer state. See the property contract for details.
booltrue when using unscaled time; otherwise false.
IsOneShotbool
public bool IsOneShot();Returns OneShot without changing timer state. See the property contract for details.
booltrue when OneShot is enabled; otherwise false.
IsPausedbool
public bool IsPaused();Returns Paused without changing timer state. See the property contract for details.
booltrue for this timer's local pause; not the whole tree's pause state.
IsStoppedbool
public bool IsStopped();Checks GetTimeLeft() <= 0. Returns true for a new or stopped timer; a pause with positive remaining time is not a stop. An overdue repeating timer can also report zero: the method does not inspect the processing flag or Entity existence.
booltrue when the visible remaining time is zero; otherwise false.
SetAutostartvoid
public void SetAutostart(bool enable);Sets Autostart with the same rules as the property. This is not a separate timer-start operation.
| Name | Type | Default |
|---|---|---|
enable | bool | — |
enableEnable automatic start at Ready.
SetIgnoreTimeScalevoid
public void SetIgnoreTimeScale(bool ignore);Sets IgnoreTimeScale with the same rules as the property. This is not a separate timer-start operation.
| Name | Type | Default |
|---|---|---|
ignore | bool | — |
ignoreUse unscaled time without bypassing pause conditions.
SetOneShotvoid
public void SetOneShot(bool enable);Sets OneShot with the same rules as the property. This is not a separate timer-start operation.
| Name | Type | Default |
|---|---|---|
enable | bool | — |
enableStop after one expiry without deleting the Entity.
SetPausedvoid
public void SetPaused(bool paused);Sets Paused with the same rules as the property. This is not a separate timer-start operation.
| Name | Type | Default |
|---|---|---|
paused | bool | — |
pausedLocal timer pause; remaining time is retained.
SetTimerProcessCallbackvoid
public void SetTimerProcessCallback(Timer.TimerProcessCallback callback);Sets ProcessCallback with the same rules as the property. This is not a separate timer-start operation.
| Name | Type | Default |
|---|---|---|
callback | Timer.TimerProcessCallback | — |
callbackValid Idle or Physics phase.
SetWaitTimevoid
public void SetWaitTime(double timeSec);Sets WaitTime with the same rules as the property. This is not a separate timer-start operation.
| Name | Type | Default |
|---|---|---|
timeSec | double | — |
timeSecFinite positive interval in seconds. Does not restart the countdown.
Startvoid
public void Start(double timeSec = -1d);Starts or resets the countdown in the active tree. A positive timeSec first replaces WaitTime; zero and negative values reuse the previous interval. Does not clear Paused. Calling outside the tree reports a native error; do not rely on a CLR exception.
The complete example validates inputs and subscribes before starting. The returned Timer remains a child of parent after expiry. Call Stop to cancel its countdown; use QueueFree when the Entity is no longer needed.
using System;
using Reckfell;
public static class TimerExample
{
// The returned Timer remains a child of parent after its one timeout.
public static Timer StartOnce(Entity parent, double seconds, Action onTimeout)
{
ArgumentNullException.ThrowIfNull(parent);
ArgumentNullException.ThrowIfNull(onTimeout);
if (!parent.IsInsideTree())
throw new ArgumentException("Parent must be inside the active tree.", nameof(parent));
if (!double.IsFinite(seconds) || seconds <= 0)
throw new ArgumentOutOfRangeException(nameof(seconds));
var timer = new Timer { OneShot = true };
parent.AddChild(timer);
timer.Timeout += onTimeout;
timer.Start(seconds);
return timer;
}
}| Name | Type | Default |
|---|---|---|
timeSec | double | -1d |
timeSecNew finite positive interval, or a value <= 0 to reuse WaitTime. Defaults to -1.
Stopvoid
public void Stop();Stops processing, makes the visible TimeLeft zero and clears Autostart. Does not emit Timeout or delete the Entity. Safe outside the tree. An await for Timeout is not automatically cancelled or completed.
Signals and events1
TimeoutEvent
public event Action Timeout;Argument-free signal for automatic countdown expiry. Subscribe before Start. With OneShot the timer is already stopped; a repeating timer continues processing. Stop does not itself emit this signal.
Timer.TimerProcessCallback
| Value | Description |
|---|---|
Idle = 1 | Update in process frames; the default. |
Physics = 0 | Update in physics ticks. |