fix(anim): Phase L.1c animate server-controlled chase
This commit is contained in:
parent
b96b680a20
commit
7656fe0970
6 changed files with 224 additions and 13 deletions
63
src/AcDream.Core/Physics/ServerControlledLocomotion.cs
Normal file
63
src/AcDream.Core/Physics/ServerControlledLocomotion.cs
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
using System;
|
||||
using System.Numerics;
|
||||
|
||||
namespace AcDream.Core.Physics;
|
||||
|
||||
/// <summary>
|
||||
/// Chooses the visible locomotion cycle for server-controlled remotes whose
|
||||
/// UpdateMotion packet is a MoveToObject/MoveToPosition union rather than an
|
||||
/// InterpretedMotionState.
|
||||
///
|
||||
/// Retail references:
|
||||
/// <list type="bullet">
|
||||
/// <item><description>
|
||||
/// <c>MovementManager::PerformMovement</c> (0x00524440) dispatches movement
|
||||
/// types 6/7 into <c>MoveToManager::MoveToObject/MoveToPosition</c> instead
|
||||
/// of unpacking an InterpretedMotionState.
|
||||
/// </description></item>
|
||||
/// <item><description>
|
||||
/// <c>MovementParameters::UnPackNet</c> (0x0052AC50) shows MoveTo packets
|
||||
/// carry movement params + run rate, not a ForwardCommand field.
|
||||
/// </description></item>
|
||||
/// <item><description>
|
||||
/// ACE <c>MovementData.Write</c> uses the same movement type union; holtburger
|
||||
/// documents the matching <c>MovementType::MoveToPosition = 7</c>.
|
||||
/// </description></item>
|
||||
/// </list>
|
||||
/// </summary>
|
||||
public static class ServerControlledLocomotion
|
||||
{
|
||||
public const float StopSpeed = 0.20f;
|
||||
public const float RunThreshold = 1.25f;
|
||||
public const float MinSpeedMod = 0.25f;
|
||||
public const float MaxSpeedMod = 3.00f;
|
||||
|
||||
public static LocomotionCycle PlanFromVelocity(Vector3 worldVelocity)
|
||||
{
|
||||
float horizontalSpeed = MathF.Sqrt(
|
||||
worldVelocity.X * worldVelocity.X +
|
||||
worldVelocity.Y * worldVelocity.Y);
|
||||
|
||||
if (horizontalSpeed < StopSpeed)
|
||||
return new LocomotionCycle(MotionCommand.Ready, 1f, false);
|
||||
|
||||
if (horizontalSpeed < RunThreshold)
|
||||
{
|
||||
float speedMod = Math.Clamp(
|
||||
horizontalSpeed / MotionInterpreter.WalkAnimSpeed,
|
||||
MinSpeedMod,
|
||||
MaxSpeedMod);
|
||||
return new LocomotionCycle(MotionCommand.WalkForward, speedMod, true);
|
||||
}
|
||||
|
||||
return new LocomotionCycle(
|
||||
MotionCommand.RunForward,
|
||||
Math.Clamp(horizontalSpeed / MotionInterpreter.RunAnimSpeed, MinSpeedMod, MaxSpeedMod),
|
||||
true);
|
||||
}
|
||||
|
||||
public readonly record struct LocomotionCycle(
|
||||
uint Motion,
|
||||
float SpeedMod,
|
||||
bool IsMoving);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue