extends Node2D

@onready var energy_line: Line2D = %EnergyLine
@onready var ray_cast: RayCast2D = %RayCast

@export_range(1,999,8) var maximum_flow_distance: float

func _ready() -> void:
	var target_position := Vector2(maximum_flow_distance, 0)
	
	energy_line.add_point(Vector2.ZERO)
	energy_line.add_point(target_position)
	
	ray_cast.target_position = target_position

func _process(delta: float) -> void:
	energy_line.clear_points()
	if ray_cast.is_colliding():
		energy_line.add_point(Vector2.ZERO)
		energy_line.add_point(ray_cast.get_collision_point() - global_position)
	else :
		energy_line.add_point(Vector2.ZERO)
		energy_line.add_point(Vector2(maximum_flow_distance, 0))
