class_name InteractHUD extends Control # Pops up when the player is looking at something interactable. const TRANSITION_TIME := 0.06 const COLOR_VISIBLE := Color("#ffffffee") const COLOR_DISABLED := Color("#cccccc44") const COLOR_INVISIBLE := Color("#ffffff00") var _current_interactive: Interactive var _set_this_frame := false @onready var interact_name: Label = %InteractName @onready var interact_verb: Label = %InteractVerb func _ready() -> void: _to_invisible() func _transition_color(color: Color) -> void: create_tween().tween_property(self, "modulate", color, TRANSITION_TIME).set_trans( Tween.TRANS_CUBIC ) func _to_visible() -> void: print_debug("in _to_visible") _transition_color(COLOR_VISIBLE) func _to_disabled() -> void: print_debug("in _to_disabled") _transition_color(COLOR_DISABLED) func _to_invisible() -> void: print_debug("in _to_invisible") _transition_color(COLOR_INVISIBLE) func set_interactive(prop: Interactive) -> void: if prop != _current_interactive: _set_new_interactive(prop) _set_this_frame = true func _set_new_interactive(prop: Interactive) -> void: _current_interactive = prop if prop: interact_name.text = prop.label interact_verb.text = prop.verb if prop.enabled: _to_visible() else: _to_disabled() else: _to_invisible() func _process(_delta: float) -> void: if not _set_this_frame: set_interactive(null) _set_this_frame = false