feat: 增强存档管理和成就系统,添加事件通知以支持凹槽成就的动态更新

This commit is contained in:
2026-05-20 16:03:10 +08:00
parent c50f8a6cf7
commit 8c66640a6d
3 changed files with 33 additions and 10 deletions

View File

@@ -26,16 +26,29 @@ namespace BaseGames.Equipment
[SerializeField] private CharmEventChannelSO _onCharmUnequipped;
[SerializeField] private VoidEventChannelSO _onEquipmentChanged;
[Tooltip("AchievementManager 解锁授予凹槽成就时发布;订阅后调用 IncreaseNotches(1)。")]
[SerializeField] private VoidEventChannelSO _onAchievementNotchGranted;
private readonly List<CharmSO> _equipped = new(4);
private readonly List<CharmSO> _collected = new(32);
private int _currentNotchCapacity;
private int _usedNotches;
private EquipmentContext _ctx;
private readonly CompositeDisposable _subs = new();
// ── 生命周期 ──────────────────────────────────────────────────────────
private void OnEnable() => ServiceLocator.GetOrDefault<ISaveableRegistry>()?.Register(this);
private void OnDisable() => ServiceLocator.GetOrDefault<ISaveableRegistry>()?.Unregister(this);
private void OnEnable()
{
ServiceLocator.GetOrDefault<ISaveableRegistry>()?.Register(this);
_onAchievementNotchGranted?.Subscribe(() => IncreaseNotches(1)).AddTo(_subs);
}
private void OnDisable()
{
ServiceLocator.GetOrDefault<ISaveableRegistry>()?.Unregister(this);
_subs.Clear();
}
private void Awake()
{