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.Direct.DirectDrawingBase Class Referenceabstract

Provides the base implementation for direct drawing objects that can be rendered to the backbuffer with support for opacity, fade transitions, reveal animations, and flexible positioning modes. More...

Inheritance diagram for Gondwana.Drawing.Direct.DirectDrawingBase:
Gondwana.Drawing.Direct.IDirectDrawable Gondwana.Drawing.IDrawable Gondwana.Drawing.Direct.DirectDrawingMovableBase Gondwana.Drawing.Direct.DirectVideo Gondwana.Drawing.Direct.DirectImage Gondwana.Drawing.Direct.DirectRectangle Gondwana.Drawing.Direct.Particles.ParticleSurface Gondwana.Drawing.Direct.TextBlock

Public Types

enum  RevealDirection { LeftToRight , RightToLeft , TopToBottom , BottomToTop }
 Defines the direction from which a reveal animation progressively displays the direct drawing. More...

Public Member Functions

RectangleF GetDrawLocationScreen (View view)
 Gets the screen-space drawing location for this direct drawing as seen from the specified view.
void Draw (BackbufferBase backbuffer, RectangleF destRectScreen)
 Renders this direct drawing to the backbuffer at the specified screen location.
DirectDrawingBase SetOpacity (float opacity)
 Instantly sets the opacity to the specified value without animation.
DirectDrawingBase FadeTo (float targetOpacity, float durationSec)
 Initiates a smooth fade transition to the specified target opacity over the given duration.
DirectDrawingBase FadeIn (float durationSec)
 Fades this direct drawing from its current opacity to fully opaque over the specified duration.
DirectDrawingBase FadeOut (float durationSec)
 Fades this direct drawing from its current opacity to fully transparent over the specified duration.
DirectDrawingBase CancelFade ()
 Cancels any active fade transition, leaving the opacity at its current value.
DirectDrawingBase SetReveal (float t01)
 Instantly sets the reveal progress to the specified value without animation.
DirectDrawingBase SetRevealDirection (RevealDirection dir)
 Sets the direction from which the reveal animation progresses.
DirectDrawingBase RevealTo (float t01, float durationSec, Func< float, float >? easing=null)
 Initiates a smooth reveal animation to the specified target progress over the given duration, optionally using a custom easing function.
virtual void Update (long tick)
 Performs per-frame update logic for this direct drawing, including fade and reveal animations.
int CompareTo (DirectDrawingBase? other)
 Compares this direct drawing to another for sorting by ZOrder.
void Dispose ()
 Releases all resources used by this DirectDrawingBase instance.
override bool Equals (object? obj)
 Determines whether the specified object is equal to the current direct drawing.
override int GetHashCode ()
 Returns a hash code for this direct drawing.

Static Public Member Functions

static bool operator== (DirectDrawingBase? left, DirectDrawingBase? right)
 Determines whether two direct drawing instances are equal using reference equality.
static bool operator!= (DirectDrawingBase? left, DirectDrawingBase? right)
 Determines whether two direct drawing instances are not equal using reference equality.
static bool operator< (DirectDrawingBase? left, DirectDrawingBase? right)
 Determines whether the Z-order of the left direct drawing is less than the right.
static bool operator<= (DirectDrawingBase? left, DirectDrawingBase? right)
 Determines whether the Z-order of the left direct drawing is less than or equal to the right.
static bool operator> (DirectDrawingBase? left, DirectDrawingBase? right)
 Determines whether the Z-order of the left direct drawing is greater than the right.
static bool operator>= (DirectDrawingBase? left, DirectDrawingBase? right)
 Determines whether the Z-order of the left direct drawing is greater than or equal to the right.

Protected Member Functions

void OnDraw (BackbufferBase backbuffer, RectangleF destRectScreen)
 Performs the concrete drawing for this direct drawing to the backbuffer.
 DirectDrawingBase (RenderSurfaceHostBase renderSurfaceHost, DirectDrawingMode mode, SceneLayer? sceneLayer, View? view, Rectangle? screenBounds, Rectangle? worldBounds, string? nickname=null)
 Initializes a new instance of the DirectDrawingBase class.
virtual void Dispose (bool disposing)
 Releases resources used by this DirectDrawingBase instance.

Protected Attributes

readonly RenderSurfaceHostBase _renderSurfaceHost
 The render surface host that manages this direct drawing's rendering pipeline.
Rectangle _screenBounds
 The current screen-space bounds for view-mode direct drawings, in pixels.
Rectangle _worldBounds
 The current world-space bounds for scene-layer-mode direct drawings, in pixels.
int _zOrder
 The Z-order used for draw sorting. Higher values draw later (on top).
bool _visible
 Indicates whether this direct drawing is currently visible and should be rendered.
long _lastTick = HighResTimer.GetCurrentTick()
 The last engine tick value used for delta-time calculations in Update.

Properties

bool HideWhenFullyTransparent = true [get, set]
 Gets or sets a value indicating whether this direct drawing should be automatically hidden when its opacity reaches zero during fade transitions.
RenderSurfaceHostBase RenderSurfaceHost [get]
 Gets the render surface host that manages this direct drawing's rendering pipeline.
DirectDrawingMode Mode [get]
 Gets the drawing mode that determines how this direct drawing is positioned and transformed.
SceneLayerSceneLayer [get]
 Gets the scene layer to which this direct drawing is attached, or null if the drawing is in view mode.
ViewView [get]
 Gets the view to which this direct drawing is attached, or null if the drawing is in scene-layer mode.
Rectangle ScreenBounds [get, set]
 Gets or sets the screen-space bounds of this direct drawing in pixels.
Rectangle WorldBounds [get, set]
 Gets or sets the world-space bounds of this direct drawing in pixels.
TypedValueBag ValueBag = new() [get]
 Gets the extensible value bag for storing arbitrary key-value data associated with this direct drawing.
Guid Id = Guid.NewGuid() [get]
 Gets the unique identifier for this direct drawing.
string? Nickname [get]
 Gets the optional human-readable name for this direct drawing.
int ZOrder [get, set]
 Gets or sets the Z-order (depth) used for sorting this direct drawing relative to other drawables.
bool Visible [get, set]
 Gets or sets a value indicating whether this direct drawing is visible and should be rendered.
float Opacity [get, set]
 Gets or sets the current opacity of this direct drawing.

Events

EventHandler< IDirectDrawable >? Disposing
 Occurs when this direct drawing is being disposed.
EventHandler< DirectDrawingBase >? FadeToCompleted
 Occurs when a fade transition initiated by FadeTo, FadeIn, or FadeOut completes.
Events inherited from Gondwana.Drawing.Direct.IDirectDrawable
EventHandler< IDirectDrawable >? Disposing
 Occurs when the object is being disposed.

Detailed Description

Provides the base implementation for direct drawing objects that can be rendered to the backbuffer with support for opacity, fade transitions, reveal animations, and flexible positioning modes.

DirectDrawingBase serves as the foundation for all custom drawing operations in the Gondwana engine. Unlike sprites and tiles which are managed by scene layers, direct drawings provide immediate control over rendering with support for advanced visual effects.

Direct drawings can operate in two modes:

  • DirectDrawingMode.SceneLayer - Positioned in world coordinates relative to a specific scene layer, affected by camera and parallax.
  • DirectDrawingMode.View - Positioned in screen coordinates relative to a view, unaffected by camera movement (ideal for UI overlays).

This class is abstract. Derived classes must implement OnDraw to perform the actual drawing operations. The base class handles visibility, opacity, fade transitions, reveal animations, and dirty-rectangle management.

Thread safety: This class is not thread-safe. All operations should be performed on the UI thread.

Member Enumeration Documentation

◆ RevealDirection

Defines the direction from which a reveal animation progressively displays the direct drawing.

The reveal effect uses clipping to progressively show portions of the drawing. The direction determines which edge starts visible and how the visible region expands as the reveal progresses from 0.0 to 1.0.

Enumerator
LeftToRight 

Reveals the drawing from the left edge toward the right edge.

RightToLeft 

Reveals the drawing from the right edge toward the left edge.

TopToBottom 

Reveals the drawing from the top edge toward the bottom edge.

BottomToTop 

Reveals the drawing from the bottom edge toward the top edge.

Constructor & Destructor Documentation

◆ DirectDrawingBase()

Gondwana.Drawing.Direct.DirectDrawingBase.DirectDrawingBase ( RenderSurfaceHostBase renderSurfaceHost,
DirectDrawingMode mode,
SceneLayer? sceneLayer,
View? view,
Rectangle? screenBounds,
Rectangle? worldBounds,
string? nickname = null )
protected

Initializes a new instance of the DirectDrawingBase class.

Parameters
renderSurfaceHostThe render surface host that manages rendering for this direct drawing. Must not be null.
modeThe drawing mode determining how this object is positioned and transformed.
sceneLayerThe scene layer to which this drawing is attached (required if mode is DirectDrawingMode.SceneLayer).
viewThe view to which this drawing is attached (required if mode is DirectDrawingMode.View).
screenBoundsThe screen-space bounds in pixels (required if mode is DirectDrawingMode.View).
worldBoundsThe world-space bounds in pixels (required if mode is DirectDrawingMode.SceneLayer).
nicknameAn optional human-readable name for this direct drawing, useful for debugging and identification.
Exceptions
ArgumentNullExceptionThrown when renderSurfaceHost is null.
ArgumentExceptionThrown when:

The constructor automatically registers this direct drawing with the DirectDrawingManager and marks the appropriate regions as dirty to ensure the drawing appears on the next frame.

Member Function Documentation

◆ CancelFade()

DirectDrawingBase Gondwana.Drawing.Direct.DirectDrawingBase.CancelFade ( )

Cancels any active fade transition, leaving the opacity at its current value.

Returns
This DirectDrawingBase instance for method chaining.

After calling this method, the fade animation stops immediately and Opacity remains at its current value. The FadeToCompleted event will not be raised for the cancelled fade.

◆ CompareTo()

int Gondwana.Drawing.Direct.DirectDrawingBase.CompareTo ( DirectDrawingBase? other)

Compares this direct drawing to another for sorting by ZOrder.

Parameters
otherThe other direct drawing to compare, or null.
Returns
A negative value if this drawing's Z-order is less than other ; zero if they are equal; a positive value if this drawing's Z-order is greater. null is considered to have a Z-order of 0.

This method is used to sort direct drawings during rendering. Higher Z-order values are drawn later and appear on top of lower values.

◆ Dispose() [1/2]

void Gondwana.Drawing.Direct.DirectDrawingBase.Dispose ( )

Releases all resources used by this DirectDrawingBase instance.

This method unregisters the direct drawing from the DirectDrawingManager, marks affected regions as dirty, and raises the Disposing event. After disposal, the object should not be used.

Calling Dispose() multiple times is safe and has no additional effect.

◆ Dispose() [2/2]

virtual void Gondwana.Drawing.Direct.DirectDrawingBase.Dispose ( bool disposing)
protectedvirtual

Releases resources used by this DirectDrawingBase instance.

Parameters
disposingtrue to release both managed and unmanaged resources; false to release only unmanaged resources (called from finalizer).

When disposing is true, this method:

  • Marks affected regions as dirty by calling ForceRefresh.
  • Raises the Disposing event.
  • Clears all event handlers to prevent memory leaks.

Override this method in derived classes to release additional resources. Always call base.Dispose(disposing) to ensure proper cleanup of the base class.

Reimplemented in Gondwana.Drawing.Direct.DirectVideo, Gondwana.Drawing.Direct.Particles.ParticleSurface, and Gondwana.Drawing.Direct.TextBlock.

◆ Draw()

void Gondwana.Drawing.Direct.DirectDrawingBase.Draw ( BackbufferBase backbuffer,
RectangleF destRectScreen )

Renders this direct drawing to the backbuffer at the specified screen location.

Parameters
backbufferThe backbuffer providing the canvas and rendering context.
destRectScreenThe destination rectangle in screen pixel coordinates.

This is the engine's entry point for rendering a direct drawing. It handles visibility checks, opacity blending via SKPaint with layer support, and reveal clipping before delegating to OnDraw for the actual drawing logic.

Do not call this method directly from game code. The rendering pipeline invokes it automatically during the render pass. To trigger a redraw, call ForceRefresh or modify properties that affect appearance.

The method applies the following operations in order:

  1. Visibility check - returns early if Visible is false.
  2. Reveal clipping - applies directional clipping based on SetReveal and SetRevealDirection.
  3. Opacity blending - applies Opacity using canvas layer if less than 1.0.
  4. Calls OnDraw to perform the actual rendering.

Implements Gondwana.Drawing.IDrawable.

◆ Equals()

override bool Gondwana.Drawing.Direct.DirectDrawingBase.Equals ( object? obj)

Determines whether the specified object is equal to the current direct drawing.

Parameters
objThe object to compare with the current instance.
Returns
true if the specified object is the same instance as this direct drawing; otherwise, false.

This implementation uses reference equality only. Direct drawings are considered equal only if they are the exact same object instance.

◆ FadeIn()

DirectDrawingBase Gondwana.Drawing.Direct.DirectDrawingBase.FadeIn ( float durationSec)

Fades this direct drawing from its current opacity to fully opaque over the specified duration.

Parameters
durationSecThe duration of the fade-in in seconds.
Returns
This DirectDrawingBase instance for method chaining.

This is a convenience method equivalent to calling FadeTo(1.0f, durationSec). If the current opacity is already zero or very close to zero, it is set to exactly 0 before starting the fade to ensure a clean transition from invisible to visible.

◆ FadeOut()

DirectDrawingBase Gondwana.Drawing.Direct.DirectDrawingBase.FadeOut ( float durationSec)

Fades this direct drawing from its current opacity to fully transparent over the specified duration.

Parameters
durationSecThe duration of the fade-out in seconds.
Returns
This DirectDrawingBase instance for method chaining.

This is a convenience method equivalent to calling FadeTo(0.0f, durationSec). If HideWhenFullyTransparent is enabled, the object will be automatically hidden when the fade completes.

Use this for smooth disappearance effects. Combine with the FadeToCompleted event to perform cleanup or trigger subsequent logic after the fade-out finishes.

◆ FadeTo()

DirectDrawingBase Gondwana.Drawing.Direct.DirectDrawingBase.FadeTo ( float targetOpacity,
float durationSec )

Initiates a smooth fade transition to the specified target opacity over the given duration.

Parameters
targetOpacityThe target opacity value (0.0 to 1.0).
durationSecThe duration of the fade in seconds. Minimum value is 0.0001 seconds.
Returns
This DirectDrawingBase instance for method chaining.

The fade animation uses linear interpolation and is updated each frame by Update. When the fade completes, the FadeToCompleted event is raised.

If the target opacity is greater than zero, Visible is automatically set to true to ensure the object is rendered during the fade. If HideWhenFullyTransparent is enabled and the target is zero, the object will be hidden when the fade completes.

Starting a new fade cancels any previous fade operation. To cancel a fade without starting a new one, call CancelFade.

◆ GetDrawLocationScreen()

RectangleF Gondwana.Drawing.Direct.DirectDrawingBase.GetDrawLocationScreen ( View view)

Gets the screen-space drawing location for this direct drawing as seen from the specified view.

Parameters
viewThe view from which to calculate the screen location.
Returns
A RectangleF in screen pixel coordinates indicating where this drawing will be rendered. For view mode drawings, this returns ScreenBounds directly. For scene-layer mode drawings, this returns the WorldBounds transformed to screen space using the view's camera and the layer's parallax.

This method is used internally by the rendering pipeline to determine the destination rectangle for drawing operations. It accounts for camera position, zoom, and parallax for scene-layer mode drawings.

Implements Gondwana.Drawing.IDrawable.

◆ GetHashCode()

override int Gondwana.Drawing.Direct.DirectDrawingBase.GetHashCode ( )

Returns a hash code for this direct drawing.

Returns
A hash code based on the Nickname.

The hash code is computed using the nickname. If the nickname is null, it contributes 0 to the hash. This implementation is not suitable for dictionary keys unless nicknames are unique; use Id for unique identification.

◆ OnDraw()

void Gondwana.Drawing.Direct.DirectDrawingBase.OnDraw ( BackbufferBase backbuffer,
RectangleF destRectScreen )
abstractprotected

Performs the concrete drawing for this direct drawing to the backbuffer.

Parameters
backbufferThe backbuffer providing the canvas and rendering context.
destRectScreenThe destination rectangle in screen pixel coordinates where this drawing should be rendered. For scene-layer mode, this is the world bounds transformed to screen space. For view mode, this is the screen bounds directly.

Override this method in derived classes to implement custom drawing logic using SkiaSharp's SKCanvas (accessible via backbuffer.Canvas).

Do not call this method directly. The engine calls it via Draw after applying visibility checks, opacity blending, and reveal clipping. The canvas state is managed by the base class; derived implementations should not call Save() or Restore() unless paired within the method.

The destination rectangle provided is already transformed to screen space and clipped to the appropriate viewport or reveal region.

◆ operator!=()

bool Gondwana.Drawing.Direct.DirectDrawingBase.operator!= ( DirectDrawingBase? left,
DirectDrawingBase? right )
static

Determines whether two direct drawing instances are not equal using reference equality.

Parameters
leftThe first direct drawing to compare.
rightThe second direct drawing to compare.
Returns
true if the references do not point to the same instance; otherwise, false.

◆ operator<()

bool Gondwana.Drawing.Direct.DirectDrawingBase.operator< ( DirectDrawingBase? left,
DirectDrawingBase? right )
static

Determines whether the Z-order of the left direct drawing is less than the right.

Parameters
leftThe first direct drawing to compare.
rightThe second direct drawing to compare.
Returns
true if left has a lower Z-order than right ; otherwise, false. null is considered to have a Z-order of 0.

◆ operator<=()

bool Gondwana.Drawing.Direct.DirectDrawingBase.operator<= ( DirectDrawingBase? left,
DirectDrawingBase? right )
static

Determines whether the Z-order of the left direct drawing is less than or equal to the right.

Parameters
leftThe first direct drawing to compare.
rightThe second direct drawing to compare.
Returns
true if left has a Z-order less than or equal to right ; otherwise, false. null is considered to have a Z-order of 0.

◆ operator==()

bool Gondwana.Drawing.Direct.DirectDrawingBase.operator== ( DirectDrawingBase? left,
DirectDrawingBase? right )
static

Determines whether two direct drawing instances are equal using reference equality.

Parameters
leftThe first direct drawing to compare.
rightThe second direct drawing to compare.
Returns
true if both references point to the same instance or are both null; otherwise, false.

◆ operator>()

bool Gondwana.Drawing.Direct.DirectDrawingBase.operator> ( DirectDrawingBase? left,
DirectDrawingBase? right )
static

Determines whether the Z-order of the left direct drawing is greater than the right.

Parameters
leftThe first direct drawing to compare.
rightThe second direct drawing to compare.
Returns
true if left has a higher Z-order than right ; otherwise, false. null is considered to have a Z-order of 0.

◆ operator>=()

bool Gondwana.Drawing.Direct.DirectDrawingBase.operator>= ( DirectDrawingBase? left,
DirectDrawingBase? right )
static

Determines whether the Z-order of the left direct drawing is greater than or equal to the right.

Parameters
leftThe first direct drawing to compare.
rightThe second direct drawing to compare.
Returns
true if left has a Z-order greater than or equal to right ; otherwise, false. null is considered to have a Z-order of 0.

◆ RevealTo()

DirectDrawingBase Gondwana.Drawing.Direct.DirectDrawingBase.RevealTo ( float t01,
float durationSec,
Func< float, float >? easing = null )

Initiates a smooth reveal animation to the specified target progress over the given duration, optionally using a custom easing function.

Parameters
t01The target reveal progress from 0.0 (fully hidden) to 1.0 (fully shown).
durationSecThe duration of the reveal animation in seconds. Minimum value is 0.0001 seconds.
easingAn optional easing function that transforms the linear progress (0..1 input) to the desired interpolation curve (0..1 output). If null, linear interpolation is used.
Returns
This DirectDrawingBase instance for method chaining.

The reveal animation is updated each frame by Update. The easing function, if provided, allows custom animation curves such as ease-in, ease-out, or elastic effects.

Starting a new reveal animation cancels any previous reveal operation. The animation starts from the current reveal value and interpolates to the target.

◆ SetOpacity()

DirectDrawingBase Gondwana.Drawing.Direct.DirectDrawingBase.SetOpacity ( float opacity)

Instantly sets the opacity to the specified value without animation.

Parameters
opacityThe target opacity value (0.0 to 1.0).
Returns
This DirectDrawingBase instance for method chaining.

This is equivalent to setting the Opacity property directly. It is provided for fluent-style API usage and method chaining. The value is clamped to the 0..1 range.

◆ SetReveal()

DirectDrawingBase Gondwana.Drawing.Direct.DirectDrawingBase.SetReveal ( float t01)

Instantly sets the reveal progress to the specified value without animation.

Parameters
t01The reveal progress from 0.0 (fully hidden) to 1.0 (fully shown).
Returns
This DirectDrawingBase instance for method chaining.

The reveal effect progressively clips the rendering based on the SetRevealDirection. At 0.0, the entire drawing is clipped; at 1.0, the full drawing is visible. Values are clamped to the 0..1 range.

This method sets the reveal progress immediately. For animated reveal transitions, use RevealTo.

◆ SetRevealDirection()

DirectDrawingBase Gondwana.Drawing.Direct.DirectDrawingBase.SetRevealDirection ( RevealDirection dir)

Sets the direction from which the reveal animation progresses.

Parameters
dirThe reveal direction (left-to-right, right-to-left, top-to-bottom, or bottom-to-top).
Returns
This DirectDrawingBase instance for method chaining.

The reveal direction determines how the clip rectangle grows as the reveal progresses from 0 to 1. For example, RevealDirection.LeftToRight reveals the drawing from the left edge first, progressively showing more to the right as the reveal value increases.

◆ Update()

virtual void Gondwana.Drawing.Direct.DirectDrawingBase.Update ( long tick)
virtual

Performs per-frame update logic for this direct drawing, including fade and reveal animations.

Parameters
tickThe current engine tick value from HighResTimer.

This method is called automatically by the DirectDrawingManager each frame. The base implementation advances active fade and reveal animations. Override this method in derived classes to add custom per-frame logic (such as animation or physics updates).

Always call base.Update(tick) from overridden implementations to ensure fade and reveal animations continue to function correctly.

The method calculates delta time using HighResTimer and the previous tick stored in _lastTick. If the tick value is less than or equal to the last tick (which can occur if time is manipulated), the method returns immediately without updating state.

Implements Gondwana.Drawing.Direct.IDirectDrawable.

Reimplemented in Gondwana.Drawing.Direct.DirectDrawingMovableBase, Gondwana.Drawing.Direct.DirectRectangle, Gondwana.Drawing.Direct.Particles.ParticleSurface, and Gondwana.Drawing.Direct.TextBlock.

Member Data Documentation

◆ _lastTick

long Gondwana.Drawing.Direct.DirectDrawingBase._lastTick = HighResTimer.GetCurrentTick()
protected

The last engine tick value used for delta-time calculations in Update.

◆ _renderSurfaceHost

readonly RenderSurfaceHostBase Gondwana.Drawing.Direct.DirectDrawingBase._renderSurfaceHost
protected

The render surface host that manages this direct drawing's rendering pipeline.

◆ _screenBounds

Rectangle Gondwana.Drawing.Direct.DirectDrawingBase._screenBounds
protected

The current screen-space bounds for view-mode direct drawings, in pixels.

◆ _visible

bool Gondwana.Drawing.Direct.DirectDrawingBase._visible
protected

Indicates whether this direct drawing is currently visible and should be rendered.

◆ _worldBounds

Rectangle Gondwana.Drawing.Direct.DirectDrawingBase._worldBounds
protected

The current world-space bounds for scene-layer-mode direct drawings, in pixels.

◆ _zOrder

int Gondwana.Drawing.Direct.DirectDrawingBase._zOrder
protected

The Z-order used for draw sorting. Higher values draw later (on top).

Property Documentation

◆ HideWhenFullyTransparent

bool Gondwana.Drawing.Direct.DirectDrawingBase.HideWhenFullyTransparent = true
getset

Gets or sets a value indicating whether this direct drawing should be automatically hidden when its opacity reaches zero during fade transitions.

true to automatically hide when fully transparent (default); false to keep the object visible even at zero opacity.

When enabled, setting Opacity to 0 or completing a FadeOut will set Visible to false. Conversely, increasing opacity above zero will restore visibility.

◆ Id

Guid Gondwana.Drawing.Direct.DirectDrawingBase.Id = Guid.NewGuid()
get

Gets the unique identifier for this direct drawing.

A Guid that uniquely identifies this instance across the application lifetime.

The ID is generated during construction and remains constant throughout the object's lifetime. Use this for tracking, lookup, or equality comparisons when reference equality is not suitable.

Implements Gondwana.Drawing.IDrawable.

◆ Mode

DirectDrawingMode Gondwana.Drawing.Direct.DirectDrawingBase.Mode
get

Gets the drawing mode that determines how this direct drawing is positioned and transformed.

A DirectDrawingMode value indicating whether this drawing uses world coordinates (scene-layer mode) or screen coordinates (view mode).

The mode is set during construction and cannot be changed. Scene-layer mode drawings move with the camera and are affected by parallax, while view mode drawings remain fixed in screen space, ideal for UI overlays.

Implements Gondwana.Drawing.Direct.IDirectDrawable.

◆ Nickname

string? Gondwana.Drawing.Direct.DirectDrawingBase.Nickname
get

Gets the optional human-readable name for this direct drawing.

A string nickname for debugging and identification purposes, or null if not set.

Nicknames are useful for logging, debugging, and identifying objects in diagnostic output. They are not required to be unique.

Implements Gondwana.Drawing.IDrawable.

◆ Opacity

float Gondwana.Drawing.Direct.DirectDrawingBase.Opacity
getset

Gets or sets the current opacity of this direct drawing.

A floating-point value between 0.0 (fully transparent) and 1.0 (fully opaque). Default is 1.0.

Setting opacity automatically marks the affected regions as dirty. Values outside the 0..1 range are clamped. Very small changes (less than 0.0001) are ignored to avoid unnecessary redraws.

If HideWhenFullyTransparent is enabled:

  • Setting opacity to 0 automatically sets Visible to false.
  • Increasing opacity above 0 automatically sets Visible to true.

For animated opacity transitions, use FadeTo, FadeIn, or FadeOut.

◆ RenderSurfaceHost

RenderSurfaceHostBase Gondwana.Drawing.Direct.DirectDrawingBase.RenderSurfaceHost
get

Gets the render surface host that manages this direct drawing's rendering pipeline.

The RenderSurfaceHostBase instance responsible for coordinating rendering, view management, and backbuffer operations for this direct drawing.

Implements Gondwana.Drawing.Direct.IDirectDrawable.

◆ SceneLayer

SceneLayer? Gondwana.Drawing.Direct.DirectDrawingBase.SceneLayer
get

Gets the scene layer to which this direct drawing is attached, or null if the drawing is in view mode.

The SceneLayer instance for scene-layer mode drawings; null for view mode drawings.

Scene-layer mode drawings are positioned in the world coordinate space of the specified layer and are affected by the layer's parallax factor and the view's camera position.

◆ ScreenBounds

Rectangle Gondwana.Drawing.Direct.DirectDrawingBase.ScreenBounds
getset

Gets or sets the screen-space bounds of this direct drawing in pixels.

A Rectangle defining the position and size in screen coordinates. Returns Rectangle.Empty for scene-layer mode drawings.

This property is only meaningful for view mode drawings (Mode is DirectDrawingMode.View). Setting this property for scene-layer mode drawings has no effect.

When set, the affected screen regions are automatically marked as dirty to ensure the drawing is rerendered at the new position. The bounds are clipped to the view's viewport rectangle.

Implements Gondwana.Drawing.Direct.IDirectDrawable.

◆ ValueBag

TypedValueBag Gondwana.Drawing.Direct.DirectDrawingBase.ValueBag = new()
get

Gets the extensible value bag for storing arbitrary key-value data associated with this direct drawing.

A TypedValueBag instance for storing custom metadata, state, or configuration.

Use the value bag to attach game-specific data to direct drawings without modifying the base class. Values are strongly typed and accessed via ValueKey<T> instances.

◆ View

View? Gondwana.Drawing.Direct.DirectDrawingBase.View
get

Gets the view to which this direct drawing is attached, or null if the drawing is in scene-layer mode.

The View instance for view mode drawings; null for scene-layer mode drawings.

View mode drawings are positioned in screen coordinates relative to the specified view's viewport and remain fixed on screen regardless of camera movement.

◆ Visible

bool Gondwana.Drawing.Direct.DirectDrawingBase.Visible
getset

Gets or sets a value indicating whether this direct drawing is visible and should be rendered.

true if this drawing should be rendered; false to skip rendering. Default is true.

When set to false, Draw returns immediately without rendering. The affected regions are marked as dirty to ensure the area is cleared on the next frame.

If HideWhenFullyTransparent is enabled, visibility may be automatically managed during fade transitions based on the Opacity value.

Implements Gondwana.Drawing.IDrawable.

◆ WorldBounds

Rectangle Gondwana.Drawing.Direct.DirectDrawingBase.WorldBounds
getset

Gets or sets the world-space bounds of this direct drawing in pixels.

A Rectangle defining the position and size in world coordinates. Returns Rectangle.Empty for view mode drawings.

This property is only meaningful for scene-layer mode drawings (Mode is DirectDrawingMode.SceneLayer). Setting this property for view mode drawings has no effect.

When set, the affected world regions are automatically marked as dirty to ensure the drawing is rerendered at the new position. The bounds are subject to the layer's parallax factor and the view's camera transformation.

Implements Gondwana.Drawing.Direct.IDirectDrawable.

◆ ZOrder

int Gondwana.Drawing.Direct.DirectDrawingBase.ZOrder
getset

Gets or sets the Z-order (depth) used for sorting this direct drawing relative to other drawables.

An integer Z-order value. Higher values are drawn later and appear on top of lower values. Default is 0.

When multiple direct drawings overlap, Z-order determines the draw sequence. Objects with identical Z-order values are drawn in the order they were added to the manager. Changing the Z-order marks the affected regions as dirty to ensure correct layering on the next frame.

Implements Gondwana.Drawing.IDrawable.

Event Documentation

◆ Disposing

EventHandler<IDirectDrawable>? Gondwana.Drawing.Direct.DirectDrawingBase.Disposing

Occurs when this direct drawing is being disposed.

Subscribe to this event to perform cleanup operations when the direct drawing is removed. The event is raised before the object is fully disposed.

◆ FadeToCompleted

EventHandler<DirectDrawingBase>? Gondwana.Drawing.Direct.DirectDrawingBase.FadeToCompleted

Occurs when a fade transition initiated by FadeTo, FadeIn, or FadeOut completes.

This event is raised on the frame where the fade animation reaches its target opacity. Use this to chain animations or trigger logic after fade transitions.