2025-09-01 16:14:21 +02:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
|
2025-09-05 15:03:52 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Represents an interactable object that can respond to tap input events.
|
|
|
|
|
|
/// </summary>
|
2025-09-01 16:14:21 +02:00
|
|
|
|
public class Interactable : MonoBehaviour, ITouchInputConsumer
|
|
|
|
|
|
{
|
2025-09-04 15:01:28 +02:00
|
|
|
|
public event Action StartedInteraction;
|
|
|
|
|
|
public event Action<bool> InteractionComplete;
|
2025-09-01 16:14:21 +02:00
|
|
|
|
|
2025-09-05 15:03:52 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Handles tap input. Triggers interaction logic.
|
|
|
|
|
|
/// </summary>
|
2025-09-05 14:10:42 +02:00
|
|
|
|
public void OnTap(Vector2 worldPosition)
|
2025-09-01 16:14:21 +02:00
|
|
|
|
{
|
2025-09-05 14:10:42 +02:00
|
|
|
|
Debug.Log($"[Interactable] OnTap at {worldPosition} on {gameObject.name}");
|
2025-09-04 15:01:28 +02:00
|
|
|
|
StartedInteraction?.Invoke();
|
2025-09-01 16:14:21 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-10 16:42:43 +02:00
|
|
|
|
// No hold behavior for interactables.
|
2025-09-05 15:03:52 +02:00
|
|
|
|
public void OnHoldStart(Vector2 worldPosition) { }
|
|
|
|
|
|
public void OnHoldMove(Vector2 worldPosition) { }
|
|
|
|
|
|
public void OnHoldEnd(Vector2 worldPosition) { }
|
2025-09-04 13:08:14 +02:00
|
|
|
|
|
2025-09-05 15:03:52 +02:00
|
|
|
|
/// <summary>
|
2025-09-10 16:42:43 +02:00
|
|
|
|
/// Called to interact with this object by a character (player, follower, etc).
|
2025-09-05 15:03:52 +02:00
|
|
|
|
/// </summary>
|
2025-09-10 16:42:43 +02:00
|
|
|
|
public virtual void OnInteract(Character character)
|
2025-09-04 13:08:14 +02:00
|
|
|
|
{
|
2025-09-10 16:42:43 +02:00
|
|
|
|
// In the new architecture, requirements and step checks will be handled by orchestrator.
|
|
|
|
|
|
StartedInteraction?.Invoke();
|
|
|
|
|
|
// For now, immediately complete interaction as success (can be extended later).
|
|
|
|
|
|
InteractionComplete?.Invoke(true);
|
2025-09-04 13:08:14 +02:00
|
|
|
|
}
|
2025-09-09 13:38:03 +02:00
|
|
|
|
|
|
|
|
|
|
public void CompleteInteraction(bool success)
|
|
|
|
|
|
{
|
|
|
|
|
|
InteractionComplete?.Invoke(success);
|
|
|
|
|
|
}
|
2025-09-01 16:14:21 +02:00
|
|
|
|
}
|