@tool
class_name CurveBar extends Control
## Swinging arc used to set the curve of a shot.

const PIVOT_SCALE := -PI / 4

@export var gradient: Gradient:
	set(value):
		if gradient_tex:
			gradient_tex.gradient = value
		gradient = value

@export var value: float:
	set(v):
		if pivot:
			pivot.rotation = v * PIVOT_SCALE
	get:
		return pivot.rotation / PIVOT_SCALE if pivot else 0.0

@onready var pivot: Control = %Pivot
@onready var gradient_fill: TextureRect = %GradientFill
@onready var gradient_tex: GradientTexture2D = gradient_fill.texture
@onready var animation_player: AnimationPlayer = $Reticle/AnimationPlayer


func _ready() -> void:
	gradient = gradient


func flourish() -> void:
	animation_player.play("flourish")
