[Puzzles] Add basic framework for ScriptableObject puzzle steps and puzzle solving.

This commit is contained in:
Michal Pikulski
2025-09-03 15:43:47 +02:00
parent d8f792c8e5
commit 93242b2702
30 changed files with 1039 additions and 169 deletions

View File

@@ -0,0 +1,55 @@
using UnityEngine;
[RequireComponent(typeof(Interactable))]
public class ObjectiveStepBehaviour : MonoBehaviour
{
public PuzzleStepSO stepData;
private Interactable interactable;
private bool isUnlocked = false;
void Awake()
{
interactable = GetComponent<Interactable>();
if (interactable != null)
{
interactable.Interacted += OnInteracted;
}
// Register with PuzzleManager
PuzzleManager.Instance?.RegisterStepBehaviour(this);
}
void OnDestroy()
{
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);
}
}