using System.Buffers.Binary; using AcDream.App.Input; using AcDream.App.Rendering; using AcDream.Core.Net.Messages; using AcDream.Core.Net.Packets; using AcDream.Core.Physics; namespace AcDream.App.Tests.Input; public sealed class LocalPlayerOutboundCombatStyleTests { [Theory] [InlineData(0x8000003Cu)] // HandCombat [InlineData(0x8000003Eu)] // Magic [InlineData(0x8000003Fu)] // BowCombat [InlineData(0x80000041u)] // CrossbowCombat public void CaptureAndBuild_PreservesCanonicalRawCombatStyle(uint combatStyle) { var controller = new PlayerMovementController(new PhysicsEngine()); controller.Motion.RawState.CurrentStyle = combatStyle; MovementResult movement = controller.CaptureMovementResult( mouseLookEvent: false); RawMotionState outbound = GameWindow.BuildOutboundRawMotionState( movement); Assert.Equal(combatStyle, movement.CurrentStyle); Assert.Equal(combatStyle, outbound.CurrentStyle); var writer = new PacketWriter(16); RawMotionStatePacker.Pack(writer, outbound); byte[] bytes = writer.ToArray(); uint flags = BinaryPrimitives.ReadUInt32LittleEndian(bytes); Assert.NotEqual(0u, flags & 0x2u); Assert.Equal( combatStyle, BinaryPrimitives.ReadUInt32LittleEndian(bytes.AsSpan(4))); } [Fact] public void CaptureAndBuild_NonCombatRetainsRetailDefault() { var controller = new PlayerMovementController(new PhysicsEngine()); RawMotionState outbound = GameWindow.BuildOutboundRawMotionState( controller.CaptureMovementResult(mouseLookEvent: false)); Assert.Equal(RawMotionState.Default.CurrentStyle, outbound.CurrentStyle); } }