2025-09-01 16:14:21 +02:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
|
|
public class Interactable : MonoBehaviour, ITouchInputConsumer
|
|
|
|
|
|
{
|
|
|
|
|
|
public event Action Interacted;
|
|
|
|
|
|
|
2025-09-03 15:43:47 +02:00
|
|
|
|
private ObjectiveStepBehaviour stepBehaviour;
|
|
|
|
|
|
|
|
|
|
|
|
void Awake()
|
|
|
|
|
|
{
|
|
|
|
|
|
stepBehaviour = GetComponent<ObjectiveStepBehaviour>();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-01 16:14:21 +02:00
|
|
|
|
// Called by InputManager when this interactable is clicked/touched
|
|
|
|
|
|
public void OnTouchPress(Vector2 worldPosition)
|
|
|
|
|
|
{
|
2025-09-03 15:43:47 +02:00
|
|
|
|
if (stepBehaviour != null && !stepBehaviour.IsStepUnlocked())
|
|
|
|
|
|
{
|
|
|
|
|
|
DebugUIMessage.Show("Item is not unlocked yet");
|
|
|
|
|
|
Debug.Log("[Puzzles] Tried to interact with locked step: " + gameObject.name);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
Debug.Log($"[Interactable] OnTouchPress at {worldPosition} on {gameObject.name}");
|
2025-09-01 16:14:21 +02:00
|
|
|
|
Interacted?.Invoke();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void OnTouchPosition(Vector2 screenPosition)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Optionally handle drag/move here
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|