feat(anim): Phase L.1c classify combat animation commands

This commit is contained in:
Erik 2026-04-28 11:37:49 +02:00
parent 268af82e28
commit 831392a7b2
3 changed files with 420 additions and 0 deletions

View file

@ -0,0 +1,74 @@
using AcDream.Core.Combat;
using AcDream.Core.Physics;
using Xunit;
namespace AcDream.Core.Tests.Combat;
public sealed class CombatAnimationPlannerTests
{
[Theory]
[InlineData(0x10000058u, CombatAnimationKind.MeleeSwing)] // ThrustMed
[InlineData(0x1000005Bu, CombatAnimationKind.MeleeSwing)] // SlashHigh
[InlineData(0x10000180u, CombatAnimationKind.MeleeSwing)] // OffhandDoubleThrustMed
[InlineData(0x10000061u, CombatAnimationKind.MissileAttack)] // Shoot
[InlineData(0x100000D4u, CombatAnimationKind.MissileAttack)] // Reload
[InlineData(0x10000062u, CombatAnimationKind.CreatureAttack)] // AttackHigh1
[InlineData(0x1000018Eu, CombatAnimationKind.CreatureAttack)] // AttackLow6
[InlineData(0x400000D3u, CombatAnimationKind.SpellCast)] // CastSpell
[InlineData(0x400000E0u, CombatAnimationKind.SpellCast)] // UseMagicStaff
[InlineData(0x10000051u, CombatAnimationKind.HitReaction)] // Twitch1
[InlineData(0x10000055u, CombatAnimationKind.HitReaction)] // StaggerBackward
[InlineData(0x40000011u, CombatAnimationKind.Death)] // Dead
[InlineData(0x8000003Eu, CombatAnimationKind.CombatStance)] // SwordCombat
public void ClassifyMotionCommand_RecognisesRetailCombatCommands(
uint command,
CombatAnimationKind expected)
{
Assert.Equal(expected, CombatAnimationPlanner.ClassifyMotionCommand(command));
}
[Fact]
public void PlanFromWireCommand_Swing_IsActionOverlay()
{
var plan = CombatAnimationPlanner.PlanFromWireCommand(0x0058, speedMod: 1.25f);
Assert.Equal(CombatAnimationKind.MeleeSwing, plan.Kind);
Assert.Equal(AnimationCommandRouteKind.Action, plan.RouteKind);
Assert.Equal(0x10000058u, plan.MotionCommand);
Assert.Equal(1.25f, plan.SpeedMod);
Assert.True(plan.HasMotion);
}
[Fact]
public void PlanFromWireCommand_Dead_IsPersistentSubState()
{
var plan = CombatAnimationPlanner.PlanFromWireCommand(0x0011);
Assert.Equal(CombatAnimationKind.Death, plan.Kind);
Assert.Equal(AnimationCommandRouteKind.SubState, plan.RouteKind);
Assert.Equal(MotionCommand.Dead, plan.MotionCommand);
}
[Fact]
public void PlanFromWireCommand_Unknown_IsNone()
{
var plan = CombatAnimationPlanner.PlanFromWireCommand(0xFFFF);
Assert.Equal(CombatAnimationPlan.None, plan);
Assert.False(plan.HasMotion);
}
[Theory]
[InlineData(CombatAnimationEvent.CombatCommenceAttack)]
[InlineData(CombatAnimationEvent.AttackDone)]
[InlineData(CombatAnimationEvent.AttackerNotification)]
[InlineData(CombatAnimationEvent.DefenderNotification)]
[InlineData(CombatAnimationEvent.EvasionAttackerNotification)]
[InlineData(CombatAnimationEvent.EvasionDefenderNotification)]
[InlineData(CombatAnimationEvent.VictimNotification)]
[InlineData(CombatAnimationEvent.KillerNotification)]
public void PlanForEvent_DoesNotInventAnimations(CombatAnimationEvent combatEvent)
{
Assert.Equal(CombatAnimationPlan.None, CombatAnimationPlanner.PlanForEvent(combatEvent));
}
}