forked from xiangwang25/whale-town-front-v2
31 lines
1.1 KiB
GDScript
31 lines
1.1 KiB
GDScript
class_name WorkZoneBuildingArea
|
|
extends Area2D
|
|
|
|
# ============================================================================
|
|
# WorkZoneBuildingArea.gd - 打工区建筑交互入口
|
|
# ============================================================================
|
|
# 为打工区建筑提供统一交互数据,玩家面对入口按交互键时由 PlayerController 调用。
|
|
# ============================================================================
|
|
|
|
const INTERACTION_COLLISION_LAYER: int = 2
|
|
|
|
@export var buildingId: String = ""
|
|
@export var buildingTitle: String = ""
|
|
@export var buildingRole: String = ""
|
|
|
|
func _ready() -> void:
|
|
collision_layer = INTERACTION_COLLISION_LAYER
|
|
collision_mask = 0
|
|
|
|
func interact() -> void:
|
|
var payload := {
|
|
"buildingId": buildingId,
|
|
"title": buildingTitle,
|
|
"role": buildingRole,
|
|
"nodePath": get_path(),
|
|
}
|
|
var eventSystem := get_node_or_null("/root/EventSystem")
|
|
if eventSystem != null:
|
|
eventSystem.call("emit_event", EventNames.OBJECT_INTERACTED, payload)
|
|
print("WorkZone building interacted: %s - %s" % [buildingTitle, buildingRole])
|