Files
zeling_v2/Assets/_Game/Scripts/Progression/BossProgressTracker.cs
2026-05-20 15:10:35 +08:00

32 lines
1.2 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;
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);
}
}
}