generated from SGDA/GodotExampleProject
feat: interactibles now emit signals and are parametrable through text and ids
This commit is contained in:
@ -1,17 +1,35 @@
|
||||
extends Area2D
|
||||
class_name Interactible
|
||||
|
||||
@export_file("*.tscn") var scene_to_trigger : String
|
||||
# @export_file("*.tscn") var scene_to_trigger: String
|
||||
@export var message: 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
|
||||
|
||||
# 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()
|
||||
|
||||
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
|
||||
|
Reference in New Issue
Block a user