Files
AppleHillsProduction/Assets/Scripts/Interactions/Interactable.cs

42 lines
1.3 KiB
C#
Raw Normal View History

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>
public class Interactable : MonoBehaviour, ITouchInputConsumer
{
public event Action StartedInteraction;
public event Action<bool> InteractionComplete;
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-05 14:10:42 +02:00
Debug.Log($"[Interactable] OnTap at {worldPosition} on {gameObject.name}");
StartedInteraction?.Invoke();
}
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-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-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-09 13:38:03 +02:00
public void CompleteInteraction(bool success)
{
InteractionComplete?.Invoke(success);
}
}