chore: initial commit

This commit is contained in:
2026-05-08 11:04:00 +08:00
commit f55d2a57c3
6278 changed files with 866081 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
using UnityEngine;
using PathBerserker2d;
using BaseGames.Enemies;
namespace BaseGames.Enemies.Navigation
{
/// <summary>
/// PathBerserker2d 导航代理包装器(架构 07_EnemyModule §5
/// 实现 IPathAgent 接口,使 EnemyBase 和 BD Task 无需直接依赖 PB2d 类型。
/// PB2d APIUpdatePath(Vector2)、Stop()、TransformBasedMovement.movementSpeed、IsFollowingAPath。
/// </summary>
[RequireComponent(typeof(NavAgent))]
[RequireComponent(typeof(TransformBasedMovement))]
public class EnemyNavAgent : MonoBehaviour, IPathAgent
{
private NavAgent _navAgent;
private TransformBasedMovement _movement;
/// <summary>正在沿路径移动时为 true。</summary>
public bool IsMoving => _navAgent != null && _navAgent.IsFollowingAPath;
public event System.Action OnNavPathFailed;
private void Awake()
{
_navAgent = GetComponent<NavAgent>();
_movement = GetComponent<TransformBasedMovement>();
}
public void RequestMoveTo(Vector2 target)
{
_navAgent?.UpdatePath(target);
}
public void StopNavigation()
{
_navAgent?.Stop();
}
public bool IsAtDestination()
{
if (_navAgent == null) return true;
// 已停止 OR 在目标线段上且不再跟随路径
return _navAgent.IsIdle;
}
public void SetSpeed(float speed)
{
if (_movement != null) _movement.movementSpeed = speed;
}
}
}