Fix issues with puzzle loading order and add saving state when using Menu
This commit is contained in:
committed by
Michal Pikulski
parent
c527ba334d
commit
717deee0cd
@@ -34,8 +34,6 @@ namespace PuzzleS
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
|
||||
_interactable = GetComponent<InteractableBase>();
|
||||
|
||||
// Initialize the indicator if it exists, but ensure it's hidden initially
|
||||
@@ -58,6 +56,8 @@ namespace PuzzleS
|
||||
Logging.Warning($"[Puzzles] Indicator prefab for {stepData?.stepId} does not implement IPuzzlePrompt");
|
||||
}
|
||||
}
|
||||
|
||||
base.Awake();
|
||||
}
|
||||
|
||||
protected override void OnManagedAwake()
|
||||
|
||||
@@ -50,7 +50,24 @@ namespace PuzzleS
|
||||
|
||||
// Save system configuration
|
||||
public override bool AutoRegisterForSave => true;
|
||||
public override string SaveId => $"{SceneManager.GetActiveScene().name}/PuzzleManager";
|
||||
|
||||
/// <summary>
|
||||
/// SaveId uses CurrentGameplayScene instead of GetActiveScene() because PuzzleManager
|
||||
/// lives in DontDestroyOnLoad and needs to save/load data per-scene.
|
||||
/// </summary>
|
||||
public override string SaveId
|
||||
{
|
||||
get
|
||||
{
|
||||
string sceneName = SceneManagerService.Instance?.CurrentGameplayScene;
|
||||
if (string.IsNullOrEmpty(sceneName))
|
||||
{
|
||||
// Fallback during early initialization
|
||||
sceneName = SceneManager.GetActiveScene().name;
|
||||
}
|
||||
return $"{sceneName}/PuzzleManager";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Singleton instance of the PuzzleManager.
|
||||
@@ -602,7 +619,8 @@ namespace PuzzleS
|
||||
// Update any behaviors that registered before RestoreState was called
|
||||
foreach (var behaviour in _pendingRegistrations)
|
||||
{
|
||||
UpdateStepState(behaviour);
|
||||
if(behaviour != null)
|
||||
UpdateStepState(behaviour);
|
||||
}
|
||||
_pendingRegistrations.Clear();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user