Files
Project-M/Assets/_Project/Scripts/Simulation/Combat/ZoneEnemyComponents.cs
T
kronic 3109b86d71 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>
2026-06-21 22:58:26 -07:00

58 lines
2.8 KiB
C#

using Unity.Entities;
namespace ProjectM.Simulation
{
/// <summary>
/// Marker on a runtime-spawned EXPEDITION combat enemy (a Husk variant the server's ZoneEnemyDirectorSystem
/// instantiates in the expedition region). Distinguishes zone enemies from base-siege Husks for the single
/// teardown point in ExpeditionFieldSystem and for the per-epoch clear count. Zone enemies ALSO keep
/// <c>EnemyTag</c> + <c>RegionTag{Expedition}</c>, so Slice-1 readability/health-bars/telegraphs/damage and the
/// per-region AI target filter all work for them unchanged.
/// </summary>
public struct ZoneEnemyTag : IComponentData { }
/// <summary>
/// Baked config for the expedition zone-enemy director (one singleton in the gameplay subscene; the server-only
/// ZoneEnemyDirectorSystem reads it). One epoch-seeded wave per sortie: a <see cref="GruntsPerWave"/> +
/// <see cref="ChargersPerWave"/> baseline that shifts grunt-&gt;charger as the expedition epoch climbs (the
/// highest-leverage variety lever), spawned one every <see cref="SpawnIntervalTicks"/> at a deterministic ring of
/// <see cref="RingSlots"/> slots / <see cref="RingRadius"/> around the expedition origin, capped at
/// <see cref="MaxAlive"/> concurrent (the v1 ghost-relevancy mitigation). On a real clear the returning player
/// banks <see cref="RewardOre"/> to the shared ledger, once per epoch.
/// </summary>
public struct ZoneEnemyDirector : IComponentData
{
public int MaxAlive;
public float RingRadius;
public int RingSlots;
public int SpawnIntervalTicks;
public int GruntsPerWave;
public int ChargersPerWave;
public int RewardOre;
}
/// <summary>
/// Baked pool of zone-enemy prefab variants the director draws from by composition. Index 0 = Grunt variant,
/// index 1 = Charger variant (see <see cref="ZoneEnemyMath.IsChargerSlot"/>). Aliases the existing Husk ghost
/// prefabs so zone enemies reuse the whole combat/readability stack with no new ghost type.
/// </summary>
public struct ZoneEnemyPrefab : IBufferElementData
{
public Entity Prefab;
}
/// <summary>
/// Runtime state of the zone-enemy director (server-only singleton; NOT replicated). Tracks its OWN spawn
/// counter (never WaveState.SpawnCounter), how many enemies remain to spawn for the current epoch's wave, the
/// next spawn tick, and the epoch the current wave was seeded for (re-syncs when CycleRuntime.ExpeditionEpoch
/// bumps). All session-scoped: 0-defaults safely on load (no SaveData field — DR-040 defers SaveData v6).
/// </summary>
public struct ZoneEnemyState : IComponentData
{
public uint SpawnCounter;
public int RemainingToSpawn;
public uint NextSpawnTick;
public int SeededEpoch;
}
}