extends Node3D

@export var isUp:bool = true
@export var upPosition:float = 45
@export var downPosition:float = -45

@onready var visual_lever: Node3D = $Visuals/VisualLever

var lever_tween: Tween = null

signal changed(isUp: bool)

func _on_interactable_on_hit() -> void:
	isUp = !isUp
	changed.emit(isUp)
	
	if lever_tween != null:
		lever_tween.kill()
	
	lever_tween = get_tree().create_tween()
	lever_tween.tween_property(visual_lever, "rotation_degrees:x", upPosition if isUp else downPosition, 0.5).set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_CUBIC)
	
