feat: Enhance Physics Perception System with new detection modes and performance optimizations
- 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.
This commit is contained in:
@@ -1240,12 +1240,22 @@ namespace BaseGames.Editor
|
||||
case "los": enumIdx = 1; radius = 0f; layer = 0; break;
|
||||
case "attack_melee":enumIdx = 0; radius = 1.5f; layer = playerLayer; break;
|
||||
case "attack_range":enumIdx = 0; radius = 8f; layer = playerLayer; break;
|
||||
case "patrol": enumIdx = 0; radius = 5f; layer = 0; break;
|
||||
case "alert": enumIdx = 0; radius = 3f; layer = playerLayer; break;
|
||||
case "sight": enumIdx = 4; radius = 6f; layer = playerLayer; break;
|
||||
}
|
||||
|
||||
elem.FindPropertyRelative("type").enumValueIndex = enumIdx;
|
||||
elem.FindPropertyRelative("radius").floatValue = radius;
|
||||
elem.FindPropertyRelative("detectLayer").intValue = layer;
|
||||
|
||||
// sight 槽位默认设置推荐的 LOS 采样点数(3:中心+上+下)
|
||||
if (name == "sight")
|
||||
{
|
||||
var losRayCountProp = elem.FindPropertyRelative("losRayCount");
|
||||
if (losRayCountProp != null) losRayCountProp.intValue = 3;
|
||||
}
|
||||
|
||||
// 各 slot 分配语义化默认颜色,可在 Inspector 中按需覆盖
|
||||
Color defaultColor = name switch
|
||||
{
|
||||
@@ -1253,6 +1263,9 @@ namespace BaseGames.Editor
|
||||
"los" => new Color(0.00f, 0.80f, 1.00f, 1f), // 青
|
||||
"attack_melee" => new Color(1.00f, 0.20f, 0.20f, 1f), // 红
|
||||
"attack_range" => new Color(1.00f, 0.40f, 0.60f, 1f), // 粉红
|
||||
"patrol" => new Color(0.20f, 0.90f, 0.20f, 1f), // 绿
|
||||
"alert" => new Color(1.00f, 0.90f, 0.10f, 1f), // 黄
|
||||
"sight" => new Color(0.30f, 0.85f, 1.00f, 1f), // 浅蓝(LOS 传感器)
|
||||
_ => Color.clear, // 未知 slot 回退为紫色
|
||||
};
|
||||
elem.FindPropertyRelative("gizmoColor").colorValue = defaultColor;
|
||||
|
||||
Reference in New Issue
Block a user