Fix puzzle unlock issues

This commit is contained in:
Michal Pikulski
2025-10-02 07:16:39 +02:00
parent eabc1de569
commit a6c63af911
3 changed files with 26 additions and 5 deletions

View File

@@ -136,7 +136,16 @@ namespace Interactions
}
FollowerController?.TryPickupItem(gameObject, itemData);
bool wasPickedUp = (combinationResult == FollowerController.CombinationResult.NotApplicable);
var step = GetComponent<PuzzleS.ObjectiveStepBehaviour>();
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

View File

@@ -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
/// </summary>
public bool IsStepUnlocked(PuzzleStepSO step)
{
BuildRuntimeDependencies();
UnlockInitialSteps();
// _runtimeDependencies.Clear();
// BuildRuntimeDependencies();
// UnlockInitialSteps();
return _unlockedSteps.Contains(step);
}