- Updated PhysicsPerceptionSystem to support seven detection modes: RangeCircle, BatchLOS, FanCast, BoxCast, Sight, RayCast, and TriggerZone. - Improved documentation for each detection mode, including performance optimization strategies. - Introduced PerceptionTriggerProxy for event-driven detection in TriggerZone slots. - Added SightBatchSystem to manage Sight slots efficiently, reducing CPU spikes during high enemy counts. - Updated SensorSlotNames to reflect new detection modes and their purposes. - Enhanced internal logic for detecting targets and managing detection events.
52 lines
2.1 KiB
C#
52 lines
2.1 KiB
C#
namespace BaseGames.Enemies.Perception
|
||
{
|
||
/// <summary>
|
||
/// <see cref="PhysicsPerceptionSystem"/> 槽位名称常量。
|
||
///
|
||
/// 统一定义字符串键,避免在 BD Task Inspector 和代码中散布魔法字符串。
|
||
/// Prefab 上 <see cref="PhysicsPerceptionSystem"/> 组件的 slotName 字段必须与此处常量保持一致。
|
||
/// </summary>
|
||
public static class SensorSlotNames
|
||
{
|
||
/// <summary>
|
||
/// 警戒范围(RangeCircle):玩家进入此圈触发 Alert 阶段。
|
||
/// 通常半径大于攻击范围,小于视线检测范围。
|
||
/// </summary>
|
||
public const string Aggro = "aggro";
|
||
|
||
/// <summary>
|
||
/// 视线检测(BatchLOS):敌我之间无遮挡时持续为 true。
|
||
/// 由 PhysicsPerceptionSystem 自研批量计算(OverlapCircle + 单次 Raycast),BD_IsPlayerVisible 读取结果。
|
||
/// </summary>
|
||
public const string LOS = "los";
|
||
|
||
/// <summary>
|
||
/// 近战攻击范围(RangeCircle):玩家进入时触发近战攻击条件。
|
||
/// </summary>
|
||
public const string AttackMelee = "attack_melee";
|
||
|
||
/// <summary>
|
||
/// 远程攻击范围(RangeCircle):玩家进入时触发远程攻击条件。
|
||
/// </summary>
|
||
public const string AttackRange = "attack_range";
|
||
|
||
/// <summary>
|
||
/// 巡逻范围(RangeCircle):定义敌人允许巡逻的地图固定区域半径。
|
||
/// 超出此范围时触发"返回巡逻点"逻辑。
|
||
/// </summary>
|
||
public const string Patrol = "patrol";
|
||
|
||
/// <summary>
|
||
/// 警觉半径(RangeCircle):进入此圈时敌人从待机/巡逻切换到 Alert 状态,
|
||
/// 通常比 Aggro 小,用于区分"察觉"和"追击"两个阶段。
|
||
/// </summary>
|
||
public const string Alert = "alert";
|
||
|
||
/// <summary>
|
||
/// 视线感知(Sight):带强制 LOS 遮挡检测的视锥传感器。
|
||
/// 仅当目标在视野锥内且无障碍物遮挡时才触发,是"看见玩家"的核心传感器。
|
||
/// </summary>
|
||
public const string Sight = "sight";
|
||
}
|
||
}
|