修了不少东西
This commit is contained in:
@@ -16,6 +16,8 @@ public sealed class StoreOwnershipLedger : MonoBehaviour
|
||||
private readonly Dictionary<int, StoreOwnershipEntry> entriesByItemId = new Dictionary<int, StoreOwnershipEntry>();
|
||||
private readonly List<storeItemSO> cachedStoreItems = new List<storeItemSO>();
|
||||
private bool initialized;
|
||||
private bool loadedFromSave;
|
||||
private bool hasAnyRecoverableLocalState;
|
||||
private int lastSaveFrame = -1;
|
||||
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
|
||||
@@ -73,8 +75,8 @@ public sealed class StoreOwnershipLedger : MonoBehaviour
|
||||
|
||||
initialized = true;
|
||||
StoreOwnershipPayload payload;
|
||||
bool loadedFromSave = StoreOwnershipStorage.TryLoad(out payload);
|
||||
bool hasAnyRecoverableLocalState = loadedFromSave || StoreOwnershipStorage.HasAnyRecoverableState();
|
||||
loadedFromSave = StoreOwnershipStorage.TryLoad(out payload);
|
||||
hasAnyRecoverableLocalState = loadedFromSave || StoreOwnershipStorage.HasAnyRecoverableState();
|
||||
RebuildFromPayload(payload);
|
||||
LoadStoreItems();
|
||||
|
||||
@@ -208,6 +210,12 @@ public sealed class StoreOwnershipLedger : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
|
||||
if (!loadedFromSave && hasAnyRecoverableLocalState)
|
||||
{
|
||||
Debug.LogWarning("[StoreOwnershipLedger] Recoverable save state exists but could not be loaded; skip saving to avoid overwriting older store ownership data.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Application.isPlaying && lastSaveFrame == Time.frameCount)
|
||||
{
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user