Gondwana Game Engine Development (master) - 2.6.1
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 and web platforms using SkiaSharp for graphics and pluggable audio backends for desktop and browser targets.
Loading...
Searching...
No Matches
Gondwana.Drawing.Tilesheets.TilesheetRegistry Class Referencesealed

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

Inheritance diagram for Gondwana.Drawing.Tilesheets.TilesheetRegistry:

Public Member Functions

bool TryGet (string name, out Tilesheet? sheet)
 Attempts to retrieve a Tilesheet by its name from the registry.
Tilesheet? GetOrNull (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, Tilesheet > GetAll ()
 Gets an immutable snapshot of all registered tilesheets as a dictionary.
void Dispose ()
 Releases all resources used by the TilesheetRegistry by clearing and disposing all registered tilesheets.
Tilesheet LoadFromBitmap (string name, SKBitmap bitmap)
 Creates a new tilesheet from an existing SKBitmap and registers it in the registry.
Tilesheet LoadFromStream (string name, Stream stream)
 Creates a new tilesheet from a stream and registers it in the registry.
Tilesheet LoadFromImageFile (string name, string imageFilePath)
 Creates a new tilesheet from an image file and registers it in the registry.
Tilesheet LoadFromAssetsFile (AssetsFile assetsFile, string entryName)
 Creates a new tilesheet from an entry in an assets file and registers it in the registry.
Tilesheet LoadFromDefinitionFile (string gtsPath)
 Creates a new tilesheet from a GTS definition file and registers it in the registry.
Tilesheet LoadFromDefinition (TilesheetDefinition definition, string? baseDirectory=null)
 Creates a new tilesheet from a tilesheet definition object and registers it in the registry.
Tilesheet LoadFromDefinitionAsset (AssetsFile assetsFile, string gtsEntryName)
 Creates a new tilesheet from a GTS definition stored as an entry in an assets file and registers it in the registry.

Properties

static TilesheetRegistry Instance [get]
 Gets the singleton instance of the TilesheetRegistry.
Tilesheet this[string name] [get]
 Gets the Tilesheet associated with the specified name.
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.

Definition at line 12 of file TilesheetRegistry.cs.

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.

Definition at line 233 of file TilesheetRegistry.cs.

◆ Dispose()

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

Releases all resources used by the TilesheetRegistry by clearing and disposing all registered tilesheets.

Definition at line 360 of file TilesheetRegistry.cs.

◆ 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.

Definition at line 274 of file TilesheetRegistry.cs.

◆ 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.

Definition at line 109 of file TilesheetRegistry.cs.

◆ LoadFromAssetsFile()

Tilesheet Gondwana.Drawing.Tilesheets.TilesheetRegistry.LoadFromAssetsFile ( AssetsFile assetsFile,
string entryName )

Creates a new tilesheet from an entry in an assets file and registers it in the registry.

Parameters
assetsFileThe assets file containing the tilesheet image.
entryNameThe name of the entry within the assets file.
Returns
The newly created and registered Tilesheet.

Definition at line 412 of file TilesheetRegistry.cs.

◆ LoadFromBitmap()

Tilesheet Gondwana.Drawing.Tilesheets.TilesheetRegistry.LoadFromBitmap ( string name,
SKBitmap bitmap )

Creates a new tilesheet from an existing SKBitmap and registers it in the registry.

Parameters
nameThe name to assign to the tilesheet.
bitmapThe SKBitmap containing the tilesheet image data.
Returns
The newly created and registered Tilesheet.

Definition at line 373 of file TilesheetRegistry.cs.

◆ LoadFromDefinition()

Tilesheet Gondwana.Drawing.Tilesheets.TilesheetRegistry.LoadFromDefinition ( TilesheetDefinition definition,
string? baseDirectory = null )

Creates a new tilesheet from a tilesheet definition object and registers it in the registry.

Parameters
definitionThe tilesheet definition containing configuration and metadata.
baseDirectoryThe optional base directory for resolving relative paths in the definition. If null, the current directory is used.
Returns
The newly created and registered Tilesheet.

Definition at line 437 of file TilesheetRegistry.cs.

◆ LoadFromDefinitionAsset()

Tilesheet Gondwana.Drawing.Tilesheets.TilesheetRegistry.LoadFromDefinitionAsset ( AssetsFile assetsFile,
string gtsEntryName )

Creates a new tilesheet from a GTS definition stored as an entry in an assets file and registers it in the registry.

Parameters
assetsFileThe assets file containing the GTS definition entry.
gtsEntryNameThe name of the GTS definition entry within the assets file.
Returns
The newly created and registered Tilesheet.

Definition at line 450 of file TilesheetRegistry.cs.

◆ LoadFromDefinitionFile()

Tilesheet Gondwana.Drawing.Tilesheets.TilesheetRegistry.LoadFromDefinitionFile ( string gtsPath)

Creates a new tilesheet from a GTS definition file and registers it in the registry.

Parameters
gtsPathThe file path to the GTS (Gondwana Tilesheet) definition file.
Returns
The newly created and registered Tilesheet.

Definition at line 424 of file TilesheetRegistry.cs.

◆ LoadFromImageFile()

Tilesheet Gondwana.Drawing.Tilesheets.TilesheetRegistry.LoadFromImageFile ( string name,
string imageFilePath )

Creates a new tilesheet from an image file and registers it in the registry.

Parameters
nameThe name to assign to the tilesheet.
imageFilePathThe file path to the image file.
Returns
The newly created and registered Tilesheet.

Definition at line 399 of file TilesheetRegistry.cs.

◆ LoadFromStream()

Tilesheet Gondwana.Drawing.Tilesheets.TilesheetRegistry.LoadFromStream ( string name,
Stream stream )

Creates a new tilesheet from a stream and registers it in the registry.

Parameters
nameThe name to assign to the tilesheet.
streamThe stream containing the tilesheet image data.
Returns
The newly created and registered Tilesheet.

Definition at line 386 of file TilesheetRegistry.cs.

◆ 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.

Definition at line 152 of file TilesheetRegistry.cs.

◆ 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.

Definition at line 87 of file TilesheetRegistry.cs.

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.

Definition at line 289 of file TilesheetRegistry.cs.

◆ Instance

TilesheetRegistry Gondwana.Drawing.Tilesheets.TilesheetRegistry.Instance
staticget

Gets the singleton instance of the TilesheetRegistry.

The singleton instance.

Definition at line 25 of file TilesheetRegistry.cs.

◆ 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.

Definition at line 257 of file TilesheetRegistry.cs.

◆ this[string name]

Tilesheet Gondwana.Drawing.Tilesheets.TilesheetRegistry.this[string name]
get

Gets the Tilesheet associated with the specified name.

Parameters
nameThe name of the tilesheet to retrieve. Cannot be null.
Returns
The Tilesheet associated with the specified name.
Exceptions
ArgumentNullExceptionThrown when name is null.
KeyNotFoundExceptionThrown when a tilesheet with the specified name is not found in the registry.

This indexer is thread-safe and provides direct access to tilesheets by name using bracket notation. If you need to check for existence without throwing an exception, use TryGet or GetOrNull instead.

Definition at line 126 of file TilesheetRegistry.cs.