diff --git a/Assets/Scenes/Levels/AppleHillsOverworld.unity b/Assets/Scenes/Levels/AppleHillsOverworld.unity index 6bf3524f..5af05e20 100644 --- a/Assets/Scenes/Levels/AppleHillsOverworld.unity +++ b/Assets/Scenes/Levels/AppleHillsOverworld.unity @@ -590,8 +590,7 @@ PrefabInstance: propertyPath: m_Name value: TestAss objectReference: {fileID: 0} - m_RemovedComponents: - - {fileID: 4778083634590203921, guid: b5fc01af35233eb4cbeede05e50a7c34, type: 3} + m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] m_AddedComponents: [] diff --git a/Assets/Scripts/Interactions/Pickup.cs b/Assets/Scripts/Interactions/Pickup.cs index 6d77a9fd..065b6a86 100644 --- a/Assets/Scripts/Interactions/Pickup.cs +++ b/Assets/Scripts/Interactions/Pickup.cs @@ -136,7 +136,16 @@ namespace Interactions } FollowerController?.TryPickupItem(gameObject, itemData); - bool wasPickedUp = (combinationResult == FollowerController.CombinationResult.NotApplicable); + + var step = GetComponent(); + if (step != null && !step.IsStepUnlocked()) + { + Interactable.BroadcastInteractionComplete(false); + return; + } + + bool wasPickedUp = (combinationResult == FollowerController.CombinationResult.NotApplicable + || combinationResult == FollowerController.CombinationResult.Unsuccessful); Interactable.BroadcastInteractionComplete(wasPickedUp); // Update pickup state and invoke event when the item was picked up successfully diff --git a/Assets/Scripts/PuzzleS/PuzzleManager.cs b/Assets/Scripts/PuzzleS/PuzzleManager.cs index b73ec3d3..0c7d2c28 100644 --- a/Assets/Scripts/PuzzleS/PuzzleManager.cs +++ b/Assets/Scripts/PuzzleS/PuzzleManager.cs @@ -60,6 +60,10 @@ namespace PuzzleS private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { + SceneManager.sceneLoaded -= OnSceneLoaded; + + Debug.Log("[MDPI] OnSceneLoaded"); + _runtimeDependencies.Clear(); BuildRuntimeDependencies(); UnlockInitialSteps(); } @@ -74,6 +78,14 @@ namespace PuzzleS if (!_stepBehaviours.ContainsKey(behaviour.stepData)) { _stepBehaviours.Add(behaviour.stepData, behaviour); + _runtimeDependencies.Clear(); + foreach (var step in _stepBehaviours.Values) + { + step.LockStep(); + } + _unlockedSteps.Clear(); + BuildRuntimeDependencies(); + UnlockInitialSteps(); Debug.Log($"[Puzzles] Registered step: {behaviour.stepData.stepId} on {behaviour.gameObject.name}"); } } @@ -196,8 +208,9 @@ namespace PuzzleS /// public bool IsStepUnlocked(PuzzleStepSO step) { - BuildRuntimeDependencies(); - UnlockInitialSteps(); + // _runtimeDependencies.Clear(); + // BuildRuntimeDependencies(); + // UnlockInitialSteps(); return _unlockedSteps.Contains(step); }