Files
zeling_v2/Assets/Scripts/Progression/BossProgressTracker.cs
2026-05-12 15:34:08 +08:00

34 lines
1.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using UnityEngine;
using BaseGames.Core.Events;
namespace BaseGames.Progression
{
/// <summary>
/// Boss 进程追踪器(架构 09_ProgressionModule §13
/// 挂载在 Boss 房间的 BossTrigger 同一对象上。
/// 监听 _onBossDefeated 事件,路由到 SaveSystem 专用频道(零耦合)。
/// </summary>
public class BossProgressTracker : MonoBehaviour
{
[SerializeField] private string _bossId; // 如 "Boss_SpiderGuard"
[SerializeField] private string[] _unlocksProgressLockIds; // 击败后应解锁的 ProgressLock ID预留
[Header("Event Channels")]
[SerializeField] private StringEventChannelSO _onBossDefeated; // 监听(来自 BossCombat
[SerializeField] private StringEventChannelSO _onBossDefeatedForSave; // 广播 → SaveSystem
private readonly CompositeDisposable _subs = new();
private void OnEnable() => _onBossDefeated?.Subscribe(OnBossDefeated).AddTo(_subs);
private void OnDisable() => _subs.Clear();
private void OnBossDefeated(string bossId)
{
if (bossId != _bossId) return;
// 通过事件频道通知 SaveSystemSaveSystem 负责写入 data.World.DefeatedBossIds
_onBossDefeatedForSave?.Raise(bossId);
}
}
}