Update Puzzle Manager's initialization sequence

This commit is contained in:
Michal Pikulski
2025-09-11 15:48:44 +02:00
parent c5b8561b73
commit 15b8146815

View File

@@ -1,6 +1,7 @@
using UnityEngine; using UnityEngine;
using System.Collections.Generic; using System.Collections.Generic;
using PuzzleS; using PuzzleS;
using UnityEngine.SceneManagement;
/// <summary> /// <summary>
/// Manages puzzle step registration, dependency management, and step completion for the puzzle system. /// Manages puzzle step registration, dependency management, and step completion for the puzzle system.
@@ -44,6 +45,18 @@ public class PuzzleManager : MonoBehaviour
{ {
_instance = this; _instance = this;
// DontDestroyOnLoad(gameObject); // DontDestroyOnLoad(gameObject);
SceneManager.sceneLoaded += OnSceneLoaded;
}
void OnDestroy()
{
SceneManager.sceneLoaded -= OnSceneLoaded;
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
BuildRuntimeDependencies();
UnlockInitialSteps();
} }
/// <summary> /// <summary>
@@ -71,12 +84,6 @@ public class PuzzleManager : MonoBehaviour
Debug.Log($"[Puzzles] Unregistered step: {behaviour.stepData.stepId} on {behaviour.gameObject.name}"); Debug.Log($"[Puzzles] Unregistered step: {behaviour.stepData.stepId} on {behaviour.gameObject.name}");
} }
void Start()
{
BuildRuntimeDependencies();
UnlockInitialSteps();
}
/// <summary> /// <summary>
/// Builds the runtime dependency graph for all registered steps. /// Builds the runtime dependency graph for all registered steps.
/// </summary> /// </summary>