23 lines
726 B
GDScript
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() |