Update assets, working save kerfuffle

This commit is contained in:
Michal Pikulski
2025-11-17 14:30:07 +01:00
parent ee07d89d3e
commit c6f635f871
30 changed files with 44358 additions and 462 deletions

View File

@@ -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()
{

View File

@@ -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();
}
}

View File

@@ -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
{