refactor: unify interactable components

This commit is contained in:
ANG-Server
2026-07-21 23:23:26 +08:00
parent 9dee47492c
commit 74a0fb8309
17 changed files with 241 additions and 208 deletions

View File

@@ -19,9 +19,22 @@ class_name CafeCompanionTarget
var _lastClickMsec: int = 0
func _ready() -> void:
var interactable: InteractableComponent = InteractableComponent.new()
interactable.interaction_distance = 160.0
add_child(interactable)
input_pickable = true
set_process_unhandled_input(true)
func is_interaction_active(_component: InteractableComponent) -> bool:
return not servicePointId.strip_edges().is_empty() and not companionId.strip_edges().is_empty()
func build_interaction_actions(_component: InteractableComponent, _player: Node2D) -> Array[InteractionAction]:
var actions: Array[InteractionAction] = []
var display_name: String = _resolved_persona_name()
var action_id: String = "cafe_companion:%s" % servicePointId
actions.append(InteractionAction.create(action_id, "%s 交流" % display_name, 45, Callable(self, "_try_emit_target_selected")))
return actions
func _input_event(_viewport: Viewport, event: InputEvent, _shapeIdx: int) -> void:
if not (event is InputEventMouseButton):
return