Files
Dawn-Godot/battle/ui/BattleCursor.gd
2026-01-17 18:03:59 -06:00

23 lines
726 B
GDScript

class_name BattleCursor extends Control
@export var cursor:PackedScene
func setCursors(battleScene:BattleScene, targets:Array[BattleSingleton.BattlePosition]) -> void:
clearCursors()
for target in targets:
var fighterScene = battleScene.getFighterSceneAtPosition(target)
if fighterScene == null:
continue
var cursorInstance = cursor.instantiate()
add_child(cursorInstance)
# Convert world position to screen space
var screenPos = battleScene.get_viewport().get_camera_3d().unproject_position(fighterScene.global_transform.origin)
cursorInstance.position = screenPos
func clearCursors() -> void:
# Clear all children (cursors).
for child in get_children():
child.queue_free()