Files
whale-town-front-v2/scenes/prefabs/items/NoticeBoard.gd
2026-07-21 23:23:26 +08:00

27 lines
872 B
GDScript

extends Area2D
class_name NoticeBoard
const NOTICE_DIALOG_SCENE: PackedScene = preload("res://scenes/ui/notice_dialog.tscn")
const NOTICE_DIALOG_NAME: String = "NoticeDialog"
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 = "notice_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 root: Window = get_tree().root
if root.has_node(NOTICE_DIALOG_NAME):
return
var dialog := NOTICE_DIALOG_SCENE.instantiate()
dialog.name = NOTICE_DIALOG_NAME
root.add_child(dialog)