feat(enemy): 新增 GroundNavigator 地面直接移动导航(+7 纯函数单测)
补充 EditMode 测试程序集对 BaseGames.Enemies.Navigation 的引用(此前缺失,新测试无法编译)
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
"BaseGames.Core",
|
||||
"BaseGames.AI",
|
||||
"BaseGames.Enemies",
|
||||
"BaseGames.Enemies.Navigation",
|
||||
"BaseGames.Core.Events",
|
||||
"BaseGames.Core.Save",
|
||||
"BaseGames.EventChain",
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
using NUnit.Framework;
|
||||
using BaseGames.Enemies.Navigation;
|
||||
|
||||
namespace BaseGames.Tests.EditMode.Enemies
|
||||
{
|
||||
/// <summary>GroundNavigator 的方向/到达判定纯函数(无场景依赖)。</summary>
|
||||
public class GroundNavigatorLogicTests
|
||||
{
|
||||
[Test]
|
||||
public void Arrived_WhenWithinStopDistance()
|
||||
=> Assert.IsTrue(GroundNavigator.Arrived(1.0f, 1.1f, 0.2f));
|
||||
|
||||
[Test]
|
||||
public void Arrived_ExactlyAtStopDistance_True()
|
||||
=> Assert.IsTrue(GroundNavigator.Arrived(1.0f, 1.2f, 0.2f));
|
||||
|
||||
[Test]
|
||||
public void NotArrived_WhenOutsideStopDistance()
|
||||
=> Assert.IsFalse(GroundNavigator.Arrived(1.0f, 1.5f, 0.2f));
|
||||
|
||||
[Test]
|
||||
public void Arrived_IgnoresDirection()
|
||||
{
|
||||
Assert.IsTrue(GroundNavigator.Arrived(1.0f, 0.9f, 0.2f)); // 目标在左侧
|
||||
Assert.IsFalse(GroundNavigator.Arrived(1.0f, 0.5f, 0.2f));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WanderX_PositiveSign_LandsWithinForwardRange()
|
||||
{
|
||||
Assert.AreEqual(11.5f, GroundNavigator.WanderX(10f, 1.5f, 5f, +1f, 0f), 1e-4f); // t=0 → 最近端
|
||||
Assert.AreEqual(15f, GroundNavigator.WanderX(10f, 1.5f, 5f, +1f, 1f), 1e-4f); // t=1 → 最远端
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WanderX_NegativeSign_LandsWithinBackwardRange()
|
||||
{
|
||||
Assert.AreEqual(8.5f, GroundNavigator.WanderX(10f, 1.5f, 5f, -1f, 0f), 1e-4f);
|
||||
Assert.AreEqual(5f, GroundNavigator.WanderX(10f, 1.5f, 5f, -1f, 1f), 1e-4f);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WanderX_MidT_Interpolates()
|
||||
=> Assert.AreEqual(13.25f, GroundNavigator.WanderX(10f, 1.5f, 5f, +1f, 0.5f), 1e-4f);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user