using UnityEngine; using System; public class Interactable : MonoBehaviour, ITouchInputConsumer { public event Action StartedInteraction; public event Action InteractionComplete; private ObjectiveStepBehaviour stepBehaviour; void Awake() { stepBehaviour = GetComponent(); } // Implement new ITouchInputConsumer contract public void OnTap(Vector2 worldPosition) { Debug.Log($"[Interactable] OnTap at {worldPosition} on {gameObject.name}"); StartedInteraction?.Invoke(); } public void OnDragStart(Vector2 worldPosition) { } public void OnDrag(Vector2 worldPosition) { } public void OnDragEnd(Vector2 worldPosition) { } public void OnHoldStart(Vector2 worldPosition) { /* No hold behavior for interactables */ } public void OnHold(Vector2 worldPosition) { /* No hold behavior for interactables */ } public void OnHoldEnd(Vector2 worldPosition) { /* No hold behavior for interactables */ } // Called when the follower arrives at this interactable public bool OnFollowerArrived(FollowerController follower) { // Check if step is locked here if (stepBehaviour != null && !stepBehaviour.IsStepUnlocked()) { DebugUIMessage.Show("Item is not unlocked yet"); Debug.Log("[Puzzles] Tried to interact with locked step: " + gameObject.name); InteractionComplete?.Invoke(false); return false; } var requirements = GetComponents(); if (requirements.Length == 0) { InteractionComplete?.Invoke(true); return true; } bool anySuccess = false; foreach (var req in requirements) { if (req.TryInteract(follower)) { anySuccess = true; break; } } InteractionComplete?.Invoke(anySuccess); if (!anySuccess) { Debug.Log($"[Interactable] No interaction requirements succeeded for {gameObject.name}"); // Optionally trigger a default failure event or feedback here } return anySuccess; } }