43 lines
1.6 KiB
C#
43 lines
1.6 KiB
C#
using System;
|
||
using UnityEngine;
|
||
|
||
namespace BaseGames.Enemies
|
||
{
|
||
/// <summary>
|
||
/// 导航代理抽象接口(架构 07_EnemyModule §5)。
|
||
/// EnemyBase 和 BD Task 只依赖此接口,不依赖具体导航库。
|
||
/// 实现:EnemyNavAgent(PathBerserker2d);测试用 NullPathAgent。
|
||
/// </summary>
|
||
public interface IPathAgent
|
||
{
|
||
/// <summary>请求移动到世界坐标 target。</summary>
|
||
void RequestMoveTo(Vector2 target);
|
||
|
||
/// <summary>立即停止导航(清除路径)。</summary>
|
||
void StopNavigation();
|
||
|
||
/// <summary>是否已到达目标(距离 ≤ stoppingDistance)。</summary>
|
||
bool IsAtDestination();
|
||
|
||
/// <summary>运行时覆盖移动速度。</summary>
|
||
void SetSpeed(float speed);
|
||
|
||
/// <summary>当前帧是否在移动(速度 > 0.01 且有有效路径)。</summary>
|
||
bool IsMoving { get; }
|
||
|
||
/// <summary>路径寻路失败事件(目标不可达时触发)。</summary>
|
||
event Action OnNavPathFailed;
|
||
}
|
||
|
||
// ── 无导航 / 测试用空实现 ─────────────────────────────────────────────
|
||
public sealed class NullPathAgent : IPathAgent
|
||
{
|
||
public void RequestMoveTo(Vector2 _) { }
|
||
public void StopNavigation() { }
|
||
public bool IsAtDestination() => true;
|
||
public void SetSpeed(float _) { }
|
||
public bool IsMoving => false;
|
||
public event Action OnNavPathFailed { add { } remove { } }
|
||
}
|
||
}
|