feat: 优化存档管理和工具槽管理,改进数据类型转换,增强代码可读性
This commit is contained in:
@@ -235,10 +235,10 @@ namespace BaseGames.Core.Save
|
|||||||
return new SlotSummary
|
return new SlotSummary
|
||||||
{
|
{
|
||||||
SlotIndex = slotIndex,
|
SlotIndex = slotIndex,
|
||||||
Playtime = root["Meta"]?["Playtime"]?.Value<float>() ?? 0f,
|
Playtime = (float?)root["Meta"]?["Playtime"] ?? 0f,
|
||||||
LastSaved = root["Meta"]?["LastSaved"]?.Value<string>(),
|
LastSaved = (string)root["Meta"]?["LastSaved"],
|
||||||
SceneName = root["Player"]?["Scene"]?.Value<string>(),
|
SceneName = (string)root["Player"]?["Scene"],
|
||||||
ActiveFormId = root["Player"]?["ActiveFormId"]?.Value<string>(),
|
ActiveFormId = (string)root["Player"]?["ActiveFormId"],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
catch { return null; }
|
catch { return null; }
|
||||||
|
|||||||
@@ -96,9 +96,9 @@ namespace BaseGames.Equipment
|
|||||||
|
|
||||||
// 恢复剩余使用次数(EquipTool 会重置为 maxUses,此处覆盖还原)
|
// 恢复剩余使用次数(EquipTool 会重置为 maxUses,此处覆盖还原)
|
||||||
if (data.Tools.ToolStates.TryGetValue("Slot0_Uses", out var uses0))
|
if (data.Tools.ToolStates.TryGetValue("Slot0_Uses", out var uses0))
|
||||||
_remainingUses[0] = uses0["uses"]?.Value<int>() ?? _remainingUses[0];
|
_remainingUses[0] = (int?)uses0["uses"] ?? _remainingUses[0];
|
||||||
if (data.Tools.ToolStates.TryGetValue("Slot1_Uses", out var uses1))
|
if (data.Tools.ToolStates.TryGetValue("Slot1_Uses", out var uses1))
|
||||||
_remainingUses[1] = uses1["uses"]?.Value<int>() ?? _remainingUses[1];
|
_remainingUses[1] = (int?)uses1["uses"] ?? _remainingUses[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using BaseGames.Core;
|
using BaseGames.Core;
|
||||||
|
using BaseGames.Core.Events;
|
||||||
using BaseGames.Core.Save;
|
using BaseGames.Core.Save;
|
||||||
using BaseGames.Platform;
|
using BaseGames.Platform;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user