Skip to main content

TimerLogic

A class in Root.Township, the global namespace.

Saved component that runs a timer for a set duration and fires an event when it ends. Base for ImpactDetectionLogic.

Constructors​

MemberWhat it is
TimerLogic()Creates a TimerLogic with default values.

Fields​

MemberWhat it is
protected float activeProgressTimer progress from 0 to 1.
protected bool timerAlreadyActiveTrue while the timer runs.
protected bool timerResetsWhenRetriggeredWhether starting the timer again resets its progress.
3 private and internal fields
MemberWhat it is
private float activeDurationSeconds the timer runs for once started. Saved.
private bool activeOnLoadWhen true, the timer starts as soon as it is loaded from save (in play mode).
private UnityEvent timerOverUnity event invoked when the timer reaches the end.

Events​

MemberWhat it is
protected event TimerLogic.TimeEvent timerToggleRaised with true when the timer starts and false when it ends.

Methods​

MemberWhat it is
void StartTimer()Starts the timer. If it is already running, it restarts the progress when timerResetsWhenRetriggered is set.
protected IEnumerator WaitActiveTimer() (iterator)The timer coroutine. Raises timerToggle at start and end, then fires the timer over event.