class_name PlayerHUD extends Control

const TRANSITION_TIME := 0.06

const COLOR_VISIBLE := Color("#ffffffee")
const COLOR_DISABLED := Color("#cccccc44")
const COLOR_INVISIBLE := Color("#ffffff00")

@onready var interact_hud: Control = %InteractHUD


func _transition_color(element: CanvasItem, color: Color) -> void:
	create_tween().tween_property(element, "modulate", color, TRANSITION_TIME).set_trans(
		Tween.TRANS_CUBIC
	)


func _to_visible(element: Control) -> void:
	_transition_color(element, COLOR_VISIBLE)


func _to_disabled(element: Control) -> void:
	_transition_color(element, COLOR_DISABLED)


func _to_invisible(element: Control) -> void:
	_transition_color(element, COLOR_INVISIBLE)


func select_interactive(prop: Interactive) -> void:
	if prop:
		if prop.enabled:
			_to_visible(interact_hud)
		else:
			_to_disabled(interact_hud)
	else:
		_to_invisible(interact_hud)
