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.Drawing.Tilesheets.TilesheetRegistry Class Referencesealed

Thread-safe singleton registry for Tilesheet instances. More...

Public Member Functions

bool TryGet (string name, out Tilesheet? sheet)
 Attempts to retrieve a Tilesheet by its name from the registry.
TilesheetGetOrNull (string name)
 Retrieves a Tilesheet by its name from the registry, or null if not found.
bool Remove (string name, bool dispose=false)
 Removes the tilesheet with the specified name from the collection.
void Clear ()
 Removes all tilesheets from the registry and disposes them.
IImmutableDictionary< string, TilesheetGetAll ()
 Gets an immutable snapshot of all registered tilesheets as a dictionary.

Properties

static TilesheetRegistry Instance [get]
 Gets the singleton instance of the TilesheetRegistry.
IReadOnlyList< string > Names [get]
 Gets a read-only list of all tilesheet names currently registered in the registry.
int Count [get]
 Gets the number of tilesheets currently registered in the registry.

Detailed Description

Thread-safe singleton registry for Tilesheet instances.

Member Function Documentation

◆ Clear()

void Gondwana.Drawing.Tilesheets.TilesheetRegistry.Clear ( )

Removes all tilesheets from the registry and disposes them.

This method is thread-safe. All tilesheets in the registry are disposed after being removed. Use with caution as any external references to the tilesheets will reference disposed objects.

◆ GetAll()

IImmutableDictionary< string, Tilesheet > Gondwana.Drawing.Tilesheets.TilesheetRegistry.GetAll ( )

Gets an immutable snapshot of all registered tilesheets as a dictionary.

Returns
An immutable dictionary containing all registered tilesheets, keyed by their names.

This method is thread-safe and returns a snapshot of the registry at the time of invocation. The returned dictionary uses the same string comparer as the internal collection.

◆ GetOrNull()

Tilesheet? Gondwana.Drawing.Tilesheets.TilesheetRegistry.GetOrNull ( string name)

Retrieves a Tilesheet by its name from the registry, or null if not found.

Parameters
nameThe name of the tilesheet to retrieve.
Returns
The tilesheet associated with the specified name, or null if not found.

This method is thread-safe and provides a convenient alternative to TryGet when a null return value is acceptable.

◆ Remove()

bool Gondwana.Drawing.Tilesheets.TilesheetRegistry.Remove ( string name,
bool dispose = false )

Removes the tilesheet with the specified name from the collection.

Parameters
nameThe name of the tilesheet to remove. Cannot be null.
disposeA value indicating whether the removed tilesheet should be disposed. true to dispose the tilesheet; otherwise, false. This is to prevent issues where a Tilesheet is removed, but existing references still exist.
Returns
true if the tilesheet was successfully removed; otherwise, false.
Exceptions
ArgumentNullExceptionThrown if name is null.

◆ TryGet()

bool Gondwana.Drawing.Tilesheets.TilesheetRegistry.TryGet ( string name,
out Tilesheet? sheet )

Attempts to retrieve a Tilesheet by its name from the registry.

Parameters
nameThe name of the tilesheet to retrieve. Cannot be null.
sheetWhen this method returns, contains the tilesheet associated with the specified name, if found; otherwise, null.
Returns
true if the tilesheet was found in the registry; otherwise, false.

This method is thread-safe. If name is null, a warning is logged and the method returns false.

Property Documentation

◆ Count

int Gondwana.Drawing.Tilesheets.TilesheetRegistry.Count
get

Gets the number of tilesheets currently registered in the registry.

The total count of registered tilesheets.

This property is thread-safe.

◆ Instance

TilesheetRegistry Gondwana.Drawing.Tilesheets.TilesheetRegistry.Instance
staticget

Gets the singleton instance of the TilesheetRegistry.

The singleton instance.

◆ Names

IReadOnlyList<string> Gondwana.Drawing.Tilesheets.TilesheetRegistry.Names
get

Gets a read-only list of all tilesheet names currently registered in the registry.

A read-only list containing the names of all registered tilesheets.

This property is thread-safe and returns a snapshot of the names at the time of access.