34 lines
1.3 KiB
C#
34 lines
1.3 KiB
C#
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;
|
||
|
||
// 通过事件频道通知 SaveSystem(SaveSystem 负责写入 data.World.DefeatedBossIds)
|
||
_onBossDefeatedForSave?.Raise(bossId);
|
||
}
|
||
}
|
||
}
|