Table of Contents

Class UnitSystem

Namespace
AshesOfVelsingrad.systems
Assembly
Ashes of Velsingrad.dll

Base class for all units in the tactical grid-based system. Handles stats, movement, effects, and Godot integration.

[ScriptPath("res://scripts/systems/UnitSystem.cs")]
public abstract class UnitSystem : CharacterBody3D, IDisposable, IEffectTarget
Inheritance
GodotObject
Node
Node3D
CollisionObject3D
PhysicsBody3D
CharacterBody3D
UnitSystem
Implements
Derived
Inherited Members
CharacterBody3D.MoveAndSlide()
CharacterBody3D.ApplyFloorSnap()
CharacterBody3D.IsOnFloor()
CharacterBody3D.IsOnFloorOnly()
CharacterBody3D.IsOnCeiling()
CharacterBody3D.IsOnCeilingOnly()
CharacterBody3D.IsOnWall()
CharacterBody3D.IsOnWallOnly()
CharacterBody3D.GetFloorNormal()
CharacterBody3D.GetWallNormal()
CharacterBody3D.GetLastMotion()
CharacterBody3D.GetPositionDelta()
CharacterBody3D.GetRealVelocity()
CharacterBody3D.GetFloorAngle(Vector3?)
CharacterBody3D.GetPlatformVelocity()
CharacterBody3D.GetPlatformAngularVelocity()
CharacterBody3D.GetSlideCollisionCount()
CharacterBody3D.GetLastSlideCollision()
CharacterBody3D.InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)
CharacterBody3D.HasGodotClassMethod(in godot_string_name)
CharacterBody3D.HasGodotClassSignal(in godot_string_name)
CharacterBody3D.MotionMode
CharacterBody3D.UpDirection
CharacterBody3D.SlideOnCeiling
CharacterBody3D.Velocity
CharacterBody3D.MaxSlides
CharacterBody3D.WallMinSlideAngle
CharacterBody3D.FloorStopOnSlope
CharacterBody3D.FloorConstantSpeed
CharacterBody3D.FloorBlockOnWall
CharacterBody3D.FloorMaxAngle
CharacterBody3D.FloorSnapLength
CharacterBody3D.PlatformOnLeave
CharacterBody3D.PlatformFloorLayers
CharacterBody3D.PlatformWallLayers
CharacterBody3D.SafeMargin
PhysicsBody3D.GetGravity()
PhysicsBody3D.GetCollisionExceptions()
PhysicsBody3D.AddCollisionExceptionWith(Node)
PhysicsBody3D.RemoveCollisionExceptionWith(Node)
PhysicsBody3D.AxisLockLinearX
PhysicsBody3D.AxisLockLinearY
PhysicsBody3D.AxisLockLinearZ
PhysicsBody3D.AxisLockAngularX
PhysicsBody3D.AxisLockAngularY
PhysicsBody3D.AxisLockAngularZ
CollisionObject3D._MouseEnter()
CollisionObject3D._MouseExit()
CollisionObject3D.GetRid()
CollisionObject3D.CreateShapeOwner(GodotObject)
CollisionObject3D.GetShapeOwners()
CollisionObject3D.EmitSignalMouseEntered()
CollisionObject3D.EmitSignalMouseExited()
CollisionObject3D.DisableMode
CollisionObject3D.CollisionLayer
CollisionObject3D.CollisionMask
CollisionObject3D.CollisionPriority
CollisionObject3D.InputRayPickable
CollisionObject3D.InputCaptureOnDrag
CollisionObject3D.InputEvent
CollisionObject3D.MouseEntered
CollisionObject3D.MouseExited
Node3D.NotificationTransformChanged
Node3D.NotificationEnterWorld
Node3D.NotificationExitWorld
Node3D.NotificationVisibilityChanged
Node3D.NotificationLocalTransformChanged
Node3D.GetGlobalTransformInterpolated()
Node3D.GetParentNode3D()
Node3D.IsScaleDisabled()
Node3D.GetWorld3D()
Node3D.ForceUpdateTransform()
Node3D.UpdateGizmos()
Node3D.AddGizmo(Node3DGizmo)
Node3D.GetGizmos()
Node3D.ClearGizmos()
Node3D.ClearSubgizmoSelection()
Node3D.IsVisibleInTree()
Node3D.Show()
Node3D.Hide()
Node3D.IsLocalTransformNotificationEnabled()
Node3D.IsTransformNotificationEnabled()
Node3D.GlobalScale(Vector3)
Node3D.GlobalTranslate(Vector3)
Node3D.ScaleObjectLocal(Vector3)
Node3D.TranslateObjectLocal(Vector3)
Node3D.Translate(Vector3)
Node3D.Orthonormalize()
Node3D.SetIdentity()
Node3D.ToLocal(Vector3)
Node3D.ToGlobal(Vector3)
Node3D.EmitSignalVisibilityChanged()
Node3D.Transform
Node3D.GlobalTransform
Node3D.Position
Node3D.Rotation
Node3D.RotationDegrees
Node3D.Quaternion
Node3D.Basis
Node3D.Scale
Node3D.RotationEditMode
Node3D.RotationOrder
Node3D.TopLevel
Node3D.GlobalPosition
Node3D.GlobalBasis
Node3D.GlobalRotation
Node3D.GlobalRotationDegrees
Node3D.Visible
Node3D.VisibilityParent
Node3D.VisibilityChanged
Node.NotificationEnterTree
Node.NotificationExitTree
Node.NotificationMovedInParent
Node.NotificationReady
Node.NotificationPaused
Node.NotificationUnpaused
Node.NotificationPhysicsProcess
Node.NotificationProcess
Node.NotificationParented
Node.NotificationUnparented
Node.NotificationSceneInstantiated
Node.NotificationDragBegin
Node.NotificationDragEnd
Node.NotificationPathRenamed
Node.NotificationChildOrderChanged
Node.NotificationInternalProcess
Node.NotificationInternalPhysicsProcess
Node.NotificationPostEnterTree
Node.NotificationDisabled
Node.NotificationEnabled
Node.NotificationResetPhysicsInterpolation
Node.NotificationEditorPreSave
Node.NotificationEditorPostSave
Node.NotificationWMMouseEnter
Node.NotificationWMMouseExit
Node.NotificationWMWindowFocusIn
Node.NotificationWMWindowFocusOut
Node.NotificationWMCloseRequest
Node.NotificationWMGoBackRequest
Node.NotificationWMSizeChanged
Node.NotificationWMDpiChange
Node.NotificationVpMouseEnter
Node.NotificationVpMouseExit
Node.NotificationWMPositionChanged
Node.NotificationOsMemoryWarning
Node.NotificationTranslationChanged
Node.NotificationWMAbout
Node.NotificationCrash
Node.NotificationOsImeUpdate
Node.NotificationApplicationResumed
Node.NotificationApplicationPaused
Node.NotificationApplicationFocusIn
Node.NotificationApplicationFocusOut
Node.NotificationTextServerChanged
Node.NotificationAccessibilityUpdate
Node.NotificationAccessibilityInvalidate
Node.GetNode<T>(NodePath)
Node.GetNodeOrNull<T>(NodePath)
Node.GetOwner<T>()
Node.GetOwnerOrNull<T>()
Node.GetParent<T>()
Node.GetParentOrNull<T>()
Node._EnterTree()
Node._GetAccessibilityConfigurationWarnings()
Node._GetConfigurationWarnings()
Node._GetFocusedAccessibilityElement()
Node._Input(InputEvent)
Node._ShortcutInput(InputEvent)
Node._UnhandledInput(InputEvent)
Node._UnhandledKeyInput(InputEvent)
Node.PrintOrphanNodes()
Node.GetOrphanNodeIds()
Node.RemoveChild(Node)
Node.HasNode(NodePath)
Node.GetNode(NodePath)
Node.GetNodeOrNull(NodePath)
Node.GetParent()
Node.HasNodeAndResource(NodePath)
Node.GetNodeAndResource(NodePath)
Node.IsInsideTree()
Node.IsPartOfEditedScene()
Node.IsAncestorOf(Node)
Node.IsGreaterThan(Node)
Node.GetPath()
Node.RemoveFromGroup(StringName)
Node.IsInGroup(StringName)
Node.GetGroups()
Node.PrintTree()
Node.PrintTreePretty()
Node.GetTreeString()
Node.GetTreeStringPretty()
Node.GetPhysicsProcessDeltaTime()
Node.IsPhysicsProcessing()
Node.GetProcessDeltaTime()
Node.IsProcessing()
Node.IsProcessingInput()
Node.IsProcessingShortcutInput()
Node.IsProcessingUnhandledInput()
Node.IsProcessingUnhandledKeyInput()
Node.CanProcess()
Node.QueueAccessibilityUpdate()
Node.GetAccessibilityElement()
Node.IsDisplayedFolded()
Node.IsProcessingInternal()
Node.IsPhysicsProcessingInternal()
Node.IsPhysicsInterpolated()
Node.IsPhysicsInterpolatedAndEnabled()
Node.ResetPhysicsInterpolation()
Node.CanAutoTranslate()
Node.SetTranslationDomainInherited()
Node.GetWindow()
Node.GetLastExclusiveWindow()
Node.GetTree()
Node.CreateTween()
Node.GetSceneInstanceLoadPlaceholder()
Node.IsEditableInstance(Node)
Node.GetViewport()
Node.QueueFree()
Node.RequestReady()
Node.IsNodeReady()
Node.GetMultiplayerAuthority()
Node.IsMultiplayerAuthority()
Node.RpcConfig(StringName, Variant)
Node.GetNodeRpcConfig()
Node.Rpc(StringName, params Variant[])
Node.UpdateConfigurationWarnings()
Node.CallDeferredThreadGroup(StringName, params Variant[])
Node.SetDeferredThreadGroup(StringName, Variant)
Node.CallThreadSafe(StringName, params Variant[])
Node.SetThreadSafe(StringName, Variant)
Node.EmitSignalReady()
Node.EmitSignalRenamed()
Node.EmitSignalTreeEntered()
Node.EmitSignalTreeExiting()
Node.EmitSignalTreeExited()
Node.EmitSignalChildEnteredTree(Node)
Node.EmitSignalChildExitingTree(Node)
Node.EmitSignalChildOrderChanged()
Node.EmitSignalReplacingBy(Node)
Node.EmitSignalEditorDescriptionChanged(Node)
Node.EmitSignalEditorStateChanged()
Node.Name
Node.UniqueNameInOwner
Node.SceneFilePath
Node.Owner
Node.Multiplayer
Node.ProcessMode
Node.ProcessPriority
Node.ProcessPhysicsPriority
Node.ProcessThreadGroup
Node.ProcessThreadGroupOrder
Node.ProcessThreadMessages
Node.PhysicsInterpolationMode
Node.AutoTranslateMode
Node.EditorDescription
Node.Ready
Node.Renamed
Node.TreeEntered
Node.TreeExiting
Node.TreeExited
Node.ChildEnteredTree
Node.ChildExitingTree
Node.ChildOrderChanged
Node.ReplacingBy
Node.EditorDescriptionChanged
Node.EditorStateChanged
GodotObject.NotificationPostinitialize
GodotObject.NotificationPredelete
GodotObject.NotificationExtensionReloaded
GodotObject.IsInstanceValid(GodotObject)
GodotObject.WeakRef(GodotObject)
GodotObject.Dispose()
GodotObject.ToString()
GodotObject.ToSignal(GodotObject, StringName)
GodotObject._Get(StringName)
GodotObject._GetPropertyList()
GodotObject._IterGet(Variant)
GodotObject._IterInit(Array)
GodotObject._IterNext(Array)
GodotObject._PropertyCanRevert(StringName)
GodotObject._PropertyGetRevert(StringName)
GodotObject._Set(StringName, Variant)
GodotObject._ValidateProperty(Dictionary)
GodotObject.Free()
GodotObject.GetClass()
GodotObject.Set(StringName, Variant)
GodotObject.Get(StringName)
GodotObject.SetIndexed(NodePath, Variant)
GodotObject.GetIndexed(NodePath)
GodotObject.GetPropertyList()
GodotObject.GetMethodList()
GodotObject.PropertyCanRevert(StringName)
GodotObject.PropertyGetRevert(StringName)
GodotObject.GetInstanceId()
GodotObject.SetScript(Variant)
GodotObject.GetScript()
GodotObject.SetMeta(StringName, Variant)
GodotObject.RemoveMeta(StringName)
GodotObject.GetMeta(StringName, Variant)
GodotObject.HasMeta(StringName)
GodotObject.GetMetaList()
GodotObject.HasUserSignal(StringName)
GodotObject.RemoveUserSignal(StringName)
GodotObject.EmitSignal(StringName, params Variant[])
GodotObject.Call(StringName, params Variant[])
GodotObject.CallDeferred(StringName, params Variant[])
GodotObject.SetDeferred(StringName, Variant)
GodotObject.Callv(StringName, Array)
GodotObject.HasMethod(StringName)
GodotObject.GetMethodArgumentCount(StringName)
GodotObject.HasSignal(StringName)
GodotObject.GetSignalList()
GodotObject.GetSignalConnectionList(StringName)
GodotObject.GetIncomingConnections()
GodotObject.Disconnect(StringName, Callable)
GodotObject.IsConnected(StringName, Callable)
GodotObject.HasConnections(StringName)
GodotObject.IsBlockingSignals()
GodotObject.NotifyPropertyListChanged()
GodotObject.CanTranslateMessages()
GodotObject.Tr(StringName, StringName)
GodotObject.GetTranslationDomain()
GodotObject.SetTranslationDomain(StringName)
GodotObject.IsQueuedForDeletion()
GodotObject.CancelFree()
GodotObject.EmitSignalScriptChanged()
GodotObject.EmitSignalPropertyListChanged()
GodotObject.NativeInstance
GodotObject.ScriptChanged
GodotObject.PropertyListChanged

Remarks

This class provides fundamental behavior for all combat units, including:

  • Base stats (HP, attack, defense, etc.)
  • Turn logic (HasPlayed)
  • Movement logic (BFS pathfinding in 3D)
  • Integration with MapSystem and StatusEffect

Fields

Gravity

[Export(PropertyHint.None, "")]
public float Gravity

Field Value

float

Properties

ActiveSkills

List of active (usable) skills available to this unit.

public List<SkillSystem> ActiveSkills { get; protected set; }

Property Value

List<SkillSystem>

BaseAtk

The base physical attack value of the unit.

public float BaseAtk { get; protected set; }

Property Value

float

BaseDef

The base physical defense value of the unit.

public float BaseDef { get; protected set; }

Property Value

float

BaseSpeed

The unit's base speed (used for turn order or initiative).

public float BaseSpeed { get; protected set; }

Property Value

float

CharacterSprite

public Sprite3D? CharacterSprite { get; protected set; }

Property Value

Sprite3D

Curse

The unit’s curse value (used for status mechanics or debuffs).

public float Curse { get; protected set; }

Property Value

float

Description

Descriptive text about the unit.

public string Description { get; protected set; }

Property Value

string

HasPlayed

Indicates whether the unit has already acted this turn.

public bool HasPlayed { get; protected set; }

Property Value

bool

Hp

The current health points of the unit.

public float Hp { get; protected set; }

Property Value

float

Intelligence

The unit's intelligence stat, affecting magical power or effects.

public float Intelligence { get; protected set; }

Property Value

float

IsAlive

Indicates whether the unit is alive.

public bool IsAlive { get; protected set; }

Property Value

bool

ManaPoint

The unit's available mana points for casting skills.

public float ManaPoint { get; protected set; }

Property Value

float

MaxHp

The maximum health points of the unit.

public float MaxHp { get; protected set; }

Property Value

float

PassiveSkills

List of passive (always-on) skills applied to this unit.

public List<SkillSystem> PassiveSkills { get; protected set; }

Property Value

List<SkillSystem>

PortraitTexture

The portrait texture displayed for this unit in the UI.

public Texture2D? PortraitTexture { get; protected set; }

Property Value

Texture2D

PossibleMovesRange

The maximum number of tiles the unit can move per turn.

public int PossibleMovesRange { get; protected set; }

Property Value

int

Type

The type or archetype of the unit.

public UnitType Type { get; protected set; }

Property Value

UnitType

UnitName

The name of the unit.

public string UnitName { get; protected set; }

Property Value

string

Methods

ApplyEffect(StatusEffect)

Applies a status effect to this target.

public void ApplyEffect(StatusEffect statusEffect)

Parameters

statusEffect StatusEffect

The status effect to apply.

Attack(List<UnitSystem>, MapSystem?)

Performs an attack on the specified targets.

public abstract void Attack(List<UnitSystem> targets, MapSystem? map)

Parameters

targets List<UnitSystem>

List of target units to attack.

map MapSystem

Reference to the map system for positional logic.

CanMoveTo(int, int, int, MapSystem)

Checks if the unit can move to a given position.

public virtual bool CanMoveTo(int x, int y, int z, MapSystem map)

Parameters

x int

The X coordinate.

y int

The Y coordinate (height).

z int

The Z coordinate.

map MapSystem

The map to check against.

Returns

bool

true if the position is walkable; otherwise false.

Cleanup()

Cleans up the unit instance. This method can be overridden in derived classes to implement specific cleanup logic.

protected virtual void Cleanup()

Remarks

This method is called when the unit is removed from the scene tree. It provides a place for derived classes to implement any necessary cleanup logic, such as disconnecting signals or releasing resources. By default, it does nothing, but derived classes can override it to perform specific cleanup tasks.

EmitSignalHealthChanged(float, float)

protected void EmitSignalHealthChanged(float currentHp, float maxHp)

Parameters

currentHp float
maxHp float

EmitSignalPortraitChanged(Texture2D)

protected void EmitSignalPortraitChanged(Texture2D texture)

Parameters

texture Texture2D

GetActiveEffects()

Retrieves all status effects that are currently active on this target.

public List<StatusEffect> GetActiveEffects()

Returns

List<StatusEffect>

A list containing all active status effects.

GetPossibleMoves(MapSystem)

Calculates all possible movement tiles for this unit based on its range and position.

public virtual List<(int, int, int)> GetPossibleMoves(MapSystem map)

Parameters

map MapSystem

The map to evaluate movement on.

Returns

List<(int, int, int)>

A list of reachable coordinates (x, y, z).

Remarks

This method uses a Breadth-First Search (BFS) algorithm to evaluate all valid moves considering walkable tiles and vertical traversal (e.g. stairs, cliffs).

HasEffect<T>()

Checks whether this target currently has an active status effect of the given type.

public bool HasEffect<T>() where T : StatusEffect

Returns

bool

true if the effect is present, otherwise false.

Type Parameters

T

The type of the status effect to check for.

Initialize()

Initializes the unit instance This method should be overridden in derived classes to set up specific functionality.

protected virtual void Initialize()

Remarks

This method is called by the _Ready method to initialize the map. It should contain the logic necessary to set up the unit's state and functionality. Derived classes must implement this method to provide their specific initialization logic.

MoveTo(int, int, int, MapSystem)

Moves the unit to the specified coordinates if possible.

public virtual bool MoveTo(int x, int y, int z, MapSystem map)

Parameters

x int

Target X coordinate.

y int

Target Y coordinate (height).

z int

Target Z coordinate.

map MapSystem

The map to interact with.

Returns

bool

true if the move was successful; otherwise false.

PassTurn()

Marks the unit as having completed its turn.

public void PassTurn()

RemoveEffect(StatusEffect)

Removes an active status effect from this target.

public void RemoveEffect(StatusEffect statusEffect)

Parameters

statusEffect StatusEffect

The status effect to remove.

ReportSystemUnitHasPlayed()

Called by every UnitSystem function with an action to report to the system that the unit has played.

protected void ReportSystemUnitHasPlayed()

SetGridPosition(int, int, int, MapSystem)

Moves the unit to the specified grid coordinates in the MapSystem.

public virtual void SetGridPosition(int x, int y, int z, MapSystem map)

Parameters

x int

The X grid coordinate.

y int

The Y grid coordinate (height).

z int

The Z grid coordinate.

map MapSystem

The map on which the unit exists.

TakeDamage(float)

Applies incoming damage to the unit and updates HP.

public abstract void TakeDamage(float damage)

Parameters

damage float

The amount of damage received.

WaitForActionAsync()

Lock the system and wait the player for an action

public Task WaitForActionAsync()

Returns

Task

A Task that completes when the player finishes their action.

_ExitTree()

Called when the node is removed from the scene tree. Cleans up the unit instance and sets it to null.

public override void _ExitTree()

Remarks

This method is called automatically by Godot when the node is removed from the scene tree. It ensures that the unit instance is properly cleaned up and set to null. This is important for preventing memory leaks and ensuring that the manager can be re-initialized later if needed.

_PhysicsProcess(double)

Called once on each physics tick, and allows Nodes to synchronize their logic with physics ticks. delta is the logical time between physics ticks in seconds and is equal to Godot.Engine.TimeScale / Godot.Engine.PhysicsTicksPerSecond.

It is only called if physics processing is enabled for this Node, which is done automatically if this method is overridden, and can be toggled with SetPhysicsProcess(bool).

Processing happens in order of Godot.Node.ProcessPhysicsPriority, lower priority values are called first. Nodes with the same priority are processed in tree order, or top to bottom as seen in the editor (also known as pre-order traversal).

Corresponds to the Godot.Node.NotificationPhysicsProcess notification in _Notification(int).

Note: This method is only called if the node is present in the scene tree (i.e. if it's not an orphan).

Note: Accumulated delta may diverge from real world seconds.

public override void _PhysicsProcess(double delta)

Parameters

delta double

_Ready()

Called when the node is added to the scene tree. Initializes the unit instance.

public override void _Ready()

Remarks

This method is called automatically by Godot when the node is ready.

Events

HealthChanged

Emitted when the unit's health changes.

public event UnitSystem.HealthChangedEventHandler HealthChanged

Event Type

UnitSystem.HealthChangedEventHandler

PortraitChanged

Emitted when the unit's portrait texture changes.

public event UnitSystem.PortraitChangedEventHandler PortraitChanged

Event Type

UnitSystem.PortraitChangedEventHandler