feat: 增强存档管理和成就系统,添加事件通知以支持凹槽成就的动态更新
This commit is contained in:
@@ -29,9 +29,11 @@ namespace BaseGames.Progression
|
||||
[Header("事件频道")]
|
||||
[SerializeField] private AchievementEventChannelSO _onAchievementUnlocked;
|
||||
|
||||
[Tooltip("成就授予凹槽时发布;EquipmentManager 订阅后调用 IncreaseNotches(1)。")]
|
||||
[SerializeField] private VoidEventChannelSO _onNotchGranted;
|
||||
|
||||
// ── 运行时状态 ─────────────────────────────────────────────────────────
|
||||
private readonly Dictionary<string, AchievementRuntimeState> _states = new();
|
||||
private SaveData _saveRef;
|
||||
|
||||
|
||||
private void Awake()
|
||||
@@ -104,7 +106,6 @@ namespace BaseGames.Progression
|
||||
/// </summary>
|
||||
public void EvaluateAll(SaveData save)
|
||||
{
|
||||
_saveRef = save;
|
||||
foreach (var state in _states.Values)
|
||||
{
|
||||
if (state.IsUnlocked) continue;
|
||||
@@ -151,11 +152,10 @@ namespace BaseGames.Progression
|
||||
ServiceLocator.Get<IPlatformService>()?.UnlockAchievement(state.Achievement.achievementId);
|
||||
#endif
|
||||
|
||||
// 若成就授予凹槽,写入存档数值
|
||||
if (state.Achievement.grantsNotch && _saveRef != null)
|
||||
{
|
||||
_saveRef.Equipment.MaxNotches++;
|
||||
}
|
||||
// 若成就授予凹槽,通过事件通知 EquipmentManager 更新运行时状态;
|
||||
// 不直接写 SaveData,避免与 EquipmentManager.OnSave 的数据竞争。
|
||||
if (state.Achievement.grantsNotch)
|
||||
_onNotchGranted?.Raise();
|
||||
|
||||
Debug.Log($"[Achievement] 解锁:{state.Achievement.displayName} ({state.Achievement.achievementId})");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user