fix(enemy): 终审修复——删死代码群体警戒、修 Waypoints 到达推进、补 Locomotion 缺失报错

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-10 14:05:56 +08:00
co-authored by Claude Opus 4.8
parent c43ca8e8b6
commit 6a34b42db0
4 changed files with 9 additions and 44 deletions
+2 -36
View File
@@ -377,9 +377,6 @@ namespace BaseGames.Enemies
// LOD tick 速率控制迁移到后续 AiScheduler 阶段
}
// ── 警戒传播(Group Alert)────────────────────────────────────────
private static readonly UnityEngine.Collider2D[] _alertBuffer = new UnityEngine.Collider2D[32];
// ── 弹反(Parry)响应 ──────────────────────────────────────────────
private bool _wasParried;
private float _parryTimestamp;
@@ -417,39 +414,6 @@ namespace BaseGames.Enemies
ScheduleStateRecovery(EnemyStateType.Stagger, staggerDuration);
}
/// <summary>
/// 通知半径内的其他敌人进入 Alert 阶段(Group Alert 广播)。
/// 配合 BD_BroadcastAlert 在进入 Chase 阶段时调用。
/// </summary>
public void AlertNearby(float radius)
{
if (radius <= 0f) return;
int count = Physics2D.OverlapCircleNonAlloc(transform.position, radius, _alertBuffer);
for (int i = 0; i < count; i++)
{
if (_alertBuffer[i] == null) continue;
var enemy = _alertBuffer[i].GetComponentInParent<EnemyBase>();
if (enemy == null || enemy == this) continue;
enemy.ReceiveAlert(_playerTransform, LastKnownPlayerPosition);
}
}
/// <summary>
/// 接收来自邻近敌人的警戒广播。
/// 当前处于 Idle / Patrol 时切换到 AlertChase / Combat 中不降级。
/// </summary>
public void ReceiveAlert(Transform sharedPlayerTransform, Vector2 lastKnownPos)
{
if (!IsAlive) return;
if (IsEngaged) return;
// 同步玩家引用(若本敌人尚未感知到玩家)
if (sharedPlayerTransform != null && _playerTransform == null)
_playerTransform = sharedPlayerTransform;
LastKnownPlayerPosition = lastKnownPos;
PlayLocomotionClip(LocomotionMode.Face);
}
/// <summary>按当前移动模式播放步态动画(由 EnemyLocomotion 在模式变化时调用)。</summary>
public void PlayLocomotionClip(LocomotionMode mode)
{
@@ -550,6 +514,8 @@ namespace BaseGames.Enemies
_nav = GetComponent<IPathAgent>() ?? new NullPathAgent();
_locomotion = GetComponentInChildren<IEnemyLocomotion>(true);
if (_locomotion == null)
Debug.LogError($"EnemyBase 未找到 EnemyLocomotion 组件:{name}", this);
if (_movement == null) _movement = GetComponent<EnemyMovement>();
_poiseSource = GetComponent<IPoiseSource>();
_sensorHub = GetComponentInChildren<Perception.IPerceptionSystem>();