Per-entity render state for the per-instance rendering tier (server-spawned characters / creatures / equipped items). Holds: - partGfxObjOverrides: Dictionary<int, ulong> — AnimPartChange swaps (e.g. wielding a weapon replaces a hand-part's GfxObj). - hiddenMask: ulong — HiddenParts bitmask. Bit i set hides part i. - AnimationSequencer reference — N.4 doesn't touch the sequencer; this just exposes it for the draw dispatcher. Public API: HideParts / IsPartHidden / SetPartOverride / TryGetPartOverride / ResolvePartGfxObj. Bounds-checked (partIdx < 0 or >= 64 → IsPartHidden returns false). Twelve tests covering the type, the AnimPartChange resolution helper, and the HiddenParts bitmask edge cases (theories for 0b0/0b1/MSB/all-ones, plus negative-index + out-of-range guards). Consumed by Task 17's EntitySpawnAdapter (creates one per CreateObject) and Task 22's WbDrawDispatcher (reads via per-part draw loop). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
62 lines
1.7 KiB
C#
62 lines
1.7 KiB
C#
using AcDream.App.Rendering.Wb;
|
|
using AcDream.Core.Physics;
|
|
using DatReaderWriter.DBObjs;
|
|
using Xunit;
|
|
|
|
namespace AcDream.Core.Tests.Rendering.Wb;
|
|
|
|
public sealed class AnimPartChangeTests
|
|
{
|
|
[Fact]
|
|
public void SetPartOverride_ResolvedAtLookup()
|
|
{
|
|
var state = MakeState();
|
|
|
|
state.SetPartOverride(partIdx: 5, gfxObjId: 0x01001234ul);
|
|
|
|
Assert.True(state.TryGetPartOverride(5, out var got));
|
|
Assert.Equal(0x01001234ul, got);
|
|
Assert.False(state.TryGetPartOverride(6, out _));
|
|
}
|
|
|
|
[Fact]
|
|
public void SetPartOverride_TwiceForSamePart_TakesLatest()
|
|
{
|
|
var state = MakeState();
|
|
|
|
state.SetPartOverride(0, 0x01000001ul);
|
|
state.SetPartOverride(0, 0x01999999ul);
|
|
|
|
Assert.True(state.TryGetPartOverride(0, out var got));
|
|
Assert.Equal(0x01999999ul, got);
|
|
}
|
|
|
|
[Fact]
|
|
public void ResolvePartGfxObj_WithoutOverride_ReturnsSetupDefault()
|
|
{
|
|
var state = MakeState();
|
|
|
|
Assert.Equal(0x01000001ul,
|
|
state.ResolvePartGfxObj(partIdx: 0, setupDefault: 0x01000001ul));
|
|
}
|
|
|
|
[Fact]
|
|
public void ResolvePartGfxObj_WithOverride_ReturnsOverride()
|
|
{
|
|
var state = MakeState();
|
|
state.SetPartOverride(partIdx: 0, gfxObjId: 0x01999999ul);
|
|
|
|
Assert.Equal(0x01999999ul,
|
|
state.ResolvePartGfxObj(partIdx: 0, setupDefault: 0x01000001ul));
|
|
}
|
|
|
|
private static AnimatedEntityState MakeState() => new(MakeSequencer());
|
|
|
|
private static AnimationSequencer MakeSequencer()
|
|
=> new AnimationSequencer(new Setup(), new MotionTable(), new NullAnimationLoader());
|
|
|
|
private sealed class NullAnimationLoader : IAnimationLoader
|
|
{
|
|
public Animation? LoadAnimation(uint id) => null;
|
|
}
|
|
}
|