Table of Contents

Class MapSystem

Namespace
AshesOfVelsingrad.systems
Assembly
Ashes of Velsingrad.dll

Base class for all playable maps in the game.

[ScriptPath("res://scripts/systems/MapSystem.cs")]
public abstract class MapSystem : GridMap, IDisposable
Inheritance
GodotObject
Node
Node3D
GridMap
MapSystem
Implements
Derived
Inherited Members
GridMap.InvalidCellItem
GridMap.SetNavigationMap(Rid)
GridMap.GetNavigationMap()
GridMap.GetCellItem(Vector3I)
GridMap.GetCellItemOrientation(Vector3I)
GridMap.GetCellItemBasis(Vector3I)
GridMap.GetOrthogonalIndexFromBasis(Basis)
GridMap.LocalToMap(Vector3)
GridMap.MapToLocal(Vector3I)
GridMap.ResourceChanged(Resource)
GridMap.Clear()
GridMap.GetUsedCells()
GridMap.GetMeshes()
GridMap.GetBakeMeshes()
GridMap.ClearBakedMeshes()
GridMap.EmitSignalCellSizeChanged(Vector3)
GridMap.EmitSignalChanged()
GridMap.InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)
GridMap.HasGodotClassMethod(in godot_string_name)
GridMap.HasGodotClassSignal(in godot_string_name)
GridMap.MeshLibrary
GridMap.PhysicsMaterial
GridMap.CellSize
GridMap.CellOctantSize
GridMap.CellCenterX
GridMap.CellCenterY
GridMap.CellCenterZ
GridMap.CellScale
GridMap.CollisionLayer
GridMap.CollisionMask
GridMap.CollisionPriority
GridMap.BakeNavigation
GridMap.CellSizeChanged
GridMap.Changed
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 extends Godot's Godot.GridMap and manages the grid layout, grid metadata (CellInformation), and unit placement. It enforces a single active instance through the Instance property.

Fields

CellTypeWalkable

public static readonly Dictionary<CellType, bool> CellTypeWalkable

Field Value

Dictionary<CellType, bool>

CellsInformation

List of information of every grid

protected readonly List<CellInformation> CellsInformation

Field Value

List<CellInformation>

Properties

Depth

The total Z axis of the map (in number of cells)

public int Depth { get; }

Property Value

int

Height

The total Y axis of the map (in number of cells)

public int Height { get; }

Property Value

int

Instance

Instance of a map system.

public static MapSystem? Instance { get; protected set; }

Property Value

MapSystem

Remarks

It will be used to check if there is only one instance.

MapCellSize

The size of a single grid in the UI

public Vector3 MapCellSize { get; }

Property Value

Vector3

Width

The total X axis of the map (in number of cells)

public int Width { get; }

Property Value

int

Methods

Cleanup()

Cleans up the map 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 manager 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.

GetUnitAt(int, int, int)

Gets the unit currently occupying the map cell at the given position.

public virtual UnitSystem? GetUnitAt(int x, int y, int z)

Parameters

x int

The x-coordinate of the map cell.

y int

The y-coordinate of the map cell.

z int

The z-coordinate of the map cell.

Returns

UnitSystem

The unit at the specified map cell, or null if the cell is empty.

GetUnitPosition(UnitSystem)

public virtual (int, int, int)? GetUnitPosition(UnitSystem unit)

Parameters

unit UnitSystem

Returns

(int, int, int)?

Initialize()

Initializes the map 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 map's state and functionality. Derived classes must implement this method to provide their specific initialization logic.

IsWalkable(int, int, int)

Getter to know if a cell is walkable.

public virtual bool IsWalkable(int x, int y, int z)

Parameters

x int

The x-axis

y int

The y-axis

z int

The z-axis

Returns

bool

True if the cell is walkable, False otherwise

MoveUnit(UnitSystem, int, int, int)

Moves a unit to a new position in the map.

public virtual void MoveUnit(UnitSystem unit, int newX, int newY, int newZ)

Parameters

unit UnitSystem

The unit to move.

newX int

The target x-coordinate in the cell.

newY int

The target y-coordinate in the cell.

newZ int

The target z-coordinate in the cell.

Remarks

Implementations should handle removing the unit from its current cell and assigning it to the new cell. This method does not check whether the target cell is walkable, which should be verified beforehand.

PlaceUnits(List<UnitSystem>, List<UnitSystem>)

Place every unit in the map.

public abstract void PlaceUnits(List<UnitSystem> playerUnits, List<UnitSystem> enemyUnits)

Parameters

playerUnits List<UnitSystem>

List of every unit of the player

enemyUnits List<UnitSystem>

List of every enemy on the maps

Remarks

It must be called only for the class initialization.

RemoveUnit(int, int, int)

Removes any unit present at the given map cell.

public virtual void RemoveUnit(int x, int y, int z)

Parameters

x int

The x-coordinate of the map cell.

y int

The y-coordinate of the map cell.

z int

The z-coordinate of the map cell.

Remarks

Implementations should clear the reference to the unit from the cell. If the cell is already empty, this method does nothing.

SetWalkable(int, int, int)

Set the IsWalkable variable of a CellInformation to the reverse value.

public virtual void SetWalkable(int x, int y, int z)

Parameters

x int

The x-axis

y int

The y-axis

z int

The z-axis

_ExitTree()

Called when the node is removed from the scene tree. Cleans up the manager 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 map 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.

_Ready()

Called when the node is added to the scene tree. Initializes the map instance and checks for duplicates.

public override void _Ready()

Remarks

This method is called automatically by Godot when the node is ready. It ensures that only one instance of the map exists in the scene tree. If a duplicate instance is found, it removes the duplicate.