多轮审查和修复
This commit is contained in:
36
Assets/Scripts/Support/AntiSoftlock/HardAbilityGate.cs
Normal file
36
Assets/Scripts/Support/AntiSoftlock/HardAbilityGate.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using UnityEngine;
|
||||
using BaseGames.World;
|
||||
using BaseGames.Player;
|
||||
using BaseGames.Core.Save;
|
||||
|
||||
namespace BaseGames.Progression
|
||||
{
|
||||
/// <summary>
|
||||
/// 硬性能力门禁(架构 16_SupportingModules §5.3)。
|
||||
/// 在 AbilityGate 的基础上增加次级验证:检查玩家是否真正拾取了物理道具。
|
||||
/// 当 _requirePhysicalValidation = true 时,还需要通过 _physicalPickupSwitchKey 确认。
|
||||
/// </summary>
|
||||
public class HardAbilityGate : AbilityGate
|
||||
{
|
||||
[Header("HardAbilityGate 设置")]
|
||||
[Tooltip("是否还要求物理拾取验证(需要 World.Switches 中对应 Key = true)")]
|
||||
[SerializeField] private bool _requirePhysicalValidation = false;
|
||||
[Tooltip("物理拾取验证 Switch Key(需 SaveManager.Data.World.Switches[key] == true)")]
|
||||
[SerializeField] private string _physicalPickupSwitchKey;
|
||||
|
||||
[Header("引用")]
|
||||
[SerializeField] private SaveManager _saveManager;
|
||||
|
||||
protected override bool EvaluateAccess()
|
||||
{
|
||||
if (!base.EvaluateAccess()) return false;
|
||||
if (!_requirePhysicalValidation) return true;
|
||||
|
||||
// 次级检查:物理拾取确认
|
||||
if (string.IsNullOrEmpty(_physicalPickupSwitchKey)) return true;
|
||||
var save = _saveManager != null ? _saveManager.Data : null;
|
||||
if (save?.World?.Switches == null) return false;
|
||||
return save.World.Switches.TryGetValue(_physicalPickupSwitchKey, out bool val) && val;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user