diff --git a/Directory.Build.props b/Directory.Build.props
index 047d29f..32ef4f7 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -4,5 +4,6 @@
$(MSBuildThisFileDirectory)..\Ymir
$(CULTLIB_ROOT)
$(MSBuildThisFileDirectory)..\CultLib
+ Release
diff --git a/README.md b/README.md
index 658af05..7d6e95b 100644
--- a/README.md
+++ b/README.md
@@ -19,21 +19,27 @@ royale, aliens, language design). This repo holds no lore.
- Shrinking `SpectatorRing` perimeter (`Tourist`, `Patron`, and `Exemplar`
tiers with `Neutral` / `Cleared` / `Provoked` stances and Weksa-voiced
`BroadcastFeed` commentary).
- - `TerrainField`: deterministic `1536m x 1536m` desert terrain divided into an
- `8x8` (`192m x 192m`) tile grid with procedural dunes, mesas, salvage pads,
- dirt roads, and runtime crater / tire-track / thermal-scorch stamping.
+ - `TerrainField`: deterministic `1536m x 1536m` desert terrain (`8x8`,
+ `192m x 192m` tile grid) and a `3072m x 3072m` Sion, Switzerland alpine
+ arena (`1025x1025` `3m` DEM heightmap, `6x6` spatial building tiles, `2319`
+ buildings with RCOL collision), plus runtime crater / tire-track /
+ thermal-scorch stamping.
- **`RustToDust.Ymir`**:
- `ArenaSession` bridging `MatchState` onto Ymir's `Box3DSoaWorld` with
- 4-corner spring-damper terrain support, raycast weapons, terrain crater/scorch
- impacts, and AI contenders + perimeter spectators.
+ 4-corner spring-damper terrain support, Sion `StaticHeightField` + `StaticMesh`
+ building physics, raycast weapons, terrain crater/scorch impacts, and AI
+ contenders + perimeter spectators.
- **`tests/RustToDust.Tests`**:
- Behavioral xUnit suite covering Aetheria grid heat, spectator ring clearance,
- Ymir vehicle driving/combat/swapping, and procedural/dynamic terrain relief.
+ Ymir vehicle driving/combat/swapping, procedural/dynamic terrain relief, and
+ Sion map parity + LOS.
- **`client/` (Godot 4.7.2 Mono)**:
- - 3D desert client with a top-down orthographic `SubViewport` brush-to-tile PBR
- + height displacement baker, procedural 3D chassis/spectator silhouettes,
- tactical radar, clickable Aetheria Hardpoint & Heat schematic, and Imperial
- Broadcast chyron.
+ - Dual-arena 3D client (`[M]` switcher or `RTD_MAP=sion`) supporting the
+ procedural desert bake and the `3072m` Sion map (LOD1/LOD2 building tiles),
+ Brokkr mechanical rigs rendered via `MultiMeshPartPool` +
+ `mech_paint.gdshader`, `PomDecalPool` combat scars, tactical radar,
+ clickable Aetheria Hardpoint & Heat schematic, and Imperial Broadcast chyron.
+ - Sion terrain and building data attribution: `"Federal Office of Topography swisstopo"`.
## Build, test, and run
@@ -47,7 +53,7 @@ dotnet test tests/RustToDust.Tests/RustToDust.Tests.csproj -c Release
# Build the Godot 4.7.2 Mono client assembly (also builds Ymir native Box3D)
dotnet build client/RustToDust.Client.csproj -c Debug
-# Run the playable 3D client
+# Run the playable 3D client (press [M] in-game or set RTD_MAP=sion for Sion)
godot --path client
# Run the headless Godot smoke test
@@ -56,6 +62,4 @@ godot --headless --path client res://tests/Smoke.tscn
## Planned, not live yet
-- Kitbashed Brokkr mechanical rigs and goal-space walk/combat retargeting
- replacing the procedural box/cylinder silhouettes.
- Multiplayer networking and audio synthesis.
diff --git a/client/RustToDust.Client.csproj b/client/RustToDust.Client.csproj
index aa56926..188b41b 100644
--- a/client/RustToDust.Client.csproj
+++ b/client/RustToDust.Client.csproj
@@ -9,5 +9,6 @@
+
diff --git a/client/SionMapRenderer.cs b/client/SionMapRenderer.cs
index c00a96b..70d0236 100644
--- a/client/SionMapRenderer.cs
+++ b/client/SionMapRenderer.cs
@@ -17,7 +17,7 @@ public partial class SionMapRenderer : Node3D
public const float Lod1DistanceM = 650f;
public const float CullDistanceM = 2200f;
public const float ShadowDistanceM = 450f;
- private const int ChunkGridVerts = 65; // 64 quads per 512m chunk (8m spacing)
+ private const int ChunkGridVerts = 129; // 128 quads per 512m chunk (4m spacing)
private sealed class BuildingTileEntry
{
@@ -202,7 +202,7 @@ public partial class SionMapRenderer : Node3D
int n = ChunkGridVerts;
float step = tileSize / (n - 1);
- // Precompute shared index buffer for every 65x65 chunk (Godot ArrayMesh cull_back uses CW front-facing winding)
+ // Precompute shared index buffer for every terrain chunk (Godot ArrayMesh cull_back uses CW front-facing winding)
int quadCount = (n - 1) * (n - 1);
var indices = new int[quadCount * 6];
int ii = 0;
diff --git a/src/RustToDust.Core/Broadcast.cs b/src/RustToDust.Core/Broadcast.cs
index 25e3226..85a97eb 100644
--- a/src/RustToDust.Core/Broadcast.cs
+++ b/src/RustToDust.Core/Broadcast.cs
@@ -36,9 +36,11 @@ namespace RustToDust.Core
Version++;
}
- public void EmitMatchStart(float timestamp) =>
+ public void EmitMatchStart(float timestamp, ArenaMapKind mapKind = ArenaMapKind.Desert) =>
Emit(timestamp, BroadcastKind.MatchStart,
- "Imperial Broadcast opens the desert ring. Twelve unvarnished rigs enter for the gallery's amusement.");
+ mapKind == ArenaMapKind.Sion
+ ? "Imperial Broadcast opens the alpine ring over Sion. Twelve unvarnished rigs enter for the gallery's amusement."
+ : "Imperial Broadcast opens the desert ring. Twelve unvarnished rigs enter for the gallery's amusement.");
public void EmitTouristPull(float timestamp, int contenderId) =>
Emit(timestamp, BroadcastKind.TouristPull,
diff --git a/src/RustToDust.Core/MatchRules.cs b/src/RustToDust.Core/MatchRules.cs
index 15ff224..e23f622 100644
--- a/src/RustToDust.Core/MatchRules.cs
+++ b/src/RustToDust.Core/MatchRules.cs
@@ -72,7 +72,7 @@ namespace RustToDust.Core
}
}
- public static void UpdateAiContenders(MatchState state, float dt, LineOfSightCheck? hasLos = null, int tickIndex = -1)
+ public static void UpdateAiContenders(MatchState state, float dt, LineOfSightCheck? hasLos = null)
{
float safeLimit = MathF.Max(30f, state.Spectators.SafeRadius - 25f);
@@ -103,60 +103,36 @@ namespace RustToDust.Core
hasGoal = true;
}
- // 2. Find nearest hostile contender with actual live line-of-sight (staggered on Sion when tickIndex >= 0)
+ // 2. Find nearest hostile contender with actual live line-of-sight
ContenderState? target = null;
float bestEnemyDistSq = 215f * 215f;
float aiEyeY = GetObserverEyeY(ai.Y, ai.Grid.Spec.HalfHeight);
- bool reusePriorTarget = state.MapKind == ArenaMapKind.Sion &&
- tickIndex >= 0 &&
- ((tickIndex + i) & 1) != 0 &&
- ai.AiTargetContenderId.HasValue;
- if (reusePriorTarget)
+ for (int j = 0; j < state.Contenders.Count; j++)
{
- int tid = ai.AiTargetContenderId!.Value;
- if (tid >= 0 && tid < state.Contenders.Count && state.Contenders[tid].Alive)
+ var other = state.Contenders[j];
+ if (other.Id == ai.Id || !other.Alive)
{
- var prior = state.Contenders[tid];
- float dx = prior.X - ai.X;
- float dz = prior.Z - ai.Z;
- float d2 = dx * dx + dz * dz;
- if (d2 < bestEnemyDistSq &&
- (hasLos is null || hasLos(ai.X, aiEyeY, ai.Z, prior.X, GetTargetAimY(prior.Y, prior.Grid.Spec.HalfHeight), prior.Z)))
- {
- bestEnemyDistSq = d2;
- target = prior;
- }
+ continue;
}
- }
- else
- {
- for (int j = 0; j < state.Contenders.Count; j++)
+
+ float dx = other.X - ai.X;
+ float dz = other.Z - ai.Z;
+ float d2 = dx * dx + dz * dz;
+ if (d2 >= bestEnemyDistSq)
{
- var other = state.Contenders[j];
- if (other.Id == ai.Id || !other.Alive)
- {
- continue;
- }
-
- float dx = other.X - ai.X;
- float dz = other.Z - ai.Z;
- float d2 = dx * dx + dz * dz;
- if (d2 >= bestEnemyDistSq)
- {
- continue;
- }
-
- if (hasLos is not null &&
- !hasLos(ai.X, aiEyeY, ai.Z, other.X, GetTargetAimY(other.Y, other.Grid.Spec.HalfHeight), other.Z))
- {
- continue;
- }
-
- bestEnemyDistSq = d2;
- target = other;
+ continue;
}
- ai.AiTargetContenderId = target?.Id;
+
+ if (hasLos is not null &&
+ !hasLos(ai.X, aiEyeY, ai.Z, other.X, GetTargetAimY(other.Y, other.Grid.Spec.HalfHeight), other.Z))
+ {
+ continue;
+ }
+
+ bestEnemyDistSq = d2;
+ target = other;
}
+ ai.AiTargetContenderId = target?.Id;
// 3. Scavenge nearby upgrades when safe
if (!hasGoal && ai.AiScavengeCooldown <= 0f)
diff --git a/src/RustToDust.Core/MatchState.cs b/src/RustToDust.Core/MatchState.cs
index 83360c3..b0d03fc 100644
--- a/src/RustToDust.Core/MatchState.cs
+++ b/src/RustToDust.Core/MatchState.cs
@@ -214,7 +214,7 @@ namespace RustToDust.Core
ScatterInitialLoot();
}
- Broadcast.EmitMatchStart(0f);
+ Broadcast.EmitMatchStart(0f, mapKind);
}
public int Seed { get; }
diff --git a/src/RustToDust.Ymir/ArenaSession.cs b/src/RustToDust.Ymir/ArenaSession.cs
index 027f89e..eadaa7b 100644
--- a/src/RustToDust.Ymir/ArenaSession.cs
+++ b/src/RustToDust.Ymir/ArenaSession.cs
@@ -24,7 +24,6 @@ namespace RustToDust.Ymir
private readonly Dictionary _spectatorBodies = new();
private readonly Dictionary _entityByStableId = new();
private readonly float[] _trackDistAccum = new float[MatchState.ContenderCount];
- private int _tickCount;
private bool _disposed;
public ArenaSession(int seed = 42, ArenaMapKind mapKind = ArenaMapKind.Desert)
@@ -235,7 +234,6 @@ namespace RustToDust.Ymir
ObjectDisposedException.ThrowIf(_disposed, this);
State.Time += FixedDt;
- _tickCount++;
MatchRules.AdvanceTracers(State, FixedDt);
MatchRules.AdvanceHitEvents(State, FixedDt);
State.Spectators.UpdateSafeRadius(State.Time);
@@ -247,7 +245,7 @@ namespace RustToDust.Ymir
{
UpdateRingClearance();
MatchRules.ApplyPlayerInput(State, input);
- MatchRules.UpdateAiContenders(State, FixedDt, HasLineOfSight, _tickCount);
+ MatchRules.UpdateAiContenders(State, FixedDt, HasLineOfSight);
ApplyPhysicsDrives();
_world.Step(FixedDt, subSteps);
@@ -265,7 +263,7 @@ namespace RustToDust.Ymir
UpdateRingClearance();
long t1 = Stopwatch.GetTimestamp();
MatchRules.ApplyPlayerInput(State, input);
- MatchRules.UpdateAiContenders(State, FixedDt, HasLineOfSight, _tickCount);
+ MatchRules.UpdateAiContenders(State, FixedDt, HasLineOfSight);
long t2 = Stopwatch.GetTimestamp();
ApplyPhysicsDrives();
long t3 = Stopwatch.GetTimestamp();
@@ -1150,7 +1148,6 @@ namespace RustToDust.Ymir
float pTargetY = MatchRules.GetTargetAimY(p.Y, p.Grid.Spec.HalfHeight);
int detectedBy = 0;
- bool isSion = State.MapKind == ArenaMapKind.Sion;
for (int i = 0; i < State.Contenders.Count; i++)
{
var c = State.Contenders[i];
@@ -1172,35 +1169,27 @@ namespace RustToDust.Ymir
float dzC = c.Z - p.Z;
float distSqC = dxC * dxC + dzC * dzC;
- bool checkPlayerSees = !isSion || distSqC <= 350f * 350f || (((_tickCount + i) & 3) == 0);
- if (checkPlayerSees)
- {
- bool playerSees = HasLineOfSight(
- p.X, pEyeY, p.Z,
- c.X, MatchRules.GetTargetAimY(c.Y, c.Grid.Spec.HalfHeight), c.Z);
+ bool playerSees = HasLineOfSight(
+ p.X, pEyeY, p.Z,
+ c.X, MatchRules.GetTargetAimY(c.Y, c.Grid.Spec.HalfHeight), c.Z);
- if (playerSees)
- {
- mem.VisibleToPlayer = true;
- mem.FaintHorizonPing = false;
- mem.LastSeenAge = 0f;
- mem.LastSeenX = c.X;
- mem.LastSeenZ = c.Z;
- mem.HasEverBeenSeen = true;
- }
- else
- {
- mem.VisibleToPlayer = false;
- mem.FaintHorizonPing = false;
- if (mem.HasEverBeenSeen)
- {
- mem.LastSeenAge += FixedDt;
- }
- }
- }
- else if (!mem.VisibleToPlayer && mem.HasEverBeenSeen)
+ if (playerSees)
{
- mem.LastSeenAge += FixedDt;
+ mem.VisibleToPlayer = true;
+ mem.FaintHorizonPing = false;
+ mem.LastSeenAge = 0f;
+ mem.LastSeenX = c.X;
+ mem.LastSeenZ = c.Z;
+ mem.HasEverBeenSeen = true;
+ }
+ else
+ {
+ mem.VisibleToPlayer = false;
+ mem.FaintHorizonPing = false;
+ if (mem.HasEverBeenSeen)
+ {
+ mem.LastSeenAge += FixedDt;
+ }
}
if (distSqC <= 240f * 240f &&
@@ -1226,53 +1215,37 @@ namespace RustToDust.Ymir
float sdz = s.Z - p.Z;
float sDistSq = sdx * sdx + sdz * sdz;
- if (isSion && sDistSq > 950f * 950f)
+ bool playerSees = HasLineOfSight(
+ p.X, pEyeY, p.Z,
+ s.X, MatchRules.GetTargetAimY(s.Y, s.Grid.Spec.HalfHeight), s.Z);
+
+ if (playerSees)
+ {
+ mem.VisibleToPlayer = true;
+ mem.FaintHorizonPing = false;
+ mem.LastSeenAge = 0f;
+ mem.LastSeenX = s.X;
+ mem.LastSeenZ = s.Z;
+ mem.HasEverBeenSeen = true;
+ }
+ else
{
mem.VisibleToPlayer = false;
- mem.FaintHorizonPing = false;
if (mem.HasEverBeenSeen)
{
mem.LastSeenAge += FixedDt;
}
- }
- else if (!isSion || (sDistSq <= 450f * 450f ? (((_tickCount + i) & 3) == 0) : (((_tickCount + i) & 7) == 0)))
- {
- bool playerSees = HasLineOfSight(
- p.X, pEyeY, p.Z,
- s.X, MatchRules.GetTargetAimY(s.Y, s.Grid.Spec.HalfHeight), s.Z);
- if (playerSees)
+ // Spectator wall horizon rule: gaudy Tourists (RadarSignature >= 0.9) ping faintly over moderate crests at medium range;
+ // low-signature Exemplars vanish completely when terrain-occluded.
+ bool horizonPing = false;
+ if (s.RadarSignature >= 0.9f && sDistSq <= MatchState.TouristHorizonMaxRange * MatchState.TouristHorizonMaxRange)
{
- mem.VisibleToPlayer = true;
- mem.FaintHorizonPing = false;
- mem.LastSeenAge = 0f;
- mem.LastSeenX = s.X;
- mem.LastSeenZ = s.Z;
- mem.HasEverBeenSeen = true;
+ horizonPing = HasLineOfSight(
+ p.X, pEyeY + 14f, p.Z,
+ s.X, MatchRules.GetTargetAimY(s.Y, s.Grid.Spec.HalfHeight) + 14f, s.Z);
}
- else
- {
- mem.VisibleToPlayer = false;
- if (mem.HasEverBeenSeen)
- {
- mem.LastSeenAge += FixedDt;
- }
-
- // Spectator wall horizon rule: gaudy Tourists (RadarSignature >= 0.9) ping faintly over moderate crests at medium range;
- // low-signature Exemplars vanish completely when terrain-occluded.
- bool horizonPing = false;
- if (s.RadarSignature >= 0.9f && sDistSq <= MatchState.TouristHorizonMaxRange * MatchState.TouristHorizonMaxRange)
- {
- horizonPing = HasLineOfSight(
- p.X, pEyeY + 14f, p.Z,
- s.X, MatchRules.GetTargetAimY(s.Y, s.Grid.Spec.HalfHeight) + 14f, s.Z);
- }
- mem.FaintHorizonPing = horizonPing;
- }
- }
- else if (!mem.VisibleToPlayer && mem.HasEverBeenSeen)
- {
- mem.LastSeenAge += FixedDt;
+ mem.FaintHorizonPing = horizonPing;
}
if (s.Stance != SpectatorStance.Neutral &&
diff --git a/src/RustToDust.Ymir/RustToDust.Ymir.csproj b/src/RustToDust.Ymir/RustToDust.Ymir.csproj
index ad53000..4298e91 100644
--- a/src/RustToDust.Ymir/RustToDust.Ymir.csproj
+++ b/src/RustToDust.Ymir/RustToDust.Ymir.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/tests/RustToDust.Tests/RustToDust.Tests.csproj b/tests/RustToDust.Tests/RustToDust.Tests.csproj
index 95cfcf3..8e36dcc 100644
--- a/tests/RustToDust.Tests/RustToDust.Tests.csproj
+++ b/tests/RustToDust.Tests/RustToDust.Tests.csproj
@@ -16,6 +16,7 @@
+
diff --git a/tests/RustToDust.Tests/SionDetectionLosTests.cs b/tests/RustToDust.Tests/SionDetectionLosTests.cs
new file mode 100644
index 0000000..63cd0a9
--- /dev/null
+++ b/tests/RustToDust.Tests/SionDetectionLosTests.cs
@@ -0,0 +1,413 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using RustToDust.Core;
+using RustToDust.Ymir;
+using Xunit;
+
+namespace RustToDust.Tests
+{
+ public sealed class SionDetectionLosTests
+ {
+ private static (float X, float Z) FindClearBuildingAdjacentSpot(SionMapData sion, float targetX, float targetZ, float pad = 3.5f)
+ {
+ for (int r = 0; r <= 180; r += 6)
+ {
+ for (int a = 0; a < 12; a++)
+ {
+ float ang = a * (MathF.PI / 6f);
+ float x = Math.Clamp(targetX + MathF.Cos(ang) * r, -1450f, 1450f);
+ float z = Math.Clamp(targetZ + MathF.Sin(ang) * r, -1450f, 1450f);
+ if (!sion.IsInsideAnyBuildingXz(x, z, pad))
+ {
+ return (x, z);
+ }
+ if (r == 0) break;
+ }
+ }
+ throw new InvalidOperationException($"No clear Sion spot near ({targetX}, {targetZ})");
+ }
+
+ private static (float X, float Z) FindOpenLosSpotFromPlayer(
+ ArenaSession session,
+ ContenderState player,
+ float minDist,
+ float maxDist,
+ float targetHalfHeight,
+ float baseAngleRad,
+ List<(float X, float Z)>? usedSpots = null)
+ {
+ var sion = session.State.SionMap!;
+ var terrain = session.State.Terrain;
+ float pEyeY = MatchRules.GetObserverEyeY(player.Y, player.Grid.Spec.HalfHeight);
+
+ for (int aStep = 0; aStep < 36; aStep++)
+ {
+ float ang = baseAngleRad + aStep * (MathF.Tau / 36f);
+ for (float r = minDist; r <= maxDist; r += 40f)
+ {
+ float x = player.X + MathF.Cos(ang) * r;
+ float z = player.Z + MathF.Sin(ang) * r;
+ if (MathF.Abs(x) > 1420f || MathF.Abs(z) > 1420f)
+ {
+ continue;
+ }
+ if (sion.IsInsideAnyBuildingXz(x, z, 3.5f))
+ {
+ continue;
+ }
+ if (usedSpots is not null && usedSpots.Any(u => (u.X - x) * (u.X - x) + (u.Z - z) * (u.Z - z) < 25f * 25f))
+ {
+ continue;
+ }
+
+ float targetY = terrain.SampleHeight(x, z) + targetHalfHeight + 0.15f;
+ if (session.HasLineOfSight(player.X, pEyeY, player.Z, x, MatchRules.GetTargetAimY(targetY, targetHalfHeight), z))
+ {
+ return (x, z);
+ }
+ }
+ }
+
+ throw new InvalidOperationException($"No open-LOS Sion spot found in [{minDist}, {maxDist}]m from ({player.X:F1}, {player.Z:F1})");
+ }
+
+ private static (SionBuildingAabb Building, float Z1, float Z2) FindOccludingOldTownBuilding(ArenaSession session, float halfHeight)
+ {
+ var sion = session.State.SionMap!;
+ var terrain = session.State.Terrain;
+ for (int i = 0; i < sion.Buildings.Count; i++)
+ {
+ var b = sion.Buildings[i];
+ if (b.Class != "Gebaeude Einzelhaus" ||
+ b.HalfX < 6f || b.HalfZ < 6f ||
+ (b.RoofY - b.GroundY) < 9f ||
+ MathF.Abs(b.CenterX) > 600f || MathF.Abs(b.CenterZ) > 600f)
+ {
+ continue;
+ }
+
+ float z1 = b.CenterZ - b.HalfZ - 5f;
+ float z2 = b.CenterZ + b.HalfZ + 5f;
+ if (sion.IsInsideAnyBuildingXz(b.CenterX, z1, 3.5f) ||
+ sion.IsInsideAnyBuildingXz(b.CenterX, z2, 3.5f))
+ {
+ continue;
+ }
+
+ float y1 = terrain.SampleHeight(b.CenterX, z1) + halfHeight + 0.15f;
+ float y2 = terrain.SampleHeight(b.CenterX, z2) + halfHeight + 0.15f;
+ if (!session.HasLineOfSight(
+ b.CenterX, MatchRules.GetObserverEyeY(y1, halfHeight), z1,
+ b.CenterX, MatchRules.GetTargetAimY(y2, halfHeight), z2))
+ {
+ return (b, z1, z2);
+ }
+ }
+
+ throw new InvalidOperationException("Expected at least one occluding Sion Old Town building.");
+ }
+
+ private static void SwapToChassis(ArenaSession session, ContenderState c, ChassisSpec chassis, float x, float z)
+ {
+ session.SetContenderPose(c.Id, x, z);
+ if (!string.Equals(c.Grid.Spec.Id, chassis.Id, StringComparison.OrdinalIgnoreCase))
+ {
+ session.State.SpawnChassisDrop(x, z, chassis);
+ Assert.True(session.State.TrySwapNearbyChassis(c.Id));
+ }
+ }
+
+ [Fact]
+ public void Sion_Contenders_ZeroOccludedRadarLeaks_UnderAndOver350m_EveryTick()
+ {
+ using var session = new ArenaSession(seed: 42, ArenaMapKind.Sion);
+ var sion = session.State.SionMap!;
+ var player = session.State.Player;
+ var nearRival = session.State.Contenders[1];
+ var farRival = session.State.Contenders[2];
+
+ // Move unrelated contenders out of the test corridor
+ for (int i = 3; i < session.State.Contenders.Count; i++)
+ {
+ var (ox, oz) = FindClearBuildingAdjacentSpot(sion, -1350f + i * 20f, -1350f);
+ session.SetContenderPose(session.State.Contenders[i].Id, ox, oz);
+ }
+
+ // 1. < 350m occluded across a real Old Town building
+ var (bldg, z1, z2) = FindOccludingOldTownBuilding(session, Catalog.Jackal.HalfHeight);
+ SwapToChassis(session, player, Catalog.Jackal, bldg.CenterX, z1);
+ SwapToChassis(session, nearRival, Catalog.Jackal, bldg.CenterX, z2);
+ float nearDist = MathF.Abs(z2 - z1);
+ Assert.True(nearDist < 350f, $"Expected <350m building test distance, got {nearDist:F1}m");
+
+ // Place farRival far away temporarily while testing nearRival
+ var (tempFarX, tempFarZ) = FindClearBuildingAdjacentSpot(sion, -1300f, 1300f);
+ SwapToChassis(session, farRival, Catalog.Jackal, tempFarX, tempFarZ);
+
+ session.State.ContenderContacts[nearRival.Id] = new PlayerContactMemory();
+ for (int tick = 0; tick < 8; tick++)
+ {
+ session.SetContenderPose(player.Id, bldg.CenterX, z1);
+ session.SetContenderPose(nearRival.Id, bldg.CenterX, z2);
+ Assert.False(session.HasLineOfSight(
+ player.X, MatchRules.GetObserverEyeY(player.Y, player.Grid.Spec.HalfHeight), player.Z,
+ nearRival.X, MatchRules.GetTargetAimY(nearRival.Y, nearRival.Grid.Spec.HalfHeight), nearRival.Z));
+
+ session.Step(new PlayerInput(0f, 0f, player.X, player.Z, false, false, true));
+
+ var mem = session.State.ContenderContacts[nearRival.Id];
+ Assert.False(mem.VisibleToPlayer, $"Occluded <350m Sion contender leaked VisibleToPlayer on tick {tick}");
+ Assert.False(mem.HasEverBeenSeen, $"Occluded <350m Sion contender leaked HasEverBeenSeen on tick {tick}");
+ Assert.False(MatchState.IsContactOnRadar(mem), $"Occluded <350m Sion contender leaked onto radar on tick {tick}");
+ }
+
+ // 2. > 350m occluded across Valere hill (113, -360) vs (113, 80) => ~440m
+ var (southX, southZ) = FindClearBuildingAdjacentSpot(sion, 113f, 80f);
+ var (northX, northZ) = FindClearBuildingAdjacentSpot(sion, 113f, -360f);
+ float farDist = MathF.Sqrt((southX - northX) * (southX - northX) + (southZ - northZ) * (southZ - northZ));
+ Assert.True(farDist > 350f, $"Expected >350m Valere hill test distance, got {farDist:F1}m");
+
+ session.SetContenderPose(player.Id, northX, northZ);
+ session.SetContenderPose(farRival.Id, southX, southZ);
+ session.State.ContenderContacts[farRival.Id] = new PlayerContactMemory();
+
+ for (int tick = 0; tick < 8; tick++)
+ {
+ session.SetContenderPose(player.Id, northX, northZ);
+ session.SetContenderPose(farRival.Id, southX, southZ);
+ Assert.False(session.HasLineOfSight(
+ player.X, MatchRules.GetObserverEyeY(player.Y, player.Grid.Spec.HalfHeight), player.Z,
+ farRival.X, MatchRules.GetTargetAimY(farRival.Y, farRival.Grid.Spec.HalfHeight), farRival.Z));
+
+ session.Step(new PlayerInput(0f, 0f, player.X, player.Z, false, false, true));
+
+ var mem = session.State.ContenderContacts[farRival.Id];
+ Assert.False(mem.VisibleToPlayer, $"Occluded >350m Sion contender leaked VisibleToPlayer on tick {tick}");
+ Assert.False(mem.HasEverBeenSeen, $"Occluded >350m Sion contender leaked HasEverBeenSeen on tick {tick}");
+ Assert.False(MatchState.IsContactOnRadar(mem), $"Occluded >350m Sion contender leaked onto radar on tick {tick}");
+ }
+ }
+
+ [Fact]
+ public void Sion_Contenders_Over350m_OpenLosDetectedImmediatelyOnEveryTickPhase()
+ {
+ // Verify >350m contenders with open LOS are never delayed by mod-4 staggering across contenders 1..4 on tick 0.
+ using var session = new ArenaSession(seed: 42, ArenaMapKind.Sion);
+ var sion = session.State.SionMap!;
+ var player = session.State.Player;
+
+ var (px, pz) = FindClearBuildingAdjacentSpot(sion, 113f, -211f);
+ SwapToChassis(session, player, Catalog.Condor, px, pz);
+ player.TargetHoverAltAgl = Catalog.Condor.HoverMaxAltitudeM;
+ session.SetContenderPose(player.Id, px, pz);
+
+ var tested = new List();
+ var used = new List<(float X, float Z)>();
+ for (int i = 1; i <= 4; i++)
+ {
+ var c = session.State.Contenders[i];
+ SwapToChassis(session, c, Catalog.Jackal, px, pz);
+ var (cx, cz) = FindOpenLosSpotFromPlayer(
+ session,
+ player,
+ minDist: 380f,
+ maxDist: 900f,
+ targetHalfHeight: c.Grid.Spec.HalfHeight,
+ baseAngleRad: i * 0.45f,
+ usedSpots: used);
+ used.Add((cx, cz));
+ session.SetContenderPose(c.Id, cx, cz);
+
+ float dist = MathF.Sqrt((cx - px) * (cx - px) + (cz - pz) * (cz - pz));
+ Assert.True(dist > 350f, $"Expected >350m distance for contender {c.Id}, got {dist:F1}m");
+ Assert.True(session.HasLineOfSight(
+ player.X, MatchRules.GetObserverEyeY(player.Y, player.Grid.Spec.HalfHeight), player.Z,
+ c.X, MatchRules.GetTargetAimY(c.Y, c.Grid.Spec.HalfHeight), c.Z),
+ $"Expected clear elevated LOS to contender {c.Id}");
+
+ session.State.ContenderContacts[c.Id] = new PlayerContactMemory();
+ tested.Add(c);
+ }
+
+ session.Step(new PlayerInput(0f, 0f, player.X, player.Z, false, false, true));
+
+ foreach (var c in tested)
+ {
+ var mem = session.State.ContenderContacts[c.Id];
+ Assert.True(mem.VisibleToPlayer, $"Contender {c.Id} >350m with open LOS missed tick-0 detection (staggering leak)");
+ Assert.True(MatchState.IsContactOnRadar(mem));
+ }
+ }
+
+ [Fact]
+ public void Sion_Spectators_ZeroOccludedLeaks_ZeroTick0Blindspots_AndNo950mHardCull()
+ {
+ using var session = new ArenaSession(seed: 42, ArenaMapKind.Sion);
+ var sion = session.State.SionMap!;
+ var player = session.State.Player;
+
+ // Part 1: Occluded low-signature Exemplar across Valere hill (>450m) never leaks on any tick (0..9)
+ var exemplar = session.State.Spectators.Spectators.First(s => s.Tier == SpectatorTier.Exemplar);
+ var (northX, northZ) = FindClearBuildingAdjacentSpot(sion, 113f, -380f);
+ var (southX, southZ) = FindClearBuildingAdjacentSpot(sion, 113f, 110f);
+ float occDist = MathF.Sqrt((northX - southX) * (northX - southX) + (northZ - southZ) * (northZ - southZ));
+ Assert.True(occDist > 450f, $"Expected >450m Valere occlusion test distance, got {occDist:F1}m");
+
+ SwapToChassis(session, player, Catalog.Jackal, northX, northZ);
+ session.SetSpectatorPose(exemplar.Id, southX, southZ);
+ session.State.SpectatorContacts[exemplar.Id] = new PlayerContactMemory();
+
+ for (int tick = 0; tick < 10; tick++)
+ {
+ session.SetContenderPose(player.Id, northX, northZ);
+ session.SetSpectatorPose(exemplar.Id, southX, southZ);
+ Assert.False(session.HasLineOfSight(
+ player.X, MatchRules.GetObserverEyeY(player.Y, player.Grid.Spec.HalfHeight), player.Z,
+ exemplar.X, MatchRules.GetTargetAimY(exemplar.Y, exemplar.Grid.Spec.HalfHeight), exemplar.Z));
+
+ session.Step(new PlayerInput(0f, 0f, player.X, player.Z, false, false, true));
+
+ var mem = session.State.SpectatorContacts[exemplar.Id];
+ Assert.False(mem.VisibleToPlayer, $"Occluded Sion Exemplar leaked VisibleToPlayer on tick {tick}");
+ Assert.False(mem.FaintHorizonPing, $"Occluded Sion Exemplar leaked FaintHorizonPing on tick {tick}");
+ Assert.False(MatchState.IsContactOnRadar(mem), $"Occluded Sion Exemplar leaked onto radar on tick {tick}");
+ }
+
+ // Part 2: Zero tick-0 open-LOS blindspots across 8 consecutive spectator indices AND no >950m hard cull
+ var (px, pz) = FindClearBuildingAdjacentSpot(sion, 113f, -211f);
+ SwapToChassis(session, player, Catalog.Condor, px, pz);
+ player.TargetHoverAltAgl = Catalog.Condor.HoverMaxAltitudeM;
+ session.SetContenderPose(player.Id, px, pz);
+
+ var openSpecs = new List();
+ var usedSpecSpots = new List<(float X, float Z)>();
+ for (int i = 0; i < 8; i++)
+ {
+ var s = session.State.Spectators.Spectators[i];
+ // Place indices 0..3 within <450m and indices 4..7 >950m away, all with open elevated LOS
+ float minD = i < 4 ? 220f : 980f;
+ float maxD = i < 4 ? 440f : 1380f;
+ var (sx, sz) = FindOpenLosSpotFromPlayer(
+ session,
+ player,
+ minDist: minD,
+ maxDist: maxD,
+ targetHalfHeight: s.Grid.Spec.HalfHeight,
+ baseAngleRad: i * 0.35f,
+ usedSpots: usedSpecSpots);
+ usedSpecSpots.Add((sx, sz));
+ session.SetSpectatorPose(s.Id, sx, sz);
+
+ float actualDist = MathF.Sqrt((sx - px) * (sx - px) + (sz - pz) * (sz - pz));
+ if (i >= 4)
+ {
+ Assert.True(actualDist > 950f, $"Expected >950m spectator test distance, got {actualDist:F1}m");
+ }
+ Assert.True(session.HasLineOfSight(
+ player.X, MatchRules.GetObserverEyeY(player.Y, player.Grid.Spec.HalfHeight), player.Z,
+ s.X, MatchRules.GetTargetAimY(s.Y, s.Grid.Spec.HalfHeight), s.Z),
+ $"Expected open elevated LOS to spectator {s.Id} at dist={actualDist:F1}m");
+
+ session.State.SpectatorContacts[s.Id] = new PlayerContactMemory();
+ openSpecs.Add(s);
+ }
+
+ // Step ONE tick: all 8 spectators (covering all %4 and %8 phases and >950m) must be visible immediately.
+ session.Step(new PlayerInput(0f, 0f, player.X, player.Z, false, false, true));
+
+ foreach (var s in openSpecs)
+ {
+ var mem = session.State.SpectatorContacts[s.Id];
+ float d = MathF.Sqrt((s.X - player.X) * (s.X - player.X) + (s.Z - player.Z) * (s.Z - player.Z));
+ Assert.True(mem.VisibleToPlayer,
+ $"Open-LOS Sion spectator {s.Id} at {d:F1}m missed tick-0 detection (blindspot or >950m hard cull)");
+ Assert.True(MatchState.IsContactOnRadar(mem));
+ }
+ }
+
+ [Fact]
+ public void Sion_AiContender_NoOddTickTargetDropOrTunnelVision()
+ {
+ using var session = new ArenaSession(seed: 42, ArenaMapKind.Sion);
+ var sion = session.State.SionMap!;
+ var player = session.State.Player;
+ var ai = session.State.Contenders[1];
+ var closerRival = session.State.Contenders[2];
+
+ // Isolate player, ai, and closerRival
+ for (int i = 3; i < session.State.Contenders.Count; i++)
+ {
+ var (ox, oz) = FindClearBuildingAdjacentSpot(sion, -1350f + i * 20f, -1350f);
+ session.SetContenderPose(session.State.Contenders[i].Id, ox, oz);
+ }
+
+ // 1. Immediate target switch on BOTH even and odd ticks when a closer threat enters open LOS (no tunnel vision)
+ var (aiX, aiZ) = FindClearBuildingAdjacentSpot(sion, -60f, 360f);
+ var (farX, farZ) = FindClearBuildingAdjacentSpot(sion, -60f, 250f);
+ var (nearX, nearZ) = FindClearBuildingAdjacentSpot(sion, -45f, 330f);
+
+ SwapToChassis(session, ai, Catalog.Jackal, aiX, aiZ);
+ SwapToChassis(session, player, Catalog.Jackal, farX, farZ);
+ var (parkX, parkZ) = FindClearBuildingAdjacentSpot(sion, -1200f, -1200f);
+ SwapToChassis(session, closerRival, Catalog.Jackal, parkX, parkZ);
+
+ Assert.True(session.HasLineOfSight(
+ ai.X, MatchRules.GetObserverEyeY(ai.Y, ai.Grid.Spec.HalfHeight), ai.Z,
+ player.X, MatchRules.GetTargetAimY(player.Y, player.Grid.Spec.HalfHeight), player.Z));
+
+ // Advance 1 tick so ai locks onto player on tick 1
+ session.Step(new PlayerInput(0f, 0f, player.X, player.Z, false, false, true));
+ Assert.Equal(player.Id, ai.AiTargetContenderId);
+
+ // On the next tick (even/odd opposite phase), bring closerRival into open LOS closer than player
+ session.SetContenderPose(ai.Id, aiX, aiZ);
+ session.SetContenderPose(player.Id, farX, farZ);
+ session.SetContenderPose(closerRival.Id, nearX, nearZ);
+ Assert.True(session.HasLineOfSight(
+ ai.X, MatchRules.GetObserverEyeY(ai.Y, ai.Grid.Spec.HalfHeight), ai.Z,
+ closerRival.X, MatchRules.GetTargetAimY(closerRival.Y, closerRival.Grid.Spec.HalfHeight), closerRival.Z));
+
+ session.Step(new PlayerInput(0f, 0f, player.X, player.Z, false, false, true));
+ Assert.Equal(closerRival.Id, ai.AiTargetContenderId);
+
+ // 2. Immediate target drop and FireCmd=false across consecutive ticks when LOS breaks behind a Sion building
+ var (bldg, z1, z2) = FindOccludingOldTownBuilding(session, Catalog.Jackal.HalfHeight);
+ session.SetContenderPose(closerRival.Id, parkX, parkZ);
+
+ for (int phase = 0; phase < 3; phase++)
+ {
+ session.SetContenderPose(ai.Id, bldg.CenterX, z1, yaw: 0f);
+ session.SetContenderPose(player.Id, bldg.CenterX + 12f, z1, yaw: 0f);
+ // Ensure open LOS on same side of building
+ if (!session.HasLineOfSight(
+ ai.X, MatchRules.GetObserverEyeY(ai.Y, ai.Grid.Spec.HalfHeight), ai.Z,
+ player.X, MatchRules.GetTargetAimY(player.Y, player.Grid.Spec.HalfHeight), player.Z))
+ {
+ var (openPx, openPz) = FindClearBuildingAdjacentSpot(sion, bldg.CenterX + 10f, z1);
+ session.SetContenderPose(player.Id, openPx, openPz, yaw: 0f);
+ }
+
+ for (int t = 0; t <= phase; t++)
+ {
+ session.Step(new PlayerInput(0f, 0f, player.X, player.Z, false, false, true));
+ Assert.Equal(player.Id, ai.AiTargetContenderId);
+ Assert.True(ai.FireCmd, $"Expected AI to acquire and fire immediately on Sion (phase={phase}, t={t})");
+ }
+
+ // Break LOS across the Sion building
+ session.SetContenderPose(ai.Id, bldg.CenterX, z1, yaw: 0f);
+ session.SetContenderPose(player.Id, bldg.CenterX, z2, yaw: 0f);
+ for (int occTick = 0; occTick < 6; occTick++)
+ {
+ session.SetContenderPose(ai.Id, bldg.CenterX, z1, yaw: 0f);
+ session.SetContenderPose(player.Id, bldg.CenterX, z2, yaw: 0f);
+ session.Step(new PlayerInput(0f, 0f, player.X, player.Z, false, false, true));
+
+ Assert.Null(ai.AiTargetContenderId);
+ Assert.False(ai.FireCmd, $"AI leaked FireCmd through Sion building on occluded tick {occTick} (phase={phase})");
+ }
+ }
+ }
+ }
+}