57 lines
1.5 KiB
C#
57 lines
1.5 KiB
C#
using UnityEngine;
|
|
|
|
[RequireComponent(typeof(Interactable))]
|
|
public class ObjectiveStepBehaviour : MonoBehaviour
|
|
{
|
|
public PuzzleStepSO stepData;
|
|
private Interactable interactable;
|
|
private bool isUnlocked = false;
|
|
|
|
void Awake()
|
|
{
|
|
interactable = GetComponent<Interactable>();
|
|
}
|
|
|
|
void OnEnable()
|
|
{
|
|
if (interactable == null)
|
|
interactable = GetComponent<Interactable>();
|
|
if (interactable != null)
|
|
interactable.Interacted += OnInteracted;
|
|
PuzzleManager.Instance?.RegisterStepBehaviour(this);
|
|
}
|
|
|
|
void OnDisable()
|
|
{
|
|
if (interactable != null)
|
|
interactable.Interacted -= OnInteracted;
|
|
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 OnInteracted()
|
|
{
|
|
if (!isUnlocked) return;
|
|
Debug.Log($"[Puzzles] Step interacted: {stepData?.stepId} on {gameObject.name}");
|
|
PuzzleManager.Instance?.OnStepCompleted(stepData);
|
|
}
|
|
}
|