2025-03-19 17:27:50 -06:00
|
|
|
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")
|
|
|
|
|
2025-07-04 13:13:18 -06:00
|
|
|
var _current_interactive: Interactive
|
|
|
|
var _set_this_frame := false
|
|
|
|
|
2025-03-19 17:27:50 -06:00
|
|
|
@onready var interact_name: Label = %InteractName
|
|
|
|
@onready var interact_verb: Label = %InteractVerb
|
|
|
|
|
|
|
|
|
2025-07-04 13:13:18 -06:00
|
|
|
func _ready() -> void:
|
|
|
|
_to_invisible()
|
|
|
|
|
|
|
|
|
2025-03-19 17:27:50 -06:00
|
|
|
func _transition_color(color: Color) -> void:
|
|
|
|
create_tween().tween_property(self, "modulate", color, TRANSITION_TIME).set_trans(
|
|
|
|
Tween.TRANS_CUBIC
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
func _to_visible() -> void:
|
2025-07-04 13:13:18 -06:00
|
|
|
print_debug("in _to_visible")
|
2025-03-19 17:27:50 -06:00
|
|
|
_transition_color(COLOR_VISIBLE)
|
|
|
|
|
|
|
|
|
|
|
|
func _to_disabled() -> void:
|
2025-07-04 13:13:18 -06:00
|
|
|
print_debug("in _to_disabled")
|
2025-03-19 17:27:50 -06:00
|
|
|
_transition_color(COLOR_DISABLED)
|
|
|
|
|
|
|
|
|
|
|
|
func _to_invisible() -> void:
|
2025-07-04 13:13:18 -06:00
|
|
|
print_debug("in _to_invisible")
|
2025-03-19 17:27:50 -06:00
|
|
|
_transition_color(COLOR_INVISIBLE)
|
|
|
|
|
|
|
|
|
2025-07-04 13:13:18 -06:00
|
|
|
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
|
2025-03-19 17:27:50 -06:00
|
|
|
if prop:
|
|
|
|
interact_name.text = prop.label
|
|
|
|
interact_verb.text = prop.verb
|
|
|
|
if prop.enabled:
|
|
|
|
_to_visible()
|
|
|
|
else:
|
|
|
|
_to_disabled()
|
|
|
|
else:
|
|
|
|
_to_invisible()
|
2025-07-04 13:13:18 -06:00
|
|
|
|
|
|
|
|
|
|
|
func _process(_delta: float) -> void:
|
|
|
|
if not _set_this_frame:
|
|
|
|
set_interactive(null)
|
|
|
|
|
|
|
|
_set_this_frame = false
|