feat: add nearby social interactions
This commit is contained in:
@@ -8,14 +8,30 @@ extends Area2D
|
||||
# ============================================================================
|
||||
|
||||
const INTERACTION_COLLISION_LAYER: int = 2
|
||||
const InteractionAnchorUtil = preload("res://_Core/utils/InteractionAnchor.gd")
|
||||
|
||||
@export var buildingId: String = ""
|
||||
@export var buildingTitle: String = ""
|
||||
@export var buildingRole: String = ""
|
||||
@export var interactionDistance: float = 150.0
|
||||
|
||||
func _ready() -> void:
|
||||
collision_layer = INTERACTION_COLLISION_LAYER
|
||||
collision_mask = 0
|
||||
add_to_group("whaletown_interactable")
|
||||
|
||||
func get_interaction_actions(player: Node2D) -> Array[Dictionary]:
|
||||
var anchor_position: Vector2 = InteractionAnchorUtil.get_position(self)
|
||||
var distance: float = anchor_position.distance_to(player.global_position)
|
||||
if distance > interactionDistance:
|
||||
return []
|
||||
return [{
|
||||
"id": "building:%s" % buildingId,
|
||||
"title": "使用 %s" % (buildingTitle if not buildingTitle.is_empty() else "设施"),
|
||||
"distance": distance,
|
||||
"priority": 30,
|
||||
"callback": Callable(self, "interact"),
|
||||
}]
|
||||
|
||||
func interact() -> void:
|
||||
var payload := {
|
||||
|
||||
Reference in New Issue
Block a user