Semi-working Interactables rework
This commit is contained in:
@@ -9,13 +9,6 @@ public class Interactable : MonoBehaviour, ITouchInputConsumer
|
||||
public event Action StartedInteraction;
|
||||
public event Action<bool> InteractionComplete;
|
||||
|
||||
private ObjectiveStepBehaviour stepBehaviour;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
stepBehaviour = GetComponent<ObjectiveStepBehaviour>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles tap input. Triggers interaction logic.
|
||||
/// </summary>
|
||||
@@ -25,48 +18,20 @@ public class Interactable : MonoBehaviour, ITouchInputConsumer
|
||||
StartedInteraction?.Invoke();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// No hold behavior for interactables.
|
||||
/// </summary>
|
||||
// No hold behavior for interactables.
|
||||
public void OnHoldStart(Vector2 worldPosition) { }
|
||||
public void OnHoldMove(Vector2 worldPosition) { }
|
||||
public void OnHoldEnd(Vector2 worldPosition) { }
|
||||
|
||||
/// <summary>
|
||||
/// Called when the follower arrives at this interactable.
|
||||
/// Called to interact with this object by a character (player, follower, etc).
|
||||
/// </summary>
|
||||
public bool OnFollowerArrived(FollowerController follower)
|
||||
public virtual void OnInteract(Character character)
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
InteractionComplete?.Invoke(true);
|
||||
return true;
|
||||
}
|
||||
bool anySuccess = false;
|
||||
foreach (var req in requirements)
|
||||
{
|
||||
if (req.TryInteract(follower))
|
||||
{
|
||||
anySuccess = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
InteractionComplete?.Invoke(anySuccess);
|
||||
if (!anySuccess)
|
||||
{
|
||||
Debug.Log($"[Interactable] No interaction requirements succeeded for {gameObject.name}");
|
||||
// Optionally trigger a default failure event or feedback here
|
||||
}
|
||||
return anySuccess;
|
||||
// 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)
|
||||
|
||||
Reference in New Issue
Block a user