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() { // Player at world (12, 12, 0) in landblock 0xA9B40000 → cell (0,0). // Landblock origin: 0xA9 = 169 → world X = 169*192 = 32448. // 0xB4 = 180 → world Y = 180*192 = 34560. // Player needs to be in cell (0,0) RELATIVE to landblock origin: // world X = 32448 + 12 = 32460 // world Y = 34560 + 12 = 34572 var candidates = new HashSet(); CellTransit.AddAllOutsideCells( worldSphereCenter: new Vector3(32460f, 34572f, 0f), sphereRadius: 0.5f, currentCellId: 0xA9B40001u, candidates); Assert.Single(candidates); Assert.Contains(0xA9B40001u, candidates); } [Fact] public void SphereAtCellEastBoundary_AddsTwoCells() { // Player at world (32448 + 23.6, 34560 + 12, 0) — near +X edge of cell (0,0). // Sphere reach to localX = 23.6 + 0.5 = 24.1 → cell (1,0) added. var candidates = new HashSet(); CellTransit.AddAllOutsideCells( worldSphereCenter: new Vector3(32448f + 23.6f, 34560f + 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); } }