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.Movement.MovementController Class Referencesealed

Central controller responsible for managing all movement modes for a single IMovable object. Combines three systems:

  • Follow – hard/soft following of pixel or grid targets.
  • Scripted – tween or constant-speed motion toward a destination.
  • Integrated – free physics-style integration (velocity and acceleration).

The controller automatically selects the correct behavior each frame internally through AdvanceMovement(float). More...

Inheritance diagram for Gondwana.Movement.MovementController:

Public Member Functions

void StopAllMovement ()
 Immediately stops all forms of movement — follow, scripted, and integrated. Cancels active tweens, clears velocity and acceleration, and halts motion this frame.
void Dispose ()
 Releases resources and detaches all event handlers.
void FollowPixelSoft (Func< Vector2 > getPixelPos, float speed, float snap=0.5f, Vector2 offsetPx=default)
 Start following a pixel-space target at a constant speed. The speed and snap units are interpreted in the follower's position space:

  • Pixel follower → pixels/sec and pixels
  • Grid follower → tiles/sec and tiles

void FollowPixelSoft (Func< Vector2 > getPixelPos, float durationSec, Func< float, float >? easing=null, float snap=0.5f, Vector2 offsetPx=default)
 Start following a pixel-space target using a duration-based tween (easing). When easing is active, speed fields are ignored. The snap value is interpreted in the follower's space at runtime:

  • Pixel follower uses snap as pixels.
  • Grid follower treats snap as tiles (internally mapped).

void FollowPixelSoft (Func< Vector2 > getPixelPos, float durationSec, EasingKind easingKind, float snap=0.5f, Vector2 offsetPx=default)
 Start following a pixel-space target using a duration-based tween (easing). When easing is active, speed fields are ignored. The snap value is interpreted in the follower's space at runtime:

  • Pixel follower uses snap as pixels.
  • Grid follower treats snap as tiles (internally mapped).

void FollowPixelHard (Func< Vector2 > getPixelPos, Vector2 offsetPx=default)
 Hard-follow a pixel-space target. The follower snaps directly to the target every update (no tweening, no speed). An optional pixel offset is applied only for pixel-space followers.
void FollowTileSoft (IMovableOnSceneLayer tileTarget, float speedTilesPerSec, float snapTiles=0.25f, Vector2 gridOffset=default, Vector2 pixelOffset=default)
 Start following a grid (tile) target at a constant speed (tiles/sec). If the follower is pixel-space, an additional pixel offset can be applied after the grid→pixel conversion.
void FollowTileSoft (IMovableOnSceneLayer tileTarget, float durationSec, Func< float, float >? easing=null, float snap=0.5f, Vector2 gridOffset=default, Vector2 pixelOffset=default)
 Start following a grid (tile) target using a duration-based tween (easing). When easing is active, speed fields are ignored. Snap tolerance is stored for both pixel and tile spaces; the runtime branch uses the follower's space.
void FollowTileSoft (IMovableOnSceneLayer tileTarget, float durationSec, EasingKind easingKind, float snap=0.5f, Vector2 gridOffset=default, Vector2 pixelOffset=default)
 Convenience overload of FollowTileSoft(IMovableOnSceneLayer, float, Func<float, float>?, float, Vector2, Vector2) that specifies the easing curve via EasingKind.
void FollowTileHard (IMovableOnSceneLayer tileTarget, Vector2 gridOffset=default, Vector2 pixelOffset=default)
 Hard-follow a grid (tile) target. The follower snaps directly to the target grid coordinate each update (no tweening, no speed). If the follower is pixel-space, pixelOffset is applied after grid→pixel conversion.
void Unfollow ()
 Stop following any target and clear all follow/tween state (targets, speeds, offsets, easing, hard mode). Any in-flight scripted/tweened movement is cancelled immediately.
void SetVelocity (Vector2 velocity)
 Sets the velocity of the object.
void SetAcceleration (Vector2 acceleration)
 Sets the acceleration of the object.
void SetMaxSpeed (float? maxSpeed)
 Sets the maximum speed for the current state. Only applies to integrated movement.
void SetLinearDamping (float dampingPerSec)
 Sets the linear damping value, which determines the rate at which linear motion is reduced over time.
void MoveTo (Vector2 target, float durationSec, Func< float, float >? easing=null, float snapEpsilon=0.5f)
 Begins a scripted tween toward the specified target position over a fixed duration. This method interpolates linearly or with an optional easing function from the mover’s current position to the target, automatically cancelling any existing scripted or physics-based movement.
void MoveTo (Vector2 target, float seconds, EasingKind easingKind, float snapEpsilon=0.5f)
 Begins a scripted tween toward the specified target position over a fixed duration, using a predefined EasingKind curve. This overload is a convenience wrapper around MoveTo(Vector2, float, Func<float, float>?, float).
void MoveBy (Vector2 delta, float durationSec, Func< float, float >? easing=null, float snapEpsilon=0.5f)
 Scripted relative motion by a delta over a fixed duration (with optional easing). Interprets delta in the mover's PositionSpace (Grid or Pixel).
void MoveBy (Vector2 delta, float durationSec, EasingKind easingKind, float snapEpsilon=0.5f)
 Scripted relative motion by a delta over a fixed duration using an easing preset.
void MoveBy (Vector2 delta, float speedPerSec, float snapEpsilon=0.5f)
 Scripted relative motion by a delta at a constant speed (units/sec in the mover's PositionSpace).
void MoveToward (Vector2 target, float speedPerSec, float snapEpsilon=0.5f)
 Begins a scripted motion toward the target position at a constant speed. Unlike MoveTo(Vector2, float, Func<float, float>?, float), this motion continues each frame until the target is reached or cancelled, rather than running for a fixed duration.
void CancelScript ()
 Cancels any active scripted movement (tween or constant-speed) and clears the current script state. Raises ScriptedMovementStopped if a script was active.

Properties

MovementState MovementState [get]
 Gets the current MovementState containing velocity, acceleration, and motion flags for the controlled object.
bool IsFollowing [get]
 Indicates whether the controller is currently engaged in a follow behavior. Returns true if a pixel or grid target is set, or if hard follow is active.
bool IsScripted [get]
 Indicates whether a scripted movement (tween or MoveToward) is currently active.
bool IsIntegratedActive [get]
 Indicates whether physics-style integration is currently active. Returns true when the controller is not following or scripted, and MovementState.HasMotion is true.
bool WrapX = false [get, set]
 Enables or disables horizontal world wrapping. When enabled, movement crossing the left/right edges wraps the IMovable to the opposite side. Only meaningful for Grid space; ignored for Pixel space.
bool WrapY = false [get, set]
 Enables or disables vertical world wrapping. When enabled, movement crossing the top/bottom edges wraps the IMovable to the opposite side. Only meaningful for Grid space; ignored for Pixel space.

Events

Action< ScriptedMovement >? ScriptedMovementStarted
 Raised when a scripted movement (tween or MoveToward) begins. Subscribers are notified exactly once per script initialization.
Action< ScriptedMovement >? ScriptedMovementStopped
 Raised when a scripted movement (tween or MoveToward) completes or is explicitly cancelled. Subscribers are notified exactly once per script termination.

Detailed Description

Central controller responsible for managing all movement modes for a single IMovable object. Combines three systems:

  • Follow – hard/soft following of pixel or grid targets.
  • Scripted – tween or constant-speed motion toward a destination.
  • Integrated – free physics-style integration (velocity and acceleration).

The controller automatically selects the correct behavior each frame internally through AdvanceMovement(float).

Member Function Documentation

◆ CancelScript()

void Gondwana.Movement.MovementController.CancelScript ( )

Cancels any active scripted movement (tween or constant-speed) and clears the current script state. Raises ScriptedMovementStopped if a script was active.

◆ Dispose()

void Gondwana.Movement.MovementController.Dispose ( )

Releases resources and detaches all event handlers.

◆ FollowPixelHard()

void Gondwana.Movement.MovementController.FollowPixelHard ( Func< Vector2 > getPixelPos,
Vector2 offsetPx = default )

Hard-follow a pixel-space target. The follower snaps directly to the target every update (no tweening, no speed). An optional pixel offset is applied only for pixel-space followers.

Parameters
getPixelPosDelegate that returns the current target position in pixels each frame.
offsetPxOptional additional pixel offset applied only when the follower is in pixel space.
Exceptions
ArgumentNullExceptionThrown when getPixelPos is null.

◆ FollowPixelSoft() [1/3]

void Gondwana.Movement.MovementController.FollowPixelSoft ( Func< Vector2 > getPixelPos,
float durationSec,
EasingKind easingKind,
float snap = 0::5f,
Vector2 offsetPx = default )

Start following a pixel-space target using a duration-based tween (easing). When easing is active, speed fields are ignored. The snap value is interpreted in the follower's space at runtime:

  • Pixel follower uses snap as pixels.
  • Grid follower treats snap as tiles (internally mapped).

Parameters
getPixelPosDelegate that returns the current target position in pixels each frame.
durationSecTween duration in seconds. Must be > 0.
easingKindNamed easing preset.
snapArrival tolerance; interpreted in the follower's space at runtime.
offsetPxOptional additional pixel offset for pixel-space followers.
Exceptions
ArgumentNullExceptionThrown when getPixelPos is null.
ArgumentOutOfRangeExceptionThrown when durationSec ≤ 0.

◆ FollowPixelSoft() [2/3]

void Gondwana.Movement.MovementController.FollowPixelSoft ( Func< Vector2 > getPixelPos,
float durationSec,
Func< float, float >? easing = null,
float snap = 0::5f,
Vector2 offsetPx = default )

Start following a pixel-space target using a duration-based tween (easing). When easing is active, speed fields are ignored. The snap value is interpreted in the follower's space at runtime:

  • Pixel follower uses snap as pixels.
  • Grid follower treats snap as tiles (internally mapped).

Parameters
getPixelPosDelegate that returns the current target position in pixels each frame.
durationSecTween duration in seconds. Must be > 0.
easingOptional easing function in the range [0,1]→[0,1]. If null, linear easing is used.
snapArrival tolerance; interpreted in the follower's space at runtime (pixels for pixel followers, tiles for grid followers).
offsetPxOptional additional pixel offset when the follower is pixel-space (ignored for grid followers).
Exceptions
ArgumentNullExceptionThrown when getPixelPos is null.
ArgumentOutOfRangeExceptionThrown when durationSec ≤ 0.

◆ FollowPixelSoft() [3/3]

void Gondwana.Movement.MovementController.FollowPixelSoft ( Func< Vector2 > getPixelPos,
float speed,
float snap = 0::5f,
Vector2 offsetPx = default )

Start following a pixel-space target at a constant speed. The speed and snap units are interpreted in the follower's position space:

  • Pixel follower → pixels/sec and pixels
  • Grid follower → tiles/sec and tiles

Parameters
getPixelPosDelegate that returns the current target position in pixels (screen/world pixels) each frame.
speedFollow speed (pixels/sec for pixel followers; tiles/sec for grid followers). Must be > 0.
snapSnap/arrival tolerance (pixels for pixel followers; tiles for grid followers). Values < 0 are clamped to 0.
offsetPxOptional additional pixel offset applied only when the follower is in pixel space (ignored for grid followers).
Exceptions
ArgumentNullExceptionThrown when getPixelPos is null.
ArgumentOutOfRangeExceptionThrown when speed ≤ 0.

◆ FollowTileHard()

void Gondwana.Movement.MovementController.FollowTileHard ( IMovableOnSceneLayer tileTarget,
Vector2 gridOffset = default,
Vector2 pixelOffset = default )

Hard-follow a grid (tile) target. The follower snaps directly to the target grid coordinate each update (no tweening, no speed). If the follower is pixel-space, pixelOffset is applied after grid→pixel conversion.

Parameters
tileTargetThe grid-anchored target to follow.
gridOffsetOptional tile offset applied to the target's grid coordinate.
pixelOffsetOptional pixel offset applied only when the follower is pixel-space.
Exceptions
ArgumentNullExceptionThrown when tileTarget is null.

◆ FollowTileSoft() [1/3]

void Gondwana.Movement.MovementController.FollowTileSoft ( IMovableOnSceneLayer tileTarget,
float durationSec,
EasingKind easingKind,
float snap = 0::5f,
Vector2 gridOffset = default,
Vector2 pixelOffset = default )

Convenience overload of FollowTileSoft(IMovableOnSceneLayer, float, Func<float, float>?, float, Vector2, Vector2) that specifies the easing curve via EasingKind.

Parameters
tileTargetThe grid-anchored target to follow.
durationSecTween duration in seconds. Must be > 0.
easingKindNamed easing preset.
snapArrival tolerance; applied in the follower's space at runtime.
gridOffsetOptional tile offset added to the target's grid coordinate.
pixelOffsetOptional pixel offset applied only when the follower is pixel-space.
Exceptions
ArgumentNullExceptionThrown when tileTarget is null.
ArgumentOutOfRangeExceptionThrown when durationSec ≤ 0.

◆ FollowTileSoft() [2/3]

void Gondwana.Movement.MovementController.FollowTileSoft ( IMovableOnSceneLayer tileTarget,
float durationSec,
Func< float, float >? easing = null,
float snap = 0::5f,
Vector2 gridOffset = default,
Vector2 pixelOffset = default )

Start following a grid (tile) target using a duration-based tween (easing). When easing is active, speed fields are ignored. Snap tolerance is stored for both pixel and tile spaces; the runtime branch uses the follower's space.

Parameters
tileTargetThe grid-anchored target to follow.
durationSecTween duration in seconds. Must be > 0.
easingOptional easing function in the range [0,1]→[0,1]. If null, linear easing is used.
snapArrival tolerance; applied in the follower's space at runtime.
gridOffsetOptional tile offset added to the target's grid coordinate.
pixelOffsetOptional pixel offset applied only when the follower is pixel-space.
Exceptions
ArgumentNullExceptionThrown when tileTarget is null.
ArgumentOutOfRangeExceptionThrown when durationSec ≤ 0.

◆ FollowTileSoft() [3/3]

void Gondwana.Movement.MovementController.FollowTileSoft ( IMovableOnSceneLayer tileTarget,
float speedTilesPerSec,
float snapTiles = 0::25f,
Vector2 gridOffset = default,
Vector2 pixelOffset = default )

Start following a grid (tile) target at a constant speed (tiles/sec). If the follower is pixel-space, an additional pixel offset can be applied after the grid→pixel conversion.

Parameters
tileTargetThe grid-anchored target to follow (must expose SceneLayer and grid position).
speedTilesPerSecFollow speed in tiles per second. Must be > 0.
snapTilesTile-space arrival tolerance; values < 0 are clamped to 0.
gridOffsetOptional tile offset applied to the target's grid coordinate before conversion.
pixelOffsetOptional pixel offset applied only when the follower is pixel-space.
Exceptions
ArgumentNullExceptionThrown when tileTarget is null.
ArgumentOutOfRangeExceptionThrown when speedTilesPerSec ≤ 0.

◆ MoveBy() [1/3]

void Gondwana.Movement.MovementController.MoveBy ( Vector2 delta,
float durationSec,
EasingKind easingKind,
float snapEpsilon = 0::5f )

Scripted relative motion by a delta over a fixed duration using an easing preset.

Parameters
deltaThe offset by which to move, relative to the mover’s current position. Units are in the mover’s PositionSpace (grid cells or pixels).
durationSecThe total duration of the motion in seconds.
easingKindThe predefined easing curve (e.g., EaseInOutQuad, EaseOutCubic) to apply during the motion.
snapEpsilonThe distance threshold (in PositionSpace units) at which the motion will snap to the goal and stop.

◆ MoveBy() [2/3]

void Gondwana.Movement.MovementController.MoveBy ( Vector2 delta,
float durationSec,
Func< float, float >? easing = null,
float snapEpsilon = 0::5f )

Scripted relative motion by a delta over a fixed duration (with optional easing). Interprets delta in the mover's PositionSpace (Grid or Pixel).

Parameters
deltaThe offset by which to move, relative to the mover’s current position. Units are in the mover’s PositionSpace (grid cells or pixels).
durationSecThe total duration of the motion in seconds.
easingOptional easing function that determines interpolation over time. If null, the motion is linear.
snapEpsilonThe distance threshold (in PositionSpace units) at which the motion will snap to the goal and stop.

◆ MoveBy() [3/3]

void Gondwana.Movement.MovementController.MoveBy ( Vector2 delta,
float speedPerSec,
float snapEpsilon = 0::5f )

Scripted relative motion by a delta at a constant speed (units/sec in the mover's PositionSpace).

Parameters
deltaThe offset by which to move, relative to the mover’s current position. Units are in the mover’s PositionSpace (grid cells or pixels).
speedPerSecThe speed of movement in PositionSpace units per second (e.g., pixels/sec or tiles/sec).
snapEpsilonThe distance threshold (in PositionSpace units) at which the motion will snap to the goal and stop.

◆ MoveTo() [1/2]

void Gondwana.Movement.MovementController.MoveTo ( Vector2 target,
float durationSec,
Func< float, float >? easing = null,
float snapEpsilon = 0::5f )

Begins a scripted tween toward the specified target position over a fixed duration. This method interpolates linearly or with an optional easing function from the mover’s current position to the target, automatically cancelling any existing scripted or physics-based movement.

Parameters
targetThe absolute destination position.
durationSecThe total tween duration in seconds. Values less than 0 are clamped to 0.
easingOptional easing function mapping normalized time [0,1] → [0,1]. If null, linear easing is used.
snapEpsilonThe arrival tolerance. When the mover is within this distance of the target, the tween completes early. Values less than 0 are clamped to 0.

◆ MoveTo() [2/2]

void Gondwana.Movement.MovementController.MoveTo ( Vector2 target,
float seconds,
EasingKind easingKind,
float snapEpsilon = 0::5f )

Begins a scripted tween toward the specified target position over a fixed duration, using a predefined EasingKind curve. This overload is a convenience wrapper around MoveTo(Vector2, float, Func<float, float>?, float).

Parameters
targetThe absolute destination position.
secondsThe tween duration in seconds. Values less than 0 are clamped to 0.
easingKindThe built-in easing preset to apply.
snapEpsilonThe arrival tolerance. When the mover is within this distance of the target, the tween completes early.

◆ MoveToward()

void Gondwana.Movement.MovementController.MoveToward ( Vector2 target,
float speedPerSec,
float snapEpsilon = 0::5f )

Begins a scripted motion toward the target position at a constant speed. Unlike MoveTo(Vector2, float, Func<float, float>?, float), this motion continues each frame until the target is reached or cancelled, rather than running for a fixed duration.

Parameters
targetThe absolute destination position.
speedPerSecThe movement speed per second. Values less than 0 are clamped to 0.
snapEpsilonThe arrival tolerance. When the mover is within this distance of the target, motion completes early. Values less than 0 are clamped to 0.

◆ SetAcceleration()

void Gondwana.Movement.MovementController.SetAcceleration ( Vector2 acceleration)

Sets the acceleration of the object.

This method cancels any ongoing scripts before updating the acceleration.

Parameters
accelerationThe new acceleration to apply, represented as a Vector2

◆ SetLinearDamping()

void Gondwana.Movement.MovementController.SetLinearDamping ( float dampingPerSec)

Sets the linear damping value, which determines the rate at which linear motion is reduced over time.

Linear damping is used to simulate the gradual reduction of velocity in a system, such as due to friction or drag. If the specified value is negative, it will be clamped to zero.

Parameters
dampingPerSecThe damping value per second. Must be a non-negative value.

◆ SetMaxSpeed()

void Gondwana.Movement.MovementController.SetMaxSpeed ( float? maxSpeed)

Sets the maximum speed for the current state. Only applies to integrated movement.

Parameters
maxSpeedThe maximum speed to set, in units appropriate to the context. Specify null to remove the speed limit.

◆ SetVelocity()

void Gondwana.Movement.MovementController.SetVelocity ( Vector2 velocity)

Sets the velocity of the object.

This method cancels any ongoing scripts before applying the new velocity.

Parameters
velocityThe new velocity to apply, represented as a Vector2.

◆ StopAllMovement()

void Gondwana.Movement.MovementController.StopAllMovement ( )

Immediately stops all forms of movement — follow, scripted, and integrated. Cancels active tweens, clears velocity and acceleration, and halts motion this frame.

◆ Unfollow()

void Gondwana.Movement.MovementController.Unfollow ( )

Stop following any target and clear all follow/tween state (targets, speeds, offsets, easing, hard mode). Any in-flight scripted/tweened movement is cancelled immediately.

Property Documentation

◆ IsFollowing

bool Gondwana.Movement.MovementController.IsFollowing
get

Indicates whether the controller is currently engaged in a follow behavior. Returns true if a pixel or grid target is set, or if hard follow is active.

◆ IsIntegratedActive

bool Gondwana.Movement.MovementController.IsIntegratedActive
get

Indicates whether physics-style integration is currently active. Returns true when the controller is not following or scripted, and MovementState.HasMotion is true.

◆ IsScripted

bool Gondwana.Movement.MovementController.IsScripted
get

Indicates whether a scripted movement (tween or MoveToward) is currently active.

◆ MovementState

MovementState Gondwana.Movement.MovementController.MovementState
get

Gets the current MovementState containing velocity, acceleration, and motion flags for the controlled object.

◆ WrapX

bool Gondwana.Movement.MovementController.WrapX = false
getset

Enables or disables horizontal world wrapping. When enabled, movement crossing the left/right edges wraps the IMovable to the opposite side. Only meaningful for Grid space; ignored for Pixel space.

◆ WrapY

bool Gondwana.Movement.MovementController.WrapY = false
getset

Enables or disables vertical world wrapping. When enabled, movement crossing the top/bottom edges wraps the IMovable to the opposite side. Only meaningful for Grid space; ignored for Pixel space.

Event Documentation

◆ ScriptedMovementStarted

Action<ScriptedMovement>? Gondwana.Movement.MovementController.ScriptedMovementStarted

Raised when a scripted movement (tween or MoveToward) begins. Subscribers are notified exactly once per script initialization.

◆ ScriptedMovementStopped

Action<ScriptedMovement>? Gondwana.Movement.MovementController.ScriptedMovementStopped

Raised when a scripted movement (tween or MoveToward) completes or is explicitly cancelled. Subscribers are notified exactly once per script termination.