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.DirectComposite Class Reference

Represents a composite container that groups multiple direct drawable items together, managing their positions relative to a common anchor point and providing batch operations. More...

Inheritance diagram for Gondwana.Drawing.Direct.DirectComposite:
Gondwana.Drawing.Direct.IDirectDrawable Gondwana.Movement.IMovable Gondwana.Drawing.IDrawable

Public Member Functions

 DirectComposite (RenderSurfaceHostBase renderSurfaceHost, DirectDrawingMode mode, PointF anchor=default, string? nickname=null)
 Initializes a new instance of the DirectComposite class.
Vector2 GetPosition ()
 Gets the current anchor position of the composite in pixels.
void SetPosition (Vector2 pos)
 Sets the composite anchor position using a Vector2.
RectangleF GetDrawLocationScreen (View view)
 Gets the screen rectangle that encompasses all visible children in the composite.
void Draw (BackbufferBase backbuffer, RectangleF destRectScreen)
 Draws the composite. This is intentionally a no-op as children are responsible for their own rendering.
DirectComposite Add (DirectDrawingMovableBase child, bool keepCurrentOffset=true, Vector2? explicitLocalOffsetPx=null)
 Adds a child and stores its local pixel offset from the composite anchor. If keepCurrentOffset is true (default), the offset is computed from the child's current Bounds. Otherwise, pass an explicit local pixel offset.
DirectComposite Remove (DirectDrawingMovableBase child)
 Removes a child from the composite.
DirectComposite Clear ()
 Removes all children from the composite.
DirectComposite SetPosition (float x, float y)
 Sets the composite anchor position in pixels and repositions all children from their stored local offsets.
DirectComposite SetLocalOffset (DirectDrawingMovableBase child, Vector2 newLocalOffsetPx)
 Changes a specific child's local pixel offset and re-applies its absolute position.
DirectComposite SetZOrder (int z)
 Sets the Z-order for all children in the composite.
DirectComposite SetOpacity (float opacity)
 Sets the opacity for all children in the composite.
DirectComposite SetIsVisible (bool visible)
 Sets the visibility for all children in the composite.
DirectComposite FadeTo (float targetOpacity, float durationSec)
 Fades all children to the specified target opacity over the given duration.
DirectComposite FadeIn (float durationSec)
 Fades all children to full opacity (1.0) over the given duration.
DirectComposite FadeOut (float durationSec)
 Fades all children to zero opacity (0.0) over the given duration.
void Update (long tick)
 Updates the composite's movement controller based on the current tick.
void Dispose ()
 Releases all resources used by the composite and disposes all child drawables.

Properties

RenderSurfaceHostBase RenderSurfaceHost [get]
 Gets the render surface host associated with this composite.
DirectDrawingMode Mode [get]
 Gets the drawing mode for this composite (world or screen space).
ReadOnlyCollection< DirectDrawingMovableBaseChildren [get]
 Gets the read-only collection of child drawable items in this composite.
MovementController Movement [get]
 Gets the movement controller for animating the composite's position.
Rectangle ScreenBounds [get]
 Gets the bounding rectangle that encompasses all visible children in screen coordinates.
Rectangle WorldBounds [get]
 Gets the bounding rectangle that encompasses all visible children in world coordinates.
MovementSpace PositionSpace [get]
 Gets the position space used by this composite. Always returns MovementSpace.Pixel.
Guid Id = Guid.NewGuid() [get]
 Gets the unique identifier for this composite.
string? Nickname [get]
 Gets the optional friendly name for this composite.
bool Visible [get, set]
 Gets or sets the visibility of the composite. Returns true if any child is visible; setting this sets all children's Visible to the same value.
int ZOrder [get]
 Gets the Z-order of the composite. Always returns 0 as individual children manage their own Z-order.

Events

EventHandler< IDirectDrawable >? Disposing
 Event raised when this composite is being disposed.
Events inherited from Gondwana.Drawing.Direct.IDirectDrawable
EventHandler< IDirectDrawable >? Disposing
 Occurs when the object is being disposed.

Detailed Description

Represents a composite container that groups multiple direct drawable items together, managing their positions relative to a common anchor point and providing batch operations.

Constructor & Destructor Documentation

◆ DirectComposite()

Gondwana.Drawing.Direct.DirectComposite.DirectComposite ( RenderSurfaceHostBase renderSurfaceHost,
DirectDrawingMode mode,
PointF anchor = default,
string? nickname = null )

Initializes a new instance of the DirectComposite class.

Parameters
renderSurfaceHostThe render surface host for drawing operations.
modeThe drawing mode (world or screen space).
anchorThe anchor point for the composite in pixels. Default is (0, 0).
nicknameOptional friendly name for the composite.

Member Function Documentation

◆ Add()

DirectComposite Gondwana.Drawing.Direct.DirectComposite.Add ( DirectDrawingMovableBase child,
bool keepCurrentOffset = true,
Vector2? explicitLocalOffsetPx = null )

Adds a child and stores its local pixel offset from the composite anchor. If keepCurrentOffset is true (default), the offset is computed from the child's current Bounds. Otherwise, pass an explicit local pixel offset.

Parameters
childThe child drawable to add to the composite.
keepCurrentOffsetIf true, computes the offset from the child's current position relative to the anchor. If false, uses the explicit offset.
explicitLocalOffsetPxOptional explicit pixel offset to use when keepCurrentOffset is false.
Returns
This composite instance for method chaining.

◆ Clear()

DirectComposite Gondwana.Drawing.Direct.DirectComposite.Clear ( )

Removes all children from the composite.

Returns
This composite instance for method chaining.

◆ Dispose()

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

Releases all resources used by the composite and disposes all child drawables.

◆ Draw()

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

Draws the composite. This is intentionally a no-op as children are responsible for their own rendering.

Parameters
backbufferThe backbuffer to draw to.
destRectScreenThe destination rectangle in screen coordinates.

Implements Gondwana.Drawing.IDrawable.

◆ FadeIn()

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

Fades all children to full opacity (1.0) over the given duration.

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

◆ FadeOut()

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

Fades all children to zero opacity (0.0) over the given duration.

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

◆ FadeTo()

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

Fades all children to the specified target opacity over the given duration.

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

◆ GetDrawLocationScreen()

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

Gets the screen rectangle that encompasses all visible children in the composite.

Parameters
viewThe view to use for coordinate transformation.
Returns
The bounding rectangle in screen coordinates, or an empty rectangle if no children are visible.

Implements Gondwana.Drawing.IDrawable.

◆ GetPosition()

Vector2 Gondwana.Drawing.Direct.DirectComposite.GetPosition ( )

Gets the current anchor position of the composite in pixels.

Returns
The anchor position as a Vector2.

Implements Gondwana.Movement.IMovable.

◆ Remove()

DirectComposite Gondwana.Drawing.Direct.DirectComposite.Remove ( DirectDrawingMovableBase child)

Removes a child from the composite.

Parameters
childThe child drawable to remove.
Returns
This composite instance for method chaining.

◆ SetIsVisible()

DirectComposite Gondwana.Drawing.Direct.DirectComposite.SetIsVisible ( bool visible)

Sets the visibility for all children in the composite.

Parameters
visibleTrue to make all children visible; false to hide them.
Returns
This composite instance for method chaining.

◆ SetLocalOffset()

DirectComposite Gondwana.Drawing.Direct.DirectComposite.SetLocalOffset ( DirectDrawingMovableBase child,
Vector2 newLocalOffsetPx )

Changes a specific child's local pixel offset and re-applies its absolute position.

Parameters
childThe child whose offset to change.
newLocalOffsetPxThe new local pixel offset relative to the composite's anchor.
Returns
This composite instance for method chaining.

◆ SetOpacity()

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

Sets the opacity for all children in the composite.

Parameters
opacityThe opacity value (0.0 to 1.0) to apply to all children.
Returns
This composite instance for method chaining.

◆ SetPosition() [1/2]

DirectComposite Gondwana.Drawing.Direct.DirectComposite.SetPosition ( float x,
float y )

Sets the composite anchor position in pixels and repositions all children from their stored local offsets.

Parameters
xThe X coordinate of the anchor in pixels.
yThe Y coordinate of the anchor in pixels.
Returns
This composite instance for method chaining.

◆ SetPosition() [2/2]

void Gondwana.Drawing.Direct.DirectComposite.SetPosition ( Vector2 pos)

Sets the composite anchor position using a Vector2.

Parameters
posThe new anchor position in pixels.

Implements Gondwana.Movement.IMovable.

◆ SetZOrder()

DirectComposite Gondwana.Drawing.Direct.DirectComposite.SetZOrder ( int z)

Sets the Z-order for all children in the composite.

Parameters
zThe Z-order value to apply to all children.
Returns
This composite instance for method chaining.

◆ Update()

void Gondwana.Drawing.Direct.DirectComposite.Update ( long tick)

Updates the composite's movement controller based on the current tick.

Parameters
tickThe current high-resolution tick value.

Implements Gondwana.Drawing.Direct.IDirectDrawable.

Property Documentation

◆ Children

ReadOnlyCollection<DirectDrawingMovableBase> Gondwana.Drawing.Direct.DirectComposite.Children
get

Gets the read-only collection of child drawable items in this composite.

◆ Id

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

Gets the unique identifier for this composite.

Implements Gondwana.Drawing.IDrawable.

◆ Mode

DirectDrawingMode Gondwana.Drawing.Direct.DirectComposite.Mode
get

Gets the drawing mode for this composite (world or screen space).

Implements Gondwana.Drawing.Direct.IDirectDrawable.

◆ Movement

MovementController Gondwana.Drawing.Direct.DirectComposite.Movement
get

Gets the movement controller for animating the composite's position.

◆ Nickname

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

Gets the optional friendly name for this composite.

Implements Gondwana.Drawing.IDrawable.

◆ PositionSpace

MovementSpace Gondwana.Drawing.Direct.DirectComposite.PositionSpace
get

Gets the position space used by this composite. Always returns MovementSpace.Pixel.

Implements Gondwana.Movement.IMovable.

◆ RenderSurfaceHost

RenderSurfaceHostBase Gondwana.Drawing.Direct.DirectComposite.RenderSurfaceHost
get

Gets the render surface host associated with this composite.

Implements Gondwana.Drawing.Direct.IDirectDrawable.

◆ ScreenBounds

Rectangle Gondwana.Drawing.Direct.DirectComposite.ScreenBounds
get

Gets the bounding rectangle that encompasses all visible children in screen coordinates.

Implements Gondwana.Drawing.Direct.IDirectDrawable.

◆ Visible

bool Gondwana.Drawing.Direct.DirectComposite.Visible
getset

Gets or sets the visibility of the composite. Returns true if any child is visible; setting this sets all children's Visible to the same value.

Implements Gondwana.Drawing.IDrawable.

◆ WorldBounds

Rectangle Gondwana.Drawing.Direct.DirectComposite.WorldBounds
get

Gets the bounding rectangle that encompasses all visible children in world coordinates.

Implements Gondwana.Drawing.Direct.IDirectDrawable.

◆ ZOrder

int Gondwana.Drawing.Direct.DirectComposite.ZOrder
get

Gets the Z-order of the composite. Always returns 0 as individual children manage their own Z-order.

Implements Gondwana.Drawing.IDrawable.

Event Documentation

◆ Disposing

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

Event raised when this composite is being disposed.