多轮审查评估

This commit is contained in:
2026-05-13 09:19:54 +08:00
parent 458f344e83
commit 1b37297585
57 changed files with 3019 additions and 218 deletions

View File

@@ -1,6 +1,7 @@
using UnityEngine;
using BaseGames.Core;
using BaseGames.Core.Events;
using BaseGames.Core.Save;
namespace BaseGames.Progression
{
@@ -9,7 +10,7 @@ namespace BaseGames.Progression
/// 单向/永久性阻挡,需满足特定条件(击败 Boss才能解锁。
/// 通过 ServiceLocator.GetOrDefault<SaveManager>() 读取进度,订阅 BossDefeated 事件实时响应。
/// </summary>
public class ProgressLock : MonoBehaviour
public class ProgressLock : MonoBehaviour, ISaveable
{
[Header("解锁条件")]
[SerializeField] private string _requiredBossId; // 空 = 不检查 Boss
@@ -27,6 +28,17 @@ namespace BaseGames.Progression
[SerializeField] private StringEventChannelSO _onBossDefeated; // EVT_BossDefeated
private readonly CompositeDisposable _subs = new();
private bool _isUnlocked;
private void Awake()
{
ServiceLocator.GetOrDefault<ISaveableRegistry>()?.Register(this);
}
private void OnDestroy()
{
ServiceLocator.GetOrDefault<ISaveableRegistry>()?.Unregister(this);
}
private void Start()
{
@@ -49,6 +61,19 @@ namespace BaseGames.Progression
if (CheckUnlocked()) ApplyState(true);
}
// ── ISaveable ─────────────────────────────────────────────────────────
public void OnSave(SaveData data)
{
if (_isUnlocked && !string.IsNullOrEmpty(_lockId)
&& !data.World.OpenedDoors.Contains(_lockId))
data.World.OpenedDoors.Add(_lockId);
}
public void OnLoad(SaveData data)
{
// 状态由 CheckUnlocked() 读取 IsDoorOpened(从 SaveData.OpenedDoors),应于 Start() 和 OnBossDefeated() 重新评估
}
private bool CheckUnlocked()
{
var sm = ServiceLocator.GetOrDefault<ISaveService>();
@@ -62,6 +87,7 @@ namespace BaseGames.Progression
private void ApplyState(bool unlocked)
{
_isUnlocked = unlocked;
if (_blockCollider != null) _blockCollider.enabled = !unlocked;
if (_lockedVisuals != null) _lockedVisuals.SetActive(!unlocked);
if (_unlockedVisuals != null) _unlockedVisuals.SetActive(unlocked);