acdream/tests/AcDream.Core.Tests/Physics/PhysicsEngineResidencyTests.cs
Erik aba882cec6 feat(teleport B): PhysicsEngine.IsLandblockTerrainResident worldReady query
Adds a high-16-bit-prefix landblock residency check used as the teleport
worldReady gate — true once the destination landblock's terrain+cells
have been registered via AddLandblock, regardless of whether the caller
passes a canonical (0xFFFF), cell-resolved, or bare landblock id.

Two TDD tests confirm: false before registration, true after, and
that a cell-resolved id on the same landblock returns true.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-22 13:05:38 +02:00

34 lines
1.2 KiB
C#

using System;
using System.Numerics;
using AcDream.Core.Physics;
using Xunit;
namespace AcDream.Core.Tests.Physics;
public class PhysicsEngineResidencyTests
{
[Fact]
public void IsLandblockTerrainResident_trueOnlyAfterAddLandblock()
{
var eng = new PhysicsEngine();
uint canonical = 0xA9B4FFFFu; // canonical (streaming) form
uint lbId = canonical & 0xFFFF0000u; // AddLandblock id
Assert.False(eng.IsLandblockTerrainResident(canonical));
eng.AddLandblock(lbId, terrain: null!, cells: Array.Empty<CellSurface>(),
portals: Array.Empty<PortalPlane>(), worldOffsetX: 0f, worldOffsetY: 0f);
Assert.True(eng.IsLandblockTerrainResident(canonical));
}
[Fact]
public void IsLandblockTerrainResident_matchesOnHigh16_acceptsCellResolvedId()
{
var eng = new PhysicsEngine();
eng.AddLandblock(0xA9B40000u, null!, Array.Empty<CellSurface>(),
Array.Empty<PortalPlane>(), 0f, 0f);
Assert.True(eng.IsLandblockTerrainResident(0xA9B40019u)); // cell-resolved id, same LB
Assert.False(eng.IsLandblockTerrainResident(0xC6A90019u)); // different LB
}
}