[Interaction] Zip up edge cases, base for interactions is now done
This commit is contained in:
@@ -3,7 +3,8 @@ using System;
|
||||
|
||||
public class Interactable : MonoBehaviour, ITouchInputConsumer
|
||||
{
|
||||
public event Action Interacted;
|
||||
public event Action StartedInteraction;
|
||||
public event Action<bool> InteractionComplete;
|
||||
|
||||
private ObjectiveStepBehaviour stepBehaviour;
|
||||
|
||||
@@ -15,14 +16,9 @@ public class Interactable : MonoBehaviour, ITouchInputConsumer
|
||||
// Called by InputManager when this interactable is clicked/touched
|
||||
public void OnTouchPress(Vector2 worldPosition)
|
||||
{
|
||||
if (stepBehaviour != null && !stepBehaviour.IsStepUnlocked())
|
||||
{
|
||||
DebugUIMessage.Show("Item is not unlocked yet");
|
||||
Debug.Log("[Puzzles] Tried to interact with locked step: " + gameObject.name);
|
||||
return;
|
||||
}
|
||||
// Defer lock check to follower arrival
|
||||
Debug.Log($"[Interactable] OnTouchPress at {worldPosition} on {gameObject.name}");
|
||||
Interacted?.Invoke();
|
||||
StartedInteraction?.Invoke();
|
||||
}
|
||||
|
||||
public void OnTouchPosition(Vector2 screenPosition)
|
||||
@@ -33,10 +29,18 @@ public class Interactable : MonoBehaviour, ITouchInputConsumer
|
||||
// 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<InteractionRequirementBase>();
|
||||
if (requirements.Length == 0)
|
||||
{
|
||||
// No requirements: allow default pickup
|
||||
InteractionComplete?.Invoke(true);
|
||||
return true;
|
||||
}
|
||||
bool anySuccess = false;
|
||||
@@ -48,6 +52,7 @@ public class Interactable : MonoBehaviour, ITouchInputConsumer
|
||||
break;
|
||||
}
|
||||
}
|
||||
InteractionComplete?.Invoke(anySuccess);
|
||||
if (!anySuccess)
|
||||
{
|
||||
Debug.Log($"[Interactable] No interaction requirements succeeded for {gameObject.name}");
|
||||
|
||||
Reference in New Issue
Block a user