存档完善和修复
This commit is contained in:
@@ -34,6 +34,9 @@ namespace BaseGames.Equipment
|
||||
private EquipmentContext _ctx;
|
||||
|
||||
// ── 生命周期 ──────────────────────────────────────────────────────────
|
||||
private void OnEnable() => ServiceLocator.GetOrDefault<ISaveableRegistry>()?.Register(this);
|
||||
private void OnDisable() => ServiceLocator.GetOrDefault<ISaveableRegistry>()?.Unregister(this);
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_ctx = new EquipmentContext
|
||||
@@ -111,7 +114,7 @@ namespace BaseGames.Equipment
|
||||
data.Equipment.EquippedCharmIds.AddRange(_equipped.Select(c => c.charmId));
|
||||
data.Equipment.OwnedCharmIds.Clear();
|
||||
data.Equipment.OwnedCharmIds.AddRange(_collected.Select(c => c.charmId));
|
||||
data.Equipment.NotchesUsed = UsedNotches;
|
||||
data.Equipment.MaxNotches = _currentNotchCapacity;
|
||||
}
|
||||
|
||||
public void OnLoad(SaveData data)
|
||||
@@ -122,6 +125,11 @@ namespace BaseGames.Equipment
|
||||
_equipped.Clear();
|
||||
_usedNotches = 0;
|
||||
|
||||
// 恢复 Notch 上限(若存档值为 0 则使用初始默认值)
|
||||
_currentNotchCapacity = data.Equipment.MaxNotches > 0
|
||||
? data.Equipment.MaxNotches
|
||||
: _config.initialNotchCount;
|
||||
|
||||
// 从 CharmCatalog 按 ID 恢复收藏并重新装备
|
||||
_collected.Clear();
|
||||
foreach (var id in data.Equipment.OwnedCharmIds)
|
||||
|
||||
Reference in New Issue
Block a user