![]() |
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.
|
Manages the lifecycle, registration, and retrieval of all direct drawing objects in the Gondwana engine. More...
Public Member Functions | |
| IDirectDrawable? | GetDirectDrawing (string name) |
| Retrieves a direct drawing by its nickname. | |
| void | ClearAll () |
| Disposes and removes all registered direct drawings. | |
| void | Clear (string name) |
| Disposes and removes a specific direct drawing by its nickname. | |
| IReadOnlyList< DirectDrawingBase > | GetDrawingsForLayer (SceneLayer layer) |
| Returns all direct drawings associated with a specific scene layer, ordered by Z-order then nickname. | |
| IReadOnlyList< DirectDrawingBase > | GetDrawingsForView (View view) |
| Returns all direct drawings associated with a specific view, ordered by Z-order then nickname. | |
Properties | |
| ReadOnlyCollection< IDirectDrawable > | DirectDrawings [get] |
| Gets a read-only snapshot of all currently registered direct drawings. | |
| int | Count [get] |
| Gets the current number of registered direct drawings. | |
Manages the lifecycle, registration, and retrieval of all direct drawing objects in the Gondwana engine.
DirectDrawingManager is a thread-safe singleton that serves as the central registry for all IDirectDrawable instances. It handles automatic registration during construction, removal on disposal, and provides efficient lookup and filtering capabilities.
Direct drawings are automatically registered when constructed and removed when disposed. The manager maintains a concurrent dictionary keyed by each drawing's unique IDirectDrawable.Id, ensuring thread-safe access during rendering and updates.
Key responsibilities:
Access the singleton instance via Instance. Direct drawings register themselves automatically during construction by calling AddOrReplace internally.
Thread safety: All public methods are thread-safe. The manager uses ConcurrentDictionary<TKey, TValue> internally and creates snapshots for iteration to avoid race conditions during enumeration.
| void Gondwana.Drawing.Direct.DirectDrawingManager.Clear | ( | string | name | ) |
Disposes and removes a specific direct drawing by its nickname.
| name | The nickname of the direct drawing to remove. May be null or empty. |
If a drawing with the specified nickname exists, it is disposed, which automatically triggers its removal from the manager. If no matching drawing is found, or if name is null or empty, this method does nothing.
This method uses case-sensitive ordinal comparison. If multiple drawings share the same nickname, only one will be removed.
| void Gondwana.Drawing.Direct.DirectDrawingManager.ClearAll | ( | ) |
Disposes and removes all registered direct drawings.
This method creates a snapshot of all current drawings and disposes each one in sequence. Disposal automatically triggers removal from the manager via the IDirectDrawable.Disposing event handler.
Use this method to perform a full cleanup, such as when changing scenes or shutting down the engine. After calling this method, Count will be zero.
This operation is safe to call even if drawings are being added from other threads, though newly added drawings after the snapshot is taken will not be affected.
| IDirectDrawable? Gondwana.Drawing.Direct.DirectDrawingManager.GetDirectDrawing | ( | string | name | ) |
Retrieves a direct drawing by its nickname.
| name | The nickname of the direct drawing to retrieve. May be null. |
null if no matching drawing is found or name is null. This method performs a case-sensitive ordinal comparison using the drawing's IDirectDrawable.Nickname. If multiple drawings share the same nickname (which should generally be avoided), only one will be returned.
For reliable lookup, consider using the drawing's IDirectDrawable.Id instead, which is guaranteed to be unique.
| IReadOnlyList< DirectDrawingBase > Gondwana.Drawing.Direct.DirectDrawingManager.GetDrawingsForLayer | ( | SceneLayer | layer | ) |
Returns all direct drawings associated with a specific scene layer, ordered by Z-order then nickname.
| layer | The scene layer to query. May be null. |
null or if no drawings are attached to the layer. This method filters direct drawings by DirectDrawingMode.SceneLayer mode and uses reference equality to match the specified layer instance. Only drawings positioned in world coordinates relative to the given layer are included.
The returned list is a snapshot taken at the time of the call and will not reflect subsequent additions or removals. The sorting ensures consistent draw order when rendering the layer.
Use this method during rendering to retrieve all drawings that should be rendered as part of a specific scene layer, respecting Z-order for correct layering.
| IReadOnlyList< DirectDrawingBase > Gondwana.Drawing.Direct.DirectDrawingManager.GetDrawingsForView | ( | View | view | ) |
Returns all direct drawings associated with a specific view, ordered by Z-order then nickname.
| view | The view to query. May be null. |
null or if no drawings are attached to the view. This method filters direct drawings by DirectDrawingMode.View mode and uses reference equality to match the specified view instance. Only drawings positioned in screen coordinates relative to the given view are included (e.g., UI overlays, HUD elements).
The returned list is a snapshot taken at the time of the call and will not reflect subsequent additions or removals. The sorting ensures consistent draw order when rendering view overlays.
Use this method during rendering to retrieve all drawings that should be rendered on top of a specific view, unaffected by camera movement. Common use cases include UI elements, debug overlays, and screen-space effects.
|
get |
Gets the current number of registered direct drawings.
An integer count of all direct drawings currently managed by this instance.
This property provides a thread-safe snapshot of the count at the moment of access. The count may change immediately after being read if drawings are added or removed from other threads.
|
get |
Gets a read-only snapshot of all currently registered direct drawings.
A ReadOnlyCollection<T> containing all direct drawings managed by this instance. The collection is a snapshot taken at the time of access and will not reflect subsequent additions or removals.
This property creates a new snapshot each time it is accessed, so avoid calling it repeatedly in performance-critical loops. Cache the result if you need to iterate multiple times.
The returned collection is unordered. For ordered collections filtered by layer or view, use GetDrawingsForLayer or GetDrawingsForView.