LANTERN P1 step 8: light-as-territory relevancy prototype (★)
Per connection, marks every ENEMY ghost OUTSIDE the player's lamp radius IRRELEVANT (monsters in the dark aren't replicated — the gamma test). Modelled on the proven RegionRelevancySystem: SetIsIrrelevant so players/global ghosts stay relevant for free. Shared-set discipline — RegionRelevancySystem is the SOLE clearer (runs every tick); LightRelevancySystem is [UpdateAfter] it and only ADDs light hides via TryAdd (no clear; defensive against a region+light overlap dup). Gated on GymTag (LANTERN-only; legacy region relevancy untouched). Pure decision in LightRelevancyMath (+3 EditMode tests, 500 green). Per-player dim/bright (variable radius) + the L3 gamma-test verification are follow-ups; the ★adversarial netcode review is recommended before this ships. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using NUnit.Framework;
|
||||
using ProjectM.Simulation;
|
||||
using Unity.Mathematics;
|
||||
|
||||
namespace ProjectM.Tests
|
||||
{
|
||||
/// <summary>
|
||||
/// Unit tests for the LANTERN light-as-territory relevancy DECISION (LightRelevancyMath). The full per-connection
|
||||
/// GhostRelevancy set population is netcode-world (the L3 gamma test); this pins the pure planar-distance rule.
|
||||
/// </summary>
|
||||
public class LightRelevancyMathTests
|
||||
{
|
||||
[Test]
|
||||
public void InsideLamp_IsVisible()
|
||||
{
|
||||
float r = LightRelevancyMath.LampRadiusDefault;
|
||||
Assert.IsFalse(LightRelevancyMath.IsHidden(float3.zero, new float3(r - 1f, 0f, 0f), r * r), "just inside the radius = visible");
|
||||
Assert.IsFalse(LightRelevancyMath.IsHidden(float3.zero, float3.zero, r * r), "at the player = visible");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void OutsideLamp_IsHidden()
|
||||
{
|
||||
float r = LightRelevancyMath.LampRadiusDefault;
|
||||
Assert.IsTrue(LightRelevancyMath.IsHidden(float3.zero, new float3(r + 1f, 0f, 0f), r * r), "just beyond the radius = hidden (nothing to see)");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Planar_IgnoresY()
|
||||
{
|
||||
float r = 5f;
|
||||
// Within the planar (XZ) radius but far in Y is still VISIBLE — top-down relevancy ignores height.
|
||||
Assert.IsFalse(LightRelevancyMath.IsHidden(float3.zero, new float3(2f, 1000f, 2f), r * r), "Y is ignored (planar XZ test)");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user