存档完善和修复
This commit is contained in:
11
Assets/_Game/Scripts/Core/ILingZhuProvider.cs.meta
Normal file
11
Assets/_Game/Scripts/Core/ILingZhuProvider.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44b3cc2acf7eadd478af66d7d4cf770a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -54,6 +54,13 @@ namespace BaseGames.Core.Save
|
||||
public void Register(ISaveable s) => _saveables.Add(s);
|
||||
public void Unregister(ISaveable s) => _saveables.Remove(s);
|
||||
|
||||
// ── 游玩时间追踪 ──────────────────────────────────────────────────────
|
||||
private void Update()
|
||||
{
|
||||
if (_current != null)
|
||||
_current.Meta.Playtime += Time.unscaledDeltaTime;
|
||||
}
|
||||
|
||||
// ── 存档 ──────────────────────────────────────────────────────────────
|
||||
public async Task SaveAsync(int slot = -1)
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace BaseGames.Core.Save
|
||||
[Serializable]
|
||||
public class SaveMeta
|
||||
{
|
||||
public string Version = "2.1";
|
||||
public string Version = "2.2";
|
||||
public int SlotIndex;
|
||||
public string LastSaved; // ISO 8601
|
||||
public float Playtime;
|
||||
@@ -61,10 +61,6 @@ namespace BaseGames.Core.Save
|
||||
public List<string> UnlockedFormIds = new();
|
||||
|
||||
public DeathShadeSaveData DeathShade;
|
||||
|
||||
// 护盾:-1 = 满护盾(默认),>= 0 = 当前耐久值
|
||||
public int ShieldHP = -1;
|
||||
public bool ShieldIsBroken = false;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
@@ -80,7 +76,6 @@ namespace BaseGames.Core.Save
|
||||
public class EquipmentSaveData
|
||||
{
|
||||
public List<string> EquippedCharmIds = new();
|
||||
public int NotchesUsed;
|
||||
public int MaxNotches;
|
||||
public List<string> OwnedCharmIds = new();
|
||||
public List<string> UpgradedCharmIds = new();
|
||||
@@ -252,7 +247,7 @@ namespace BaseGames.Core.Save
|
||||
[Serializable]
|
||||
public class SettingsSaveData
|
||||
{
|
||||
/// <summary>玩家选择的语言。空字符串 = 使用系统默认。</summary>
|
||||
/// <summary>玩家选择的语言。空字符串 = 使用系统默认。由 LocalizationManager 读写。</summary>
|
||||
public string Language = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,11 +4,11 @@ namespace BaseGames.Core.Save
|
||||
{
|
||||
/// <summary>
|
||||
/// 处理存档版本迁移。
|
||||
/// 迁移链:旧版本 → "2.0" → "2.1"(CurrentVersion),每个分支按顺序落下执行(fall-through)。
|
||||
/// 迁移链:旧版本 → "2.0" → "2.1" → "2.2"(CurrentVersion),每个分支按顺序落下执行(fall-through)。
|
||||
/// </summary>
|
||||
public static class SaveMigrator
|
||||
{
|
||||
public const string CurrentVersion = "2.1";
|
||||
public const string CurrentVersion = "2.2";
|
||||
|
||||
public static SaveData Migrate(SaveData data)
|
||||
{
|
||||
@@ -43,6 +43,21 @@ namespace BaseGames.Core.Save
|
||||
v = "2.1";
|
||||
}
|
||||
|
||||
// ── 2.1 → 2.2 ───────────────────────────────────────────────────────
|
||||
if (v == "2.1")
|
||||
{
|
||||
// 2.2 删除 EquipmentSaveData.NotchesUsed(冗余,由 TryEquipCharm 重新计算)。
|
||||
// 2.2 删除 PlayerSaveData.ShieldHP / ShieldIsBroken(护盾在存档点始终全满,无需持久化)。
|
||||
// 2.2 删除 SettingsSaveData.Language(全局设置由 SettingsManager 写入 settings.json)。
|
||||
// 旧存档中这些字段由 Newtonsoft.Json 的 [JsonExtensionData] 忽略,无需额外处理。
|
||||
// Equipment.MaxNotches:旧存档若为 0,EquipmentManager.OnLoad 回退到初始 Notch 数量。
|
||||
if (data.Equipment != null && data.Equipment.MaxNotches == 0)
|
||||
data.Equipment.MaxNotches = 0; // 保持 0,OnLoad 回退到 config.initialNotchCount
|
||||
|
||||
Debug.Log("[SaveMigrator] 从 '2.1' 迁移至 '2.2'。");
|
||||
v = "2.2";
|
||||
}
|
||||
|
||||
// ── 未识别的未来版本 ─────────────────────────────────────────────────
|
||||
if (v != CurrentVersion)
|
||||
Debug.LogWarning($"[SaveMigrator] 未知版本 '{v}',将直接使用(可能存在兼容性问题)。");
|
||||
|
||||
Reference in New Issue
Block a user