Gondwana Game Engine
Gondwana is a cross-platform 2.5D game and rendering engine written in C#/.NET 8. It provides fine-grained control over rendering, timing, and scene composition, with built-in support for parallax, z-ordering, pixel overhang, collision detection, and particle effects. Gondwana targets desktop, mobile, and web platforms using SkiaSharp for graphics and NAudio for sound.
Loading...
Searching...
No Matches
Gondwana.Timers.Timer Class Referencesealed

Represents a high-resolution timer that can trigger events at specified intervals and supports various timer types and cycles. This class is designed to be used within the Gondwana engine. More...

Inheritance diagram for Gondwana.Timers.Timer:

Public Member Functions

void Dispose ()
 Releases all resources used by the Timer and removes it from the collection of active timers.

Static Public Member Functions

static Timer Add (string timerID, TimerType type, TimerCycles cycles, double length)
 Creates a new timer with the specified parameters and adds it to the collection of active timers.
static Timer Add (TimerType type, TimerCycles cycles, double length)
 Creates and adds a new timer with the specified type, cycle count, and duration.
static void Remove (string timerID)
 Removes the timer associated with the specified timer ID and releases its resources.
static Timer Get (string timerID)
 Retrieves the Timer instance associated with the specified timer ID.
static void ClearAll ()
 Removes and disposes all active timers, clearing the entire timer collection.

Properties

TimerType Type [get]
 Gets the type of the timer, indicating whether it is a pre-cycle or post-cycle timer.
TimerCycles Cycles [get]
 Gets the current timer cycles, representing whether the timer is set to run once or repeatedly.
long Length [get]
 Gets the length of the current timer interval in seconds.
string TimerID = string.Empty [get, set]
 Gets the unique identifier for the Timer.
bool Paused [get, set]
 Gets or sets a value indicating whether the Timer is currently paused.
static bool PausedAll [get, set]
 Gets or sets a value indicating whether all operations are globally paused.
static int Count [get]
 Gets the total number of active timers.
static string[] TimerIDs [get]
 Gets an array of timer identifiers currently managed by the Engine.

Events

Action? Tick
 Occurs when the timer interval has elapsed.

Detailed Description

Represents a high-resolution timer that can trigger events at specified intervals and supports various timer types and cycles. This class is designed to be used within the Gondwana engine.

The Timer class provides functionality for creating and managing timers that can trigger events based on a specified duration and cycle type. Timers can be paused, resumed, and disposed of when no longer needed. The class also supports managing multiple timers through static methods, such as adding, removing, and retrieving timers by their unique identifiers. This class is thread-safe for managing timers but does not guarantee thread safety for individual timer instances. Use appropriate synchronization if accessing instance members from multiple threads.

Member Function Documentation

◆ Add() [1/2]

Timer Gondwana.Timers.Timer.Add ( string timerID,
TimerType type,
TimerCycles cycles,
double length )
static

Creates a new timer with the specified parameters and adds it to the collection of active timers.

The created timer is automatically added to the internal collection of active timers and can be retrieved or managed using its timerID .

Parameters
timerIDA unique identifier for the timer. Cannot be null or empty.
typeGets the type of the timer, indicating whether it is a pre-cycle or post-cycle timer.
cyclesGets the current timer cycles, representing whether the timer is set to run once or repeatedly.
lengthThe duration of the timer in seconds.
Returns
The newly created Timer instance.

◆ Add() [2/2]

Timer Gondwana.Timers.Timer.Add ( TimerType type,
TimerCycles cycles,
double length )
static

Creates and adds a new timer with the specified type, cycle count, and duration.

Parameters
typeGets the type of the timer, indicating whether it is a pre-cycle or post-cycle timer.
cyclesGets the current timer cycles, representing whether the timer is set to run once or repeatedly.
lengthThe duration of the timer in seconds.
Returns
A Timer instance representing the newly created timer.

◆ ClearAll()

void Gondwana.Timers.Timer.ClearAll ( )
static

Removes and disposes all active timers, clearing the entire timer collection.

This method iterates through all active timers, disposes each one, and removes it from the internal collection. After calling this method, the timer collection will be empty and all previously active timers will no longer raise events.

This method is typically called during engine shutdown or when resetting the engine state. It ensures proper cleanup of all timer resources and event subscriptions.

This method is thread-safe and can be called from any thread.

◆ Dispose()

void Gondwana.Timers.Timer.Dispose ( )

Releases all resources used by the Timer and removes it from the collection of active timers.

This method performs cleanup of the timer instance, including:

  • Removing the timer from the internal collection of active timers
  • Clearing all event subscribers from the Tick event
  • Marking the timer as disposed to prevent further use

After disposal, the timer will no longer raise Tick events and cannot be reused. Calling Dispose multiple times is safe and will have no effect after the first call.

This method suppresses finalization to prevent the finalizer from running, as cleanup has already been performed.

◆ Get()

Timer Gondwana.Timers.Timer.Get ( string timerID)
static

Retrieves the Timer instance associated with the specified timer ID.

Parameters
timerIDThe unique identifier of the timer to retrieve. Cannot be null or empty.
Returns
The Timer instance associated with the specified timer ID.

◆ Remove()

void Gondwana.Timers.Timer.Remove ( string timerID)
static

Removes the timer associated with the specified timer ID and releases its resources.

If a timer with the specified timerID exists, it is disposed and removed from the collection. If no timer is found for the given ID, the method performs no action.

Parameters
timerIDThe unique identifier of the timer to remove. Cannot be null or empty.

Property Documentation

◆ Count

int Gondwana.Timers.Timer.Count
staticget

Gets the total number of active timers.

◆ Cycles

TimerCycles Gondwana.Timers.Timer.Cycles
get

Gets the current timer cycles, representing whether the timer is set to run once or repeatedly.

◆ Length

long Gondwana.Timers.Timer.Length
get

Gets the length of the current timer interval in seconds.

◆ Paused

bool Gondwana.Timers.Timer.Paused
getset

Gets or sets a value indicating whether the Timer is currently paused.

◆ PausedAll

bool Gondwana.Timers.Timer.PausedAll
staticgetset

Gets or sets a value indicating whether all operations are globally paused.

◆ TimerID

string Gondwana.Timers.Timer.TimerID = string.Empty
getset

Gets the unique identifier for the Timer.

◆ TimerIDs

string [] Gondwana.Timers.Timer.TimerIDs
staticget

Gets an array of timer identifiers currently managed by the Engine.

◆ Type

TimerType Gondwana.Timers.Timer.Type
get

Gets the type of the timer, indicating whether it is a pre-cycle or post-cycle timer.

Event Documentation

◆ Tick

Action? Gondwana.Timers.Timer.Tick

Occurs when the timer interval has elapsed.

This event is raised each time the timer completes its interval. Subscribers can handle this event to execute custom logic at regular intervals. Ensure the timer is started and enabled for the event to be raised.