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

Represents a movable composite that owns other movable direct drawables and keeps their positions relative to a shared anchor. More...

Inheritance diagram for Gondwana.Drawing.Direct.DirectComposite:
Gondwana.Drawing.Direct.IDirectCompositeChild Gondwana.Drawing.Direct.IDirectCompositeContainer Gondwana.Drawing.Direct.IDirectDrawable Gondwana.Physics.Movement.IMovable Gondwana.Drawing.IDrawable Gondwana.Widgets.WidgetBase Gondwana.Widgets.ContainerWidget Gondwana.Widgets.Controls.ButtonWidget Gondwana.Widgets.Controls.CheckBoxWidget Gondwana.Widgets.Controls.HyperlinkWidget Gondwana.Widgets.Controls.LabelWidget Gondwana.Widgets.Controls.ListBoxWidget Gondwana.Widgets.Controls.ProgressBarWidget Gondwana.Widgets.Controls.RadioButtonWidget Gondwana.Widgets.Controls.TextBoxWidget Gondwana.Widgets.Dialogs.ConversationBox Gondwana.Widgets.DraggableWidgetBase Gondwana.Widgets.Hud.HealthBarWidget Gondwana.Widgets.Hud.NameTagWidget Gondwana.Widgets.Menus.MenuHeaderWidget Gondwana.Widgets.Menus.MenuItemWidget Gondwana.Widgets.Overlays.PopupWidget Gondwana.Widgets.Overlays.SplashScreen Gondwana.Widgets.Overlays.ToastWidget Gondwana.Widgets.Overlays.TooltipWidget

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 composite anchor.
void SetPosition (Vector2 position)
 Sets the composite anchor and repositions all children from their stored offsets.
DirectComposite SetPosition (float x, float y)
 Sets the composite anchor and repositions all children from their stored offsets.
virtual DirectComposite Add (IDirectCompositeChild child, bool keepCurrentOffset=true, Vector2? explicitLocalOffsetPx=null)
 Adds a composite-compatible direct drawable as a child.
virtual DirectComposite Remove (IDirectCompositeChild child)
 Removes a child without disposing it.
virtual DirectComposite Clear ()
 Removes every child without disposing them.
DirectComposite SetLocalOffset (IDirectCompositeChild child, Vector2 newLocalOffsetPx)
 Changes one child's local offset and reapplies its position.
DirectComposite SetZOrder (int zOrder)
 Applies one Z-order to every descendant.
DirectComposite SetOpacity (float opacity)
 Applies one opacity to every descendant.
DirectComposite SetIsVisible (bool visible)
 Applies one visibility value to every descendant.
DirectComposite FadeTo (float targetOpacity, float durationSec)
 Fades every descendant to the requested opacity.
DirectComposite FadeIn (float durationSec)
 Fades every descendant to full opacity.
DirectComposite FadeOut (float durationSec)
 Fades every descendant to zero opacity.
RectangleF GetDrawLocationScreen (View view)
 Gets the union of all visible descendants as projected through a view.
void Draw (BackbufferBase backbuffer, RectangleF destRectScreen)
 Performs no direct rendering because descendants render independently.
virtual void Update (long tick)
 Advances composite movement.
virtual void Dispose ()
 Disposes the composite and every child it owns.

Protected Member Functions

virtual void OnChildAdded (IDirectCompositeChild child)
 Called after a child has been successfully added.
virtual void OnChildRemoved (IDirectCompositeChild child)
 Called after a child has been removed from the composite.

Properties

Guid Id = Guid.NewGuid() [get]
 Gets the unique identifier of the composite.
string? Nickname [get]
 Gets the optional diagnostic nickname of the composite.
RenderSurfaceHostBase RenderSurfaceHost [get]
 Gets the render surface host shared by the composite and its children.
DirectDrawingMode Mode [get]
 Gets the coordinate mode shared by the composite and its children.
SceneLayer? SceneLayer [get]
 Gets the scene layer shared by all children in scene-layer mode.
View? View [get]
 Gets the view shared by all children in view mode.
ReadOnlyCollection< IDirectCompositeChild > Children [get]
 Gets the children owned by the composite.
MovementController Movement [get]
 Gets the movement controller used to move the composite anchor.
MovementSpace PositionSpace [get]
 Gets the coordinate space used by the movement controller.
bool Visible [get, set]
 Gets or sets the visibility of all descendants.
int ZOrder [get]
 Gets the composite Z-order.
Rectangle ScreenBounds [get]
 Gets the union of all visible descendants' screen-space bounds.
Rectangle WorldBounds [get]
 Gets the union of all visible descendants' world-space bounds.

Events

EventHandler< IDirectDrawable >? Disposing
 Occurs when the 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 movable composite that owns other movable direct drawables and keeps their positions relative to a shared anchor.

A composite may recursively contain other composites. Every child must use the same render surface, drawing mode, and target View or SceneLayer.

A child may belong to only one composite at a time. Cyclic parent/child relationships are rejected.

Definition at line 28 of file DirectComposite.cs.

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 that owns the composite.
modeThe coordinate mode used by the composite and all of its children.
anchorThe composite anchor, in mode-appropriate pixels.
nicknameAn optional diagnostic nickname.

Definition at line 63 of file DirectComposite.cs.

Member Function Documentation

◆ Add()

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

Adds a composite-compatible direct drawable as a child.

Parameters
childThe child to add.
keepCurrentOffsettrue to preserve the child's current offset from the composite anchor.
explicitLocalOffsetPxThe offset to use when keepCurrentOffset is false.
Returns
The current composite.
Exceptions
ArgumentExceptionThrown when the child uses another render surface, mode, view, or scene layer.
InvalidOperationExceptionThrown when the child already has another parent or would create a cycle.

Implements Gondwana.Drawing.Direct.IDirectCompositeContainer.

Reimplemented in Gondwana.Widgets.ContainerWidget, and Gondwana.Widgets.Layout.StackPanelWidget.

Definition at line 234 of file DirectComposite.cs.

◆ Clear()

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

Removes every child without disposing them.

Returns
The current composite.

Implements Gondwana.Drawing.Direct.IDirectCompositeContainer.

Reimplemented in Gondwana.Widgets.ContainerWidget, and Gondwana.Widgets.Layout.StackPanelWidget.

Definition at line 302 of file DirectComposite.cs.

◆ Dispose()

◆ Draw()

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

Performs no direct rendering because descendants render independently.

Parameters
backbufferThe backbuffer to draw to (not used).
destRectScreenThe destination rectangle in screen coordinates (not used).

Implements Gondwana.Drawing.IDrawable.

Definition at line 461 of file DirectComposite.cs.

◆ FadeIn()

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

Fades every descendant to full opacity.

Parameters
durationSecThe animation duration in seconds.
Returns
The current composite.

◆ FadeOut()

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

Fades every descendant to zero opacity.

Parameters
durationSecThe animation duration in seconds.
Returns
The current composite.

◆ FadeTo()

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

Fades every descendant to the requested opacity.

Parameters
targetOpacityThe target opacity.
durationSecThe animation duration in seconds.
Returns
The current composite.

Implements Gondwana.Drawing.Direct.IDirectCompositeChild.

Definition at line 389 of file DirectComposite.cs.

◆ GetDrawLocationScreen()

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

Gets the union of all visible descendants as projected through a view.

Parameters
viewThe view used for projection.
Returns
The projected screen-space bounds.

Implements Gondwana.Drawing.IDrawable.

Definition at line 416 of file DirectComposite.cs.

◆ GetPosition()

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

Gets the current composite anchor.

Returns
The sprite position in scene-layer grid coordinates.

Implements Gondwana.Physics.Movement.IMovable.

◆ OnChildAdded()

virtual void Gondwana.Drawing.Direct.DirectComposite.OnChildAdded ( IDirectCompositeChild child)
protectedvirtual

Called after a child has been successfully added.

Parameters
childThe child that was added.

Overrides should perform only non-throwing bookkeeping. Derived types that need additional validation should override Add, perform that validation before calling the base implementation, and then allow this callback to perform the resulting bookkeeping.

Reimplemented in Gondwana.Widgets.ContainerWidget.

Definition at line 560 of file DirectComposite.cs.

◆ OnChildRemoved()

virtual void Gondwana.Drawing.Direct.DirectComposite.OnChildRemoved ( IDirectCompositeChild child)
protectedvirtual

Called after a child has been removed from the composite.

Parameters
childThe child that was removed.

Reimplemented in Gondwana.Widgets.ContainerWidget.

Definition at line 568 of file DirectComposite.cs.

◆ Remove()

virtual DirectComposite Gondwana.Drawing.Direct.DirectComposite.Remove ( IDirectCompositeChild child)
virtual

Removes a child without disposing it.

Parameters
childThe child to detach.
Returns
The current composite.

Implements Gondwana.Drawing.Direct.IDirectCompositeContainer.

Reimplemented in Gondwana.Widgets.ContainerWidget, and Gondwana.Widgets.Layout.StackPanelWidget.

Definition at line 280 of file DirectComposite.cs.

◆ SetIsVisible()

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

Applies one visibility value to every descendant.

Parameters
visibleThe visibility value to apply.
Returns
The current composite.

Implements Gondwana.Drawing.Direct.IDirectCompositeChild.

Definition at line 377 of file DirectComposite.cs.

◆ SetLocalOffset()

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

Changes one child's local offset and reapplies its position.

Parameters
childThe child whose offset should change.
newLocalOffsetPxThe new offset from the composite anchor.
Returns
The current composite.

Definition at line 330 of file DirectComposite.cs.

◆ SetOpacity()

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

Applies one opacity to every descendant.

Parameters
opacityThe opacity in the range 0 through 1.
Returns
The current composite.

Implements Gondwana.Drawing.Direct.IDirectCompositeChild.

Definition at line 364 of file DirectComposite.cs.

◆ SetPosition() [1/2]

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

Sets the composite anchor and repositions all children from their stored offsets.

Parameters
xThe new X coordinate.
yThe new Y coordinate.
Returns
The current composite.

Definition at line 198 of file DirectComposite.cs.

◆ SetPosition() [2/2]

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

Sets the composite anchor and repositions all children from their stored offsets.

Parameters
positionThe new anchor, in mode-appropriate pixels.

Implements Gondwana.Physics.Movement.IMovable.

Definition at line 187 of file DirectComposite.cs.

◆ SetZOrder()

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

Applies one Z-order to every descendant.

Parameters
zOrderThe Z-order to apply.
Returns
The current composite.

Implements Gondwana.Drawing.Direct.IDirectCompositeChild.

Definition at line 351 of file DirectComposite.cs.

◆ Update()

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

Advances composite movement.

Parameters
tickThe current engine tick.

This method uses the tick to calculate elapsed time and advance the movement controller. If the tick is less than or equal to the last processed tick, no update occurs.

Implements Gondwana.Drawing.Direct.IDirectDrawable.

Reimplemented in Gondwana.Widgets.Overlays.PopupWidget, and Gondwana.Widgets.Overlays.ToastWidget.

Definition at line 471 of file DirectComposite.cs.

Property Documentation

◆ Children

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

Gets the children owned by the composite.

Implements IDirectCompositeContainer.Children.

Implements Gondwana.Drawing.Direct.IDirectCompositeContainer.

Definition at line 129 of file DirectComposite.cs.

◆ Id

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

Gets the unique identifier of the composite.

Implements Gondwana.Drawing.IDrawable.

Definition at line 88 of file DirectComposite.cs.

◆ Mode

DirectDrawingMode Gondwana.Drawing.Direct.DirectComposite.Mode
get

Gets the coordinate mode shared by the composite and its children.

Implements Gondwana.Drawing.Direct.IDirectDrawable.

Definition at line 103 of file DirectComposite.cs.

◆ Movement

MovementController Gondwana.Drawing.Direct.DirectComposite.Movement
get

Gets the movement controller used to move the composite anchor.

Definition at line 134 of file DirectComposite.cs.

◆ Nickname

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

Gets the optional diagnostic nickname of the composite.

Implements Gondwana.Drawing.IDrawable.

Definition at line 93 of file DirectComposite.cs.

◆ PositionSpace

MovementSpace Gondwana.Drawing.Direct.DirectComposite.PositionSpace
get

Gets the coordinate space used by the movement controller.

Implements Gondwana.Physics.Movement.IMovable.

Definition at line 139 of file DirectComposite.cs.

◆ RenderSurfaceHost

RenderSurfaceHostBase Gondwana.Drawing.Direct.DirectComposite.RenderSurfaceHost
get

Gets the render surface host shared by the composite and its children.

Implements Gondwana.Drawing.Direct.IDirectDrawable.

Definition at line 98 of file DirectComposite.cs.

◆ SceneLayer

SceneLayer? Gondwana.Drawing.Direct.DirectComposite.SceneLayer
get

Gets the scene layer shared by all children in scene-layer mode.

The first child establishes this value. It is cleared when the composite becomes empty.

Implements Gondwana.Drawing.Direct.IDirectCompositeChild.

Definition at line 112 of file DirectComposite.cs.

◆ ScreenBounds

Rectangle Gondwana.Drawing.Direct.DirectComposite.ScreenBounds
get

Gets the union of all visible descendants' screen-space bounds.

Implements Gondwana.Drawing.Direct.IDirectDrawable.

Definition at line 166 of file DirectComposite.cs.

◆ View

View? Gondwana.Drawing.Direct.DirectComposite.View
get

Gets the view shared by all children in view mode.

The first child establishes this value. It is cleared when the composite becomes empty.

Implements Gondwana.Drawing.Direct.IDirectCompositeChild.

Definition at line 121 of file DirectComposite.cs.

◆ Visible

bool Gondwana.Drawing.Direct.DirectComposite.Visible
getset

Gets or sets the visibility of all descendants.

Implements Gondwana.Drawing.IDrawable.

Definition at line 144 of file DirectComposite.cs.

◆ WorldBounds

Rectangle Gondwana.Drawing.Direct.DirectComposite.WorldBounds
get

Gets the union of all visible descendants' world-space bounds.

Implements Gondwana.Drawing.Direct.IDirectDrawable.

Definition at line 171 of file DirectComposite.cs.

◆ ZOrder

int Gondwana.Drawing.Direct.DirectComposite.ZOrder
get

Gets the composite Z-order.

A composite is not rendered directly; descendants retain their individual Z-orders. Use SetZOrder to update all descendants.

Implements Gondwana.Drawing.IDrawable.

Definition at line 161 of file DirectComposite.cs.

Event Documentation

◆ Disposing

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

Occurs when the composite is being disposed.

Definition at line 50 of file DirectComposite.cs.