Files
AppleHillsProduction/Assets/Scripts/Interactions/Interactable.cs
2025-09-11 14:07:57 +02:00

42 lines
1.3 KiB
C#

using UnityEngine;
using System;
/// <summary>
/// Represents an interactable object that can respond to tap input events.
/// </summary>
public class Interactable : MonoBehaviour, ITouchInputConsumer
{
public event Action StartedInteraction;
public event Action<bool> InteractionComplete;
/// <summary>
/// Handles tap input. Triggers interaction logic.
/// </summary>
public void OnTap(Vector2 worldPosition)
{
Debug.Log($"[Interactable] OnTap at {worldPosition} on {gameObject.name}");
StartedInteraction?.Invoke();
}
// No hold behavior for interactables.
public void OnHoldStart(Vector2 worldPosition) { }
public void OnHoldMove(Vector2 worldPosition) { }
public void OnHoldEnd(Vector2 worldPosition) { }
/// <summary>
/// Called to interact with this object by a character (player, follower, etc).
/// </summary>
public virtual void OnInteract(Character character)
{
// 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);
}
public void CompleteInteraction(bool success)
{
InteractionComplete?.Invoke(success);
}
}