Update assets, working save kerfuffle
This commit is contained in:
@@ -82,7 +82,7 @@ namespace Core.SaveLoad
|
||||
private void Start()
|
||||
{
|
||||
// Direct registration - SaveLoadManager guaranteed available (priority 25)
|
||||
if (SaveLoadManager.Instance != null)
|
||||
if (SaveLoadManager.Instance != null && ShouldParticipateInSave())
|
||||
{
|
||||
SaveLoadManager.Instance.RegisterParticipant(this);
|
||||
}
|
||||
@@ -126,6 +126,15 @@ namespace Core.SaveLoad
|
||||
// Match ManagedBehaviour convention: SceneName/GameObjectName/ComponentType
|
||||
return $"{sceneName}/{gameObject.name}/AppleMachine";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true to participate in save/load system.
|
||||
/// Override this in derived classes to opt out (return false).
|
||||
/// </summary>
|
||||
public virtual bool ShouldParticipateInSave()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
private string GetSceneName()
|
||||
{
|
||||
|
||||
@@ -29,6 +29,13 @@
|
||||
/// Used to prevent double-restoration when inactive objects become active.
|
||||
/// </summary>
|
||||
bool HasBeenRestored { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if this participant wants to participate in save/load system.
|
||||
/// Return false to opt out (participant will not be saved or restored).
|
||||
/// Useful for transient objects like UI elements that don't need persistence.
|
||||
/// </summary>
|
||||
bool ShouldParticipateInSave();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -130,6 +130,13 @@ namespace Core.SaveLoad
|
||||
participants[saveId] = participant;
|
||||
Logging.Debug($"[SaveLoadManager] Registered participant: {saveId}");
|
||||
|
||||
// Skip restoration for participants that opt out
|
||||
if (!participant.ShouldParticipateInSave())
|
||||
{
|
||||
Logging.Debug($"[SaveLoadManager] Participant opted out of save/load: {saveId}");
|
||||
return;
|
||||
}
|
||||
|
||||
// If we have save data loaded and the participant hasn't been restored yet
|
||||
if (IsSaveDataLoaded && currentSaveData != null && !participant.HasBeenRestored)
|
||||
{
|
||||
@@ -446,6 +453,13 @@ namespace Core.SaveLoad
|
||||
{
|
||||
string saveId = kvp.Key;
|
||||
ISaveParticipant participant = kvp.Value;
|
||||
|
||||
// Skip participants that opt out of save system
|
||||
if (!participant.ShouldParticipateInSave())
|
||||
{
|
||||
Logging.Debug($"[SaveLoadManager] Skipping participant (opted out): {saveId}");
|
||||
continue;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
@@ -630,6 +644,13 @@ namespace Core.SaveLoad
|
||||
{
|
||||
string saveId = kvp.Key;
|
||||
ISaveParticipant participant = kvp.Value;
|
||||
|
||||
// Skip participants that opt out of save system
|
||||
if (!participant.ShouldParticipateInSave())
|
||||
{
|
||||
Logging.Debug($"[SaveLoadManager] Skipping participant (opted out): {saveId}");
|
||||
continue;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user