Built-in timer struct for game logic that counts frames, it is not affected by FrameBase.GameTimeScale (see GameTimer). Seconds are converted with the simulation rate (FrameBase.UpdateRate).
More...
|
| static readonly FrameTimer | None = default |
| | Empty timer. More...
|
| |
| const int | SIZE = sizeof(int) * 2 |
| | The size of the component (or struct/type) in-memory inside the Frame data-buffers or stack (when passed as value parameter). Not related to the snapshot payload this occupies, which is bit-packed and compressed. More...
|
| |
Built-in timer struct for game logic that counts frames, it is not affected by FrameBase.GameTimeScale (see GameTimer). Seconds are converted with the simulation rate (FrameBase.UpdateRate).
◆ DurationNormalized()
| readonly FP Quantum.FrameTimer.DurationNormalized |
( |
FrameBase |
frame | ) |
|
|
inline |
The progress of the timer between 0 (just started) and 1 (expired), e.g. to display a cooldown.
- Parameters
-
| frame | The current Frame instance. |
- Returns
- The elapsed frames divided by the Duration, clamped to [0, 1]. 1 for a set timer with a duration of 0, 0 if the timer is not set.
◆ IsRunning()
| readonly bool Quantum.FrameTimer.IsRunning |
( |
FrameBase |
frame | ) |
|
Is the timer set and still running.
- Parameters
-
| frame | The current Frame instance. |
- Returns
true if the timer is valid and the current frame > number is smaller than TargetFrame. false otherwise.
◆ HasStoppedThisFrame()
| readonly bool Quantum.FrameTimer.HasStoppedThisFrame |
( |
FrameBase |
frame | ) |
|
Has the timer expired during this frame.
- Parameters
-
| frame | The current Frame instance. |
- Returns
true if the timer is not expired and the current frame number is equal to TargetFrame. false otherwise.
Useful for one time operations that happen only at timer expiry.
◆ RemainingFrames()
| readonly int Quantum.FrameTimer.RemainingFrames |
( |
FrameBase |
frame | ) |
|
|
inline |
How many frames are remaining until the timer expires.
- Parameters
-
| frame | The current Frame instance. |
- Returns
- TargetFrame - current Frame number. Never returns a negative value.
◆ RemainingSeconds()
| readonly FP Quantum.FrameTimer.RemainingSeconds |
( |
FrameBase |
frame | ) |
|
|
inline |
How much time is remaining until the timer expires in seconds.
- Parameters
-
| frame | The current Frame instance. |
- Returns
- Divides the remaining frame count by the simulation rate (FrameBase.UpdateRate). Never returns a negative value.
◆ ElapsedFrames()
| readonly int Quantum.FrameTimer.ElapsedFrames |
( |
FrameBase |
frame | ) |
|
|
inline |
How many frames or ticks since the timer was started.
- Parameters
-
| frame | The current Frame instance. |
- Returns
- Returns current frame number - the start frame number. Never returns a negative value.
◆ ElapsedSeconds()
| readonly FP Quantum.FrameTimer.ElapsedSeconds |
( |
FrameBase |
frame | ) |
|
|
inline |
How long since the timer has started in seconds.
- Parameters
-
| frame | The current Frame instance. |
- Returns
- Divides the elapsed frame count by the simulation rate (FrameBase.UpdateRate). Never returns a negative value.
◆ Restart()
| void Quantum.FrameTimer.Restart |
( |
FrameBase |
frame | ) |
|
|
inline |
Restarts the timer with the same Duration.
- Parameters
-
| frame | The current Frame instance. |
◆ FromSeconds()
Create a new timer from a delay in seconds.
The seconds are converted with the simulation rate (FrameBase.UpdateRate) instead of dividing by FrameBase.UnscaledDeltaTime, so whole seconds are exact whole frames at any rate (e.g. 1 second at 60 Hz is exactly 60 frames, 1/60 cannot be stored exactly by FP).
- Parameters
-
| frame | The current Frame instance. |
| durationInSeconds | The time in seconds to wait before the timer expires, rounded up to whole frames. |
- Returns
- A new FrameTimer instance with the specified duration.
◆ FromFrames()
Create a new timer from a delay in frames.
- Parameters
-
| frame | The current Frame instance. |
| durationInFrames | The number of frames to wait before the timer expires. |
- Returns
- A new FrameTimer instance with the specified duration.
◆ Serialize()
Serializes a FrameTimer into a FrameSerializer to write or read from a frame snapshot.
- Parameters
-
| ptr | The pointer to the FrameTimer. |
| serializer | The FrameSerializer instance into which the struct will be serialized. |
◆ GetHashCode()
| readonly override int Quantum.FrameTimer.GetHashCode |
( |
| ) |
|
|
inline |
Overrides the hash code generation of this type.
- Returns
- A hash code of the current state of this instance.
◆ SIZE
| const int Quantum.FrameTimer.SIZE = sizeof(int) * 2 |
|
static |
The size of the component (or struct/type) in-memory inside the Frame data-buffers or stack (when passed as value parameter). Not related to the snapshot payload this occupies, which is bit-packed and compressed.
◆ None
| readonly FrameTimer Quantum.FrameTimer.None = default |
|
static |
◆ TargetFrame
| int Quantum.FrameTimer.TargetFrame |
The frame number at which the timer will run out.
◆ StartFrame
| int Quantum.FrameTimer.StartFrame |
The frame number at which the timer has started.
◆ IsSet
◆ Duration