forked from xiangwang25/whale-town-front-v2
30 lines
1.1 KiB
GDScript
30 lines
1.1 KiB
GDScript
extends Area2D
|
|
class_name WelcomeBoard
|
|
|
|
const WELCOME_DIALOG_SCENE: PackedScene = preload("res://scenes/ui/welcome_dialog.tscn")
|
|
const WELCOME_DIALOG_NAME: String = "WelcomeDialog"
|
|
const INTERACTION_COLLISION_LAYER: int = 2
|
|
|
|
func _ready() -> void:
|
|
collision_layer = INTERACTION_COLLISION_LAYER
|
|
collision_mask = 0
|
|
var interactable: InteractableComponent = InteractableComponent.new()
|
|
interactable.interaction_id = "welcome_board:%s" % str(get_path())
|
|
interactable.interaction_title = "查看新人引导"
|
|
interactable.interaction_priority = 35
|
|
interactable.interaction_distance = 150.0
|
|
interactable.activation_method = &"interact"
|
|
add_child(interactable)
|
|
|
|
func interact() -> void:
|
|
var taskManager := get_node_or_null("/root/TaskManager")
|
|
if taskManager != null and taskManager.has_method("report_activity"):
|
|
taskManager.call("report_activity", "facility_interacted", "welcome_board")
|
|
var root: Window = get_tree().root
|
|
if root.has_node(WELCOME_DIALOG_NAME):
|
|
return
|
|
|
|
var dialog := WELCOME_DIALOG_SCENE.instantiate()
|
|
dialog.name = WELCOME_DIALOG_NAME
|
|
root.add_child(dialog)
|