using System.Collections.Generic; using System.Numerics; using AcDream.Core.Physics; using Xunit; namespace AcDream.Core.Tests.Physics; public class CellTransitAddAllOutsideCellsTests { [Fact] public void SphereWellInsideCell_AddsOneCell() { // A6.P4 (2026-05-24): coords are LANDBLOCK-LOCAL (X/Y in [0, 192]). // Player at landblock-local (12, 12, 0) → cell (0,0) in landblock 0xA9B40000. // Pre-fix this test passed world coords (32460, 34572) and the function // subtracted lbXf=32448 to get local 12. Post-fix the function expects // landblock-local directly. var candidates = new HashSet(); CellTransit.AddAllOutsideCells( worldSphereCenter: new Vector3(12f, 12f, 0f), sphereRadius: 0.5f, currentCellId: 0xA9B40001u, candidates); Assert.Single(candidates); Assert.Contains(0xA9B40001u, candidates); } [Fact] public void SphereAtCellEastBoundary_AddsTwoCells() { // A6.P4 (2026-05-24): landblock-local coords. Player at (23.6, 12, 0) // — near +X edge of cell (0,0). Sphere reaches to local X = 23.6 + 0.5 // = 24.1 → cell (1,0) added. var candidates = new HashSet(); CellTransit.AddAllOutsideCells( worldSphereCenter: new Vector3(23.6f, 12f, 0f), sphereRadius: 0.5f, currentCellId: 0xA9B40001u, candidates); Assert.Equal(2, candidates.Count); Assert.Contains(0xA9B40001u, candidates); // Cell (1,0): low-16 id = 1 * 8 + 0 + 1 = 9 → 0x0009. Assert.Contains(0xA9B40009u, candidates); } }