using UnityEngine; [RequireComponent(typeof(Interactable))] public class ObjectiveStepBehaviour : MonoBehaviour { public PuzzleStepSO stepData; private Interactable interactable; private bool isUnlocked = false; void Awake() { interactable = GetComponent(); } void OnEnable() { if (interactable == null) interactable = GetComponent(); if (interactable != null) { interactable.StartedInteraction += OnStartedInteraction; interactable.InteractionComplete += OnInteractionComplete; // Removed old Interacted subscription } PuzzleManager.Instance?.RegisterStepBehaviour(this); } void OnDisable() { if (interactable != null) { interactable.StartedInteraction -= OnStartedInteraction; interactable.InteractionComplete -= OnInteractionComplete; // Removed old Interacted unsubscription } PuzzleManager.Instance?.UnregisterStepBehaviour(this); } public void UnlockStep() { isUnlocked = true; Debug.Log($"[Puzzles] Step unlocked: {stepData?.stepId} on {gameObject.name}"); // Optionally, show visual feedback for unlocked state } public void LockStep() { isUnlocked = false; Debug.Log($"[Puzzles] Step locked: {stepData?.stepId} on {gameObject.name}"); // Optionally, show visual feedback for locked state } public bool IsStepUnlocked() { return isUnlocked; } private void OnStartedInteraction() { // Optionally handle started interaction (e.g. visual feedback) } private void OnInteractionComplete(bool success) { if (!isUnlocked) return; if (success) { Debug.Log($"[Puzzles] Step interacted: {stepData?.stepId} on {gameObject.name}"); PuzzleManager.Instance?.OnStepCompleted(stepData); } } }