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
@@ -173,8 +173,9 @@ namespace ProjectM.Tests
ledger.Add(new StorageEntry { ItemId = 2, Count = 100 });
ledger.Add(new StorageEntry { ItemId = 4, Count = 40 });
MakeWaveState(em, waveNumber: 6, phase: WavePhase.Spawning, remainingToSpawn: 3);
em.CreateEntity(typeof(EnemyTag)); // two live husks the team failed to clear
em.CreateEntity(typeof(EnemyTag));
// two live BASE husks the team failed to clear (RegionTag defaults to Region 0 = Base)
em.CreateEntity(typeof(EnemyTag), typeof(RegionTag));
em.CreateEntity(typeof(EnemyTag), typeof(RegionTag));
group.Update();
@@ -193,6 +194,38 @@ namespace ProjectM.Tests
}
}
[Test]
public void Base_Overrun_Disperses_Base_Husks_But_Spares_Expedition_Husks()
{
// Slice 3 regression: a BASE Core breach must NOT wipe an in-progress EXPEDITION wave (both share
// EnemyTag but live in different regions). A region-blind cull would also spuriously trip the zone
// director's aliveZone==0 clear/reward edge on the player's return.
var (world, group) = MakeWorld("BaseOverrunSparesExpedition", serverTick: 200);
using (world)
{
var em = world.EntityManager;
var cycle = MakeCycle(em, CyclePhase.Siege, defendStartWave: 5);
em.AddComponentData(cycle, new GoalProgress { Charge = 3, Target = 10 });
em.AddComponentData(cycle, new CoreIntegrity { Current = 0, Max = 100, OverrunTick = 0 }); // breached
var ledger = em.AddBuffer<StorageEntry>(cycle);
ledger.Add(new StorageEntry { ItemId = 2, Count = 100 });
ledger.Add(new StorageEntry { ItemId = 4, Count = 40 });
MakeWaveState(em, waveNumber: 6, phase: WavePhase.Spawning, remainingToSpawn: 3);
em.CreateEntity(typeof(EnemyTag), typeof(RegionTag)); // BASE husk (RegionTag defaults to Region 0 = Base)
var exp = em.CreateEntity(typeof(EnemyTag), typeof(RegionTag));
em.SetComponentData(exp, new RegionTag { Region = RegionId.Expedition }); // a husk out on the expedition
group.Update();
Assert.IsTrue(em.Exists(exp), "the expedition husk survives a base Core breach.");
using var huskQ = em.CreateEntityQuery(typeof(EnemyTag));
Assert.AreEqual(1, huskQ.CalculateEntityCount(),
"only the BASE husk is dispersed by the breach; the in-progress expedition wave is untouched.");
Assert.AreEqual(RegionId.Expedition, em.GetComponentData<RegionTag>(exp).Region,
"the survivor is the expedition-region husk.");
}
}
[Test]
public void Overrun_Resolves_Once_Then_Stays_Calm_Without_Recharging()
{