存档完善和修复
This commit is contained in:
@@ -4,19 +4,19 @@ using BaseGames.Core.Save;
|
||||
namespace BaseGames.Progression
|
||||
{
|
||||
/// <summary>
|
||||
/// 由事件触发的成就条件(使用 World.Switches 中的布尔标志位)。
|
||||
/// 由事件触发的成就条件(使用 EventChains.WorldFlags 中的布尔标志位)。
|
||||
/// 由代码(如剧情节点、NPC 交互)写入标志,AchievementManager 轮询检查。
|
||||
/// </summary>
|
||||
[CreateAssetMenu(menuName = "BaseGames/Achievement/Condition/EventTriggered", fileName = "COND_EventTriggered_")]
|
||||
public class EventTriggeredCondition : AchievementCondition
|
||||
{
|
||||
[Tooltip("World.Switches 中用于标记此事件发生的布尔 Key")]
|
||||
[Tooltip("EventChains.WorldFlags 中用于标记此事件发生的布尔 Key")]
|
||||
public string flagKey;
|
||||
|
||||
public override bool IsMet(SaveData save)
|
||||
{
|
||||
if (save?.World?.Switches == null || string.IsNullOrEmpty(flagKey)) return false;
|
||||
return save.World.Switches.TryGetValue(flagKey, out bool val) && val;
|
||||
if (save?.EventChains?.WorldFlags == null || string.IsNullOrEmpty(flagKey)) return false;
|
||||
return save.EventChains.WorldFlags.TryGetValue(flagKey, out bool val) && val;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace BaseGames.Progression
|
||||
{
|
||||
/// <summary>
|
||||
/// 无治疗通关成就条件。
|
||||
/// 依赖 World.Switches 中的标志位:AchievementManager 在玩家治疗时写入 noHeal_failed=true。
|
||||
/// 依赖 EventChains.WorldFlags 中的标志位:AchievementManager 在玩家治疗时写入 noHeal_failed=true。
|
||||
/// 满足条件:Boss 已击败 且 无治疗标志未被置入失败状态。
|
||||
/// </summary>
|
||||
[CreateAssetMenu(menuName = "BaseGames/Achievement/Condition/NoHealRun", fileName = "COND_NoHealRun_")]
|
||||
@@ -14,7 +14,7 @@ namespace BaseGames.Progression
|
||||
[Tooltip("追踪的 Boss ID(击败此 Boss 时检查是否治疗过)")]
|
||||
public string targetBossId;
|
||||
|
||||
[Tooltip("Switches 中记录「已治疗」失败状态的 Key(由 AchievementManager 设置)")]
|
||||
[Tooltip("WorldFlags 中记录「已治疗」失败状态的 Key(由 AchievementManager 设置)")]
|
||||
public string healFailFlagKey;
|
||||
|
||||
public override bool IsMet(SaveData save)
|
||||
@@ -22,7 +22,7 @@ namespace BaseGames.Progression
|
||||
if (save?.World == null) return false;
|
||||
// Boss 已击败 且 未触发治疗失败标志
|
||||
bool bossDefeated = save.World.DefeatedBossIds.Contains(targetBossId);
|
||||
bool didHeal = save.World.Switches.TryGetValue(healFailFlagKey, out bool val) && val;
|
||||
bool didHeal = save.EventChains?.WorldFlags?.TryGetValue(healFailFlagKey, out bool val) == true && val;
|
||||
return bossDefeated && !didHeal;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using UnityEngine;
|
||||
using BaseGames.Core;
|
||||
using BaseGames.Core.Events;
|
||||
|
||||
namespace BaseGames.Progression
|
||||
@@ -6,7 +7,7 @@ namespace BaseGames.Progression
|
||||
/// <summary>
|
||||
/// Boss 进程追踪器(架构 09_ProgressionModule §13)。
|
||||
/// 挂载在 Boss 房间的 BossTrigger 同一对象上。
|
||||
/// 监听 _onBossDefeated 事件,路由到 SaveSystem 专用频道(零耦合)。
|
||||
/// 监听 _onBossDefeated 事件,立即将胜利写入 SaveData 并推送到全局 ISaveService。
|
||||
/// </summary>
|
||||
public class BossProgressTracker : MonoBehaviour
|
||||
{
|
||||
@@ -14,8 +15,7 @@ namespace BaseGames.Progression
|
||||
[SerializeField] private string[] _unlocksProgressLockIds; // 击败后应解锁的 ProgressLock ID(预留)
|
||||
|
||||
[Header("Event Channels")]
|
||||
[SerializeField] private StringEventChannelSO _onBossDefeated; // 监听(来自 BossCombat)
|
||||
[SerializeField] private StringEventChannelSO _onBossDefeatedForSave; // 广播 → SaveSystem
|
||||
[SerializeField] private StringEventChannelSO _onBossDefeated; // 监听(来自 BossCombat)
|
||||
|
||||
private readonly CompositeDisposable _subs = new();
|
||||
|
||||
@@ -25,9 +25,7 @@ namespace BaseGames.Progression
|
||||
private void OnBossDefeated(string bossId)
|
||||
{
|
||||
if (bossId != _bossId) return;
|
||||
|
||||
// 通过事件频道通知 SaveSystem(SaveSystem 负责写入 data.World.DefeatedBossIds)
|
||||
_onBossDefeatedForSave?.Raise(bossId);
|
||||
ServiceLocator.GetOrDefault<ISaveService>()?.MarkBossDefeated(bossId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user