Slice Combat Depth (MC-2): enemy-variety server spine — Spitter, Swarmer, 4-type mix (DR-041)
Adds the server-authoritative mechanics for three new enemy archetypes on top of the Grunt/Charger base, plus the weighted wave-composition that introduces them: - Spitter: a ranged Husk variant (SpitterState) that holds a preferred range-band (advance/retreat/hold via EnemyAIMath.BandVelocity) and fires a telegraphed, dodgeable EnemyProjectile. New server EnemyProjectileMoveSystem (integrate + store LastStep) + EnemyProjectileDamageSystem (region-filtered swept hit-test rebuilt from LastStep — DR-018 anti-tunnelling; players use HitRadius, structures a const radius; at-most-once destroy). Concurrent-spit soft cap, soft-fail retry. - Swarmer: marker tag + deterministic cluster spawn (1 slot = 1 pack; EnemyAIMath.ClusterOffset), MaxAlive counts ENTITIES so a pack defers if it won't fit. - 4-type weighted mix: MixBands -> ZoneEnemyMath.WaveSlots/KindForSlot/ PackSizeForSlot drives both the expedition director and (fork-4a) the base siege, with a mandatory MaxAlive cap. Legacy WaveSize/IsChargerSlot kept + parity-tested. - Discriminator stays component-presence (no enum in Bursted systems): query- partition guards keep each enemy moved by exactly one EnemyAISystem pass (sole-Position-writer). EnemyTelegraph.IsCharger -> Kind byte for the client cue. New authoring (Spitter/Swarmer/EnemyProjectile) + expanded director authorings with tunable mix/cluster defaults. 13 new EditMode tests (mix composition + legacy parity, band/cluster math, projectile move + cross-region + swept anti-tunnelling regressions); full suite green before commit. Dormant until the prefab/subscene wiring lands (next): the new systems guard on TryGetSingleton/RequireForUpdate, so with no prefabs wired the new types stay inert. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -38,5 +38,66 @@ namespace ProjectM.Simulation
|
||||
int s = ((slot % size) + size) % size;
|
||||
return s >= size - chargers;
|
||||
}
|
||||
|
||||
// ---- MC-2: 4-type weighted composition (Grunt/Charger/Spitter/Swarmer), shared by both directors ----
|
||||
// Kind bytes (NO C# enum — directors index a per-Kind prefab buffer by these; EnemyAISystem is Bursted).
|
||||
public const byte KindGrunt = 0;
|
||||
public const byte KindCharger = 1;
|
||||
public const byte KindSpitter = 2;
|
||||
public const byte KindSwarmer = 3;
|
||||
|
||||
/// <summary>
|
||||
/// Total SLOTS in this epoch/wave under <paramref name="bands"/>: GruntBase + the per-kind ramped counts
|
||||
/// (charger/spitter/swarmer-slot = base + perEpoch*(epoch-1)). Lower-bounded at 1 so there is always a fight.
|
||||
/// A swarmer SLOT expands to a pack at spawn (<see cref="PackSizeForSlot"/>), so this counts packs, not
|
||||
/// individual swarmers. For the LEGACY band it equals <see cref="WaveSize"/> (parity-tested). Pure integer.
|
||||
/// </summary>
|
||||
public static int WaveSlots(int epoch, in MixBands bands)
|
||||
{
|
||||
int e = math.max(1, epoch);
|
||||
int grunts = math.max(0, bands.GruntBase);
|
||||
int chargers = math.max(0, bands.ChargerBase + bands.ChargerPerEpoch * (e - 1));
|
||||
int spitters = math.max(0, bands.SpitterBase + bands.SpitterPerEpoch * (e - 1));
|
||||
int swarmers = math.max(0, bands.SwarmerSlotBase + bands.SwarmerSlotPerEpoch * (e - 1));
|
||||
return math.max(1, grunts + chargers + spitters + swarmers);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deterministic Kind byte for spawn <paramref name="slot"/> of this epoch/wave. Slots are partitioned in a
|
||||
/// FIXED order — Grunts, then Spitters, then Chargers, then Swarmer-slots last — so the wave skews threat-heavy
|
||||
/// as the ramped counts climb (Grunts are the remainder = a fixed floor). Any leftover slot (when the kinds
|
||||
/// under-fill the max(1,..) floor) defaults to Grunt. Stable per (epoch, slot). For the LEGACY band this
|
||||
/// returns KindCharger on exactly the slots the old <see cref="IsChargerSlot"/> did (parity-tested). Pure.
|
||||
/// </summary>
|
||||
public static byte KindForSlot(int epoch, int slot, in MixBands bands)
|
||||
{
|
||||
int e = math.max(1, epoch);
|
||||
int size = WaveSlots(epoch, bands);
|
||||
int chargers = math.max(0, bands.ChargerBase + bands.ChargerPerEpoch * (e - 1));
|
||||
int spitters = math.max(0, bands.SpitterBase + bands.SpitterPerEpoch * (e - 1));
|
||||
int swarmers = math.max(0, bands.SwarmerSlotBase + bands.SwarmerSlotPerEpoch * (e - 1));
|
||||
int grunts = math.max(0, size - chargers - spitters - swarmers); // remainder = fixed grunt floor
|
||||
|
||||
int s = ((slot % size) + size) % size;
|
||||
if (s < grunts) return KindGrunt;
|
||||
s -= grunts;
|
||||
if (s < spitters) return KindSpitter;
|
||||
s -= spitters;
|
||||
if (s < chargers) return KindCharger;
|
||||
s -= chargers;
|
||||
if (s < swarmers) return KindSwarmer;
|
||||
return KindGrunt; // defensive: unreachable while counts sum to size
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Swarmer cluster size for a swarmer slot: <paramref name="basePackSize"/> plus the (default-0)
|
||||
/// <see cref="MixBands.SwarmerPackPerEpoch"/> ramp. Lower-bounded at 1. v1 bakes the ramp 0 -> a fixed pack;
|
||||
/// the field is exposed for later tuning.
|
||||
/// </summary>
|
||||
public static int PackSizeForSlot(int epoch, int slot, in MixBands bands, int basePackSize)
|
||||
{
|
||||
int e = math.max(1, epoch);
|
||||
return math.max(1, basePackSize + math.max(0, bands.SwarmerPackPerEpoch) * (e - 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user