32 lines
1.2 KiB
C#
32 lines
1.2 KiB
C#
using UnityEngine;
|
||
using BaseGames.Core;
|
||
using BaseGames.Core.Events;
|
||
|
||
namespace BaseGames.Progression
|
||
{
|
||
/// <summary>
|
||
/// Boss 进程追踪器(架构 09_ProgressionModule §13)。
|
||
/// 挂载在 Boss 房间的 BossTrigger 同一对象上。
|
||
/// 监听 _onBossDefeated 事件,立即将胜利写入 SaveData 并推送到全局 ISaveService。
|
||
/// </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)
|
||
|
||
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;
|
||
ServiceLocator.GetOrDefault<ISaveService>()?.MarkBossDefeated(bossId);
|
||
}
|
||
}
|
||
}
|