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:
@@ -126,5 +126,42 @@ namespace ProjectM.Simulation
|
||||
if (sq < bestSq) { bestSq = sq; index = i; isStructure = true; }
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MC-2 Spitter range-band velocity (planar XZ): ADVANCE toward <paramref name="to"/> at
|
||||
/// <paramref name="speed"/> when farther than <paramref name="preferred"/> + <paramref name="tolerance"/>,
|
||||
/// RETREAT directly away when closer than <paramref name="preferred"/> - <paramref name="tolerance"/>, and
|
||||
/// HOLD (zero) inside the dead-zone band. Y forced to 0. Returns zero when the points coincide. Pure /
|
||||
/// Burst-safe / EditMode-testable; keeps the Spitter at its firing distance instead of closing to melee.
|
||||
/// </summary>
|
||||
public static float3 BandVelocity(float3 from, float3 to, float speed, float preferred, float tolerance)
|
||||
{
|
||||
float3 d = to - from;
|
||||
d.y = 0f;
|
||||
float distSq = math.lengthsq(d);
|
||||
if (distSq < 1e-8f)
|
||||
return float3.zero;
|
||||
float dist = math.sqrt(distSq);
|
||||
float3 dir = d / dist;
|
||||
float tol = math.max(0f, tolerance);
|
||||
if (dist > preferred + tol)
|
||||
return dir * speed; // too far -> close in
|
||||
if (dist < preferred - tol)
|
||||
return -dir * speed; // too close -> back off
|
||||
return float3.zero; // in band -> hold and fire
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deterministic tight-cluster offset for swarmer <paramref name="index"/> of a pack of
|
||||
/// <paramref name="packSize"/> around <paramref name="center"/> at <paramref name="tightRadius"/> (reuses the
|
||||
/// <see cref="RingPosition"/> even-angle math at a small radius). A single swarmer (packSize<=1) spawns at
|
||||
/// the centre. Stable per index so a replayed pack lands identically. Pure.
|
||||
/// </summary>
|
||||
public static float3 ClusterOffset(float3 center, int index, int packSize, float tightRadius)
|
||||
{
|
||||
if (packSize <= 1)
|
||||
return center;
|
||||
return RingPosition(center, index, packSize, tightRadius);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user