[Interaction] Zip up edge cases, base for interactions is now done

This commit is contained in:
Michal Pikulski
2025-09-04 15:01:28 +02:00
parent 05a8a5445f
commit 4215d4b437
4 changed files with 51 additions and 25 deletions

View File

@@ -17,14 +17,22 @@ public class ObjectiveStepBehaviour : MonoBehaviour
if (interactable == null)
interactable = GetComponent<Interactable>();
if (interactable != null)
interactable.Interacted += OnInteracted;
{
interactable.StartedInteraction += OnStartedInteraction;
interactable.InteractionComplete += OnInteractionComplete;
// Removed old Interacted subscription
}
PuzzleManager.Instance?.RegisterStepBehaviour(this);
}
void OnDisable()
{
if (interactable != null)
interactable.Interacted -= OnInteracted;
{
interactable.StartedInteraction -= OnStartedInteraction;
interactable.InteractionComplete -= OnInteractionComplete;
// Removed old Interacted unsubscription
}
PuzzleManager.Instance?.UnregisterStepBehaviour(this);
}
@@ -47,10 +55,18 @@ public class ObjectiveStepBehaviour : MonoBehaviour
return isUnlocked;
}
private void OnInteracted()
private void OnStartedInteraction()
{
// Optionally handle started interaction (e.g. visual feedback)
}
private void OnInteractionComplete(bool success)
{
if (!isUnlocked) return;
Debug.Log($"[Puzzles] Step interacted: {stepData?.stepId} on {gameObject.name}");
PuzzleManager.Instance?.OnStepCompleted(stepData);
if (success)
{
Debug.Log($"[Puzzles] Step interacted: {stepData?.stepId} on {gameObject.name}");
PuzzleManager.Instance?.OnStepCompleted(stepData);
}
}
}