Slice 3: Expedition Combat Spine — epoch-seeded zone waves (DR-040)

Reactivate the dormant Expedition region as a procedural combat venue.
v1 loop: walk the gate -> fight an epoch-seeded enemy wave in the
expedition -> clear -> return -> flat Ore reward (once per epoch) ->
escalated retaliation base siege.

- New sim types: ZoneEnemyTag, ZoneEnemyDirector (+ ZoneEnemyPrefab
  buffer), ZoneEnemyState, ZoneEnemyMath (grunt->charger composition
  by epoch). ZoneEnemyDirectorSystem (server, Burst): drip-spawns the
  wave at a deterministic ring under a MaxAlive cap while a player is
  out and the base is Calm; marks ClearedThisEpoch on a real clear.
  [UpdateAfter(ExpeditionFieldSystem)] only (avoids a sort cycle).
- BLOCKER 1: EnemyAISystem region-filters target selection (player +
  structure snapshots gain parallel region lists; no base structures /
  no Core fallback for expedition husks).
- BLOCKER 3: WaveSystem, ThreatDirectorSystem timeout cull, and
  CyclePhaseSystem DefendCleared + Core-breach cull all count/cull
  RegionTag{Base} husks only (the breach cull was caught region-blind
  by the post-impl review: a base breach wiped the live expedition
  wave and spuriously paid the reward).
- BLOCKER 4: reward de-duped via CycleRuntime.LastRewardedEpoch +
  ClearedThisEpoch; ExpeditionGateSystem deposits RewardOre once/epoch.
- ExpeditionFieldSystem teardown also culls zone enemies + region-
  guards the clutter loop. Subscene wired with the director + roster.

368/368 EditMode green + clean netcode Play smoke. Docs: DR-040 ->
built, session log, CLAUDE.md cross-region tag-reaudit rule.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-21 22:58:26 -07:00
parent cf45ec82ae
commit 3109b86d71
33 changed files with 1044 additions and 161 deletions
@@ -170,5 +170,65 @@ namespace ProjectM.Tests
Assert.AreEqual(-1, idx);
}
// ---- Region-aware PickWeightedNearest (Slice 3: per-region target filter, DR-040 BLOCKER 1) ----
[Test]
public void PickWeightedNearest_Region_BaseHusk_PicksBasePlayer_IgnoringCloserExpedition()
{
using var players = new NativeList<float3>(Allocator.Temp);
using var pRegions = new NativeList<byte>(Allocator.Temp);
using var structs = new NativeList<float3>(Allocator.Temp);
using var sRegions = new NativeList<byte>(Allocator.Temp);
players.Add(new float3(10, 0, 0)); pRegions.Add(RegionId.Base); // base player, far
players.Add(new float3(3, 0, 0)); pRegions.Add(RegionId.Expedition); // expedition player, closer
EnemyAIMath.PickWeightedNearest(float3.zero, players, pRegions, structs, sRegions,
RegionId.Base, 0.7f, out bool isStruct, out int idx);
Assert.IsFalse(isStruct);
Assert.AreEqual(0, idx, "a base Husk targets the base player (idx 0), never the closer expedition player across the gap");
}
[Test]
public void PickWeightedNearest_Region_ExpeditionHusk_PicksExpeditionPlayer()
{
using var players = new NativeList<float3>(Allocator.Temp);
using var pRegions = new NativeList<byte>(Allocator.Temp);
using var structs = new NativeList<float3>(Allocator.Temp);
using var sRegions = new NativeList<byte>(Allocator.Temp);
players.Add(new float3(10, 0, 0)); pRegions.Add(RegionId.Base);
players.Add(new float3(3, 0, 0)); pRegions.Add(RegionId.Expedition);
EnemyAIMath.PickWeightedNearest(float3.zero, players, pRegions, structs, sRegions,
RegionId.Expedition, 0.7f, out bool isStruct, out int idx);
Assert.IsFalse(isStruct);
Assert.AreEqual(1, idx, "an expedition Husk targets the expedition player (idx 1)");
}
[Test]
public void PickWeightedNearest_Region_ExpeditionHusk_NoExpeditionTarget_ReturnsMinusOne()
{
using var players = new NativeList<float3>(Allocator.Temp);
using var pRegions = new NativeList<byte>(Allocator.Temp);
using var structs = new NativeList<float3>(Allocator.Temp);
using var sRegions = new NativeList<byte>(Allocator.Temp);
players.Add(new float3(3, 0, 0)); pRegions.Add(RegionId.Base); // only a base player
structs.Add(new float3(5, 0, 0)); sRegions.Add(RegionId.Base); // only a base structure
EnemyAIMath.PickWeightedNearest(float3.zero, players, pRegions, structs, sRegions,
RegionId.Expedition, 0.7f, out bool isStruct, out int idx);
Assert.AreEqual(-1, idx, "an expedition Husk with only base targets finds nothing in-region -> idles (no Core fallback)");
}
[Test]
public void PickWeightedNearest_Region_BaseHusk_StillRazesBaseStructures()
{
using var players = new NativeList<float3>(Allocator.Temp);
using var pRegions = new NativeList<byte>(Allocator.Temp);
using var structs = new NativeList<float3>(Allocator.Temp);
using var sRegions = new NativeList<byte>(Allocator.Temp);
structs.Add(new float3(0, 0, 12)); sRegions.Add(RegionId.Base);
EnemyAIMath.PickWeightedNearest(float3.zero, players, pRegions, structs, sRegions,
RegionId.Base, 0.7f, out bool isStruct, out int idx);
Assert.IsTrue(isStruct, "a base Husk still targets a base structure (the fortress-aggro path is unchanged in-region)");
Assert.AreEqual(0, idx);
}
}
}