feat(net): Phase 6.6 — parse UpdateMotion (0xF74C) into MotionUpdated event

Server sends UpdateMotion whenever an entity's motion state changes:
NPCs starting a walk cycle, creatures switching to a combat stance,
doors opening, a player waving, etc. Phase 6.1-6.4 already handles
rendering different (stance, forward-command) pairs for the INITIAL
CreateObject, but without this message NPCs freeze in whatever pose
they spawned with and never transition to walking/fighting.

Added UpdateMotion.TryParse with the same ServerMotionState the
CreateObject path uses, reached via a slightly different outer
layout (guid + instance seq + header'd MovementData; the MovementData
starts with the 8-byte sequence/autonomous header this time rather
than being preceded by a length field). Only the (stance, forward-
command) pair is extracted — same subset CreateObject grabs.

WorldSession dispatches MotionUpdated(guid, state) when a 0xF74C
body parses successfully. The App-side wiring (guid→entity lookup
and AnimatedEntity cycle swap) is intentionally deferred to a
separate commit because it touches GameWindow which is currently
being edited by the Phase 9.1 translucent-pass work.

89 Core.Net tests (was 83, +6 for UpdateMotion coverage).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Erik 2026-04-11 20:33:26 +02:00
parent 4752b8a528
commit a71db90310
12 changed files with 675 additions and 45 deletions

View file

@ -1,5 +1,6 @@
using System.Numerics;
using AcDream.Core.Terrain;
using DatReaderWriter;
using DatReaderWriter.DBObjs;
namespace AcDream.Core.Meshing;
@ -10,7 +11,13 @@ public static class GfxObjMesh
/// Walk a GfxObj's polygons and produce one <see cref="GfxObjSubMesh"/>
/// per referenced Surface. Polygons are triangulated as fans.
/// </summary>
public static IReadOnlyList<GfxObjSubMesh> Build(GfxObj gfxObj)
/// <param name="gfxObj">The GfxObj to build sub-meshes from.</param>
/// <param name="dats">
/// Optional dat collection used to read Surface.Type flags and set
/// <see cref="GfxObjSubMesh.Translucency"/>. When null (e.g. offline tests)
/// all sub-meshes default to <see cref="TranslucencyKind.Opaque"/>.
/// </param>
public static IReadOnlyList<GfxObjSubMesh> Build(GfxObj gfxObj, DatCollection? dats = null)
{
// Group output vertices and indices per surface index.
var perSurface = new Dictionary<int, (List<Vertex> Vertices, List<uint> Indices, Dictionary<(int pos, int uv), uint> Dedupe)>();
@ -78,10 +85,24 @@ public static class GfxObjMesh
foreach (var kvp in perSurface)
{
var surfaceId = (uint)gfxObj.Surfaces[kvp.Key];
// Resolve Surface.Type flags when a DatCollection is available so the
// renderer can split the draw into opaque and translucent passes.
var translucency = TranslucencyKind.Opaque;
if (dats is not null)
{
var surface = dats.Get<Surface>(surfaceId);
if (surface is not null)
translucency = TranslucencyKindExtensions.FromSurfaceType(surface.Type);
}
result.Add(new GfxObjSubMesh(
SurfaceId: surfaceId,
Vertices: kvp.Value.Vertices.ToArray(),
Indices: kvp.Value.Indices.ToArray()));
Indices: kvp.Value.Indices.ToArray())
{
Translucency = translucency,
});
}
return result;
}