Minor reset fixes
This commit is contained in:
committed by
Michal Pikulski
parent
717deee0cd
commit
0204c11560
@@ -1,4 +1,4 @@
|
||||
using System;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
@@ -242,6 +242,35 @@ namespace Core.SaveLoad
|
||||
return currentSaveData.unlockedMinigames.AsReadOnly();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears all save data for a specific level/scene.
|
||||
/// Removes all participant states that belong to the specified scene.
|
||||
/// Useful for "restart level" functionality to wipe progress.
|
||||
/// </summary>
|
||||
/// <param name="sceneName">The name of the scene to clear data for</param>
|
||||
public void ClearLevelData(string sceneName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(sceneName))
|
||||
{
|
||||
Logging.Warning("[SaveLoadManager] Cannot clear level data - scene name is null or empty");
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentSaveData == null || currentSaveData.participantStates == null)
|
||||
{
|
||||
Logging.Warning("[SaveLoadManager] Cannot clear level data - no save data loaded");
|
||||
return;
|
||||
}
|
||||
|
||||
// SaveId format is "SceneName/ObjectName/ComponentType"
|
||||
// Remove all entries that start with "sceneName/"
|
||||
string scenePrefix = $"{sceneName}/";
|
||||
int removedCount = currentSaveData.participantStates.RemoveAll(entry =>
|
||||
entry.saveId.StartsWith(scenePrefix));
|
||||
|
||||
Logging.Debug($"[SaveLoadManager] Cleared {removedCount} save entries for level: {sceneName}");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region State Restoration
|
||||
|
||||
Reference in New Issue
Block a user