acdream/tests/AcDream.Core.Tests/Physics/ServerControlledLocomotionTests.cs
Erik 4dd8d4b46e fix(anim): Phase L.1c seed move-to locomotion
Retail MoveToManager::BeginMoveForward calls MovementParameters::get_command (0x0052AA00) and then _DoMotion/adjust_motion, so a server-controlled MoveTo begins visible forward locomotion before the next UpdatePosition echo. Seed RunForward for MoveTo packets that omit ForwardCommand, while preserving active locomotion and letting position velocity refine walk/run/stop.
2026-04-28 19:48:12 +02:00

62 lines
1.8 KiB
C#

using System.Numerics;
using AcDream.Core.Physics;
using Xunit;
namespace AcDream.Core.Tests.Physics;
public sealed class ServerControlledLocomotionTests
{
[Fact]
public void PlanMoveToStart_SeedsImmediateRunCycle()
{
var plan = ServerControlledLocomotion.PlanMoveToStart();
Assert.True(plan.IsMoving);
Assert.Equal(MotionCommand.RunForward, plan.Motion);
Assert.Equal(1.0f, plan.SpeedMod);
}
[Fact]
public void PlanFromVelocity_StopsBelowRetailNoiseThreshold()
{
var plan = ServerControlledLocomotion.PlanFromVelocity(
new Vector3(0.10f, 0.12f, 3.0f));
Assert.False(plan.IsMoving);
Assert.Equal(MotionCommand.Ready, plan.Motion);
Assert.Equal(1.0f, plan.SpeedMod);
}
[Fact]
public void PlanFromVelocity_WalksForSlowServerControlledMotion()
{
var plan = ServerControlledLocomotion.PlanFromVelocity(
new Vector3(0.0f, 0.80f, 0.0f));
Assert.True(plan.IsMoving);
Assert.Equal(MotionCommand.WalkForward, plan.Motion);
Assert.InRange(plan.SpeedMod, 0.25f, 0.27f);
}
[Fact]
public void PlanFromVelocity_RunsAtRetailRunScale()
{
var plan = ServerControlledLocomotion.PlanFromVelocity(
new Vector3(0.0f, MotionInterpreter.RunAnimSpeed, 0.0f));
Assert.True(plan.IsMoving);
Assert.Equal(MotionCommand.RunForward, plan.Motion);
Assert.Equal(1.0f, plan.SpeedMod, precision: 4);
}
[Fact]
public void PlanFromVelocity_ClampsVeryFastSnapshots()
{
var plan = ServerControlledLocomotion.PlanFromVelocity(
new Vector3(0.0f, 30.0f, 0.0f));
Assert.True(plan.IsMoving);
Assert.Equal(MotionCommand.RunForward, plan.Motion);
Assert.Equal(ServerControlledLocomotion.MaxSpeedMod, plan.SpeedMod);
}
}