Class Clock
- Namespace
- Gamelogic.Extensions
- Assembly
- Assembly-CSharp.dll
Represents a clock that expires after a given time.
[Version(1, 2, 0)]
public class Clock
- Inheritance
-
Clock
- Inherited Members
- Extension Methods
Remarks
To use this clock, instantiate it, call Reset with the right time value, and call Update it each frame.
Any class that wants to be notified of events need to implement the IClockListener interface, and subscribe to events using the AddListener method. A listener can be removed with the RemoveListener event.
Clocks can be paused independently of Time.timeScale using the Pause method (and started again using Unpause).
Constructors
Clock()
Initializes a new instance of the Clock class.
public Clock()
Remarks
The clock is initially paused, and set to expire immediately when unpaused.
Properties
IsDone
Gets a value indicating whether this instance is done.
public bool IsDone { get; }
Property Value
- bool
true
if this instance is done; otherwise,false
.
IsPaused
Gets a value indicating whether this clock is paused.
public bool IsPaused { get; }
Property Value
- bool
true
if this clock is paused; otherwise,false
.
Time
The current time on this clock in seconds as a float.
public float Time { get; }
Property Value
- float
The time.
TimeInSeconds
Gets the time in seconds of this clock as an integer.
public int TimeInSeconds { get; }
Property Value
- int
The time in seconds. The time in seconds is the ceiling of the time left.
Methods
AddTime(float)
Adds time to this clock. This will extend the time the clock expires by the given amount.
public void AddTime(float timeIncrement)
Parameters
timeIncrement
floatThe time increment.
Pause()
Pauses this clock.
public void Pause()
Reset(float)
Resets the clock to the specified stat time.
public void Reset(float startTime)
Parameters
startTime
floatThe start time.
Exceptions
- ArgumentException
startTime
is negative.
Unpause()
Unpauses this clock.
public void Unpause()
Update(float)
Call this method repeatedly to update the time (typically, in a component's Update method).
public void Update(float deltaTime)
Parameters
deltaTime
floatThe delta time.
Events
OnClockExpired
Occurs when the clock expired.
public event Action OnClockExpired
Event Type
OnSecondsChanged
Occurs when the seconds changed. Note that the seconds is the ceiling of the current time.
public event Action OnSecondsChanged