extends Area2D
class_name Interactible

# @export_file("*.tscn") var scene_to_trigger: String
@export var message: String
@export var interact_text: String
@export var event: String

signal event_triggered(event_id: String)

@onready var rich_text_label: RichTextLabel = $RichTextLabel
@onready var confirm_panel: Panel = %ConfirmPanel
@onready var message_box: Label = %MessageBox
@onready var interact_box: RichTextLabel = $RichTextLabel

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	rich_text_label.visible = false
	confirm_panel.visible = false
	message_box.text = message.to_upper()
	
	if not interact_text.is_empty():
		interact_box.text = interact_text.to_upper()

func _on_body_entered(body: Node2D) -> void:
	rich_text_label.visible = true

func _on_body_exited(body: Node2D) -> void:
	rich_text_label.visible = false
	confirm_panel.visible = false
	
func show_confirm():
	confirm_panel.visible = true

func _on_confirm_button_pressed() -> void:
	confirm_panel.visible = false
	event_triggered.emit(event)

func _on_cancel_button_pressed() -> void:
	confirm_panel.visible = false
