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:
@@ -0,0 +1,53 @@
|
||||
using Unity.Entities;
|
||||
using Unity.Mathematics;
|
||||
|
||||
namespace ProjectM.Simulation
|
||||
{
|
||||
/// <summary>
|
||||
/// MC-2 — a hostile Spitter projectile: a server-spawned, OWNERLESS INTERPOLATED ghost moved server-only in the
|
||||
/// plain SimulationSystemGroup (NOT predicted — like the Husks that fire it). It replicates ONLY the stock
|
||||
/// LocalTransform (no hand-written [GhostField]); this component is server-only state. It deliberately carries NO
|
||||
/// Health, so it is invisible to every WithAll<Health> target loop (player melee/projectile hit-tests can
|
||||
/// never see it — fork 2a: spits are pure dodge/dash checks, NOT shootable). Integrated by
|
||||
/// EnemyProjectileMoveSystem and swept-hit-tested against players + structures by EnemyProjectileDamageSystem.
|
||||
/// </summary>
|
||||
public struct EnemyProjectile : IComponentData
|
||||
{
|
||||
/// <summary>Planar heading (world XZ -> float2 x,y), unit length, locked at spawn.</summary>
|
||||
public float2 Direction;
|
||||
|
||||
/// <summary>Travel speed (world units/second).</summary>
|
||||
public float Speed;
|
||||
|
||||
/// <summary>Damage applied to the first valid same-region target hit.</summary>
|
||||
public float Damage;
|
||||
|
||||
/// <summary>Max travel distance before it expires (world units).</summary>
|
||||
public float Range;
|
||||
|
||||
/// <summary>Accumulated travelled distance (server-only; drives range-expiry).</summary>
|
||||
public float DistanceTravelled;
|
||||
|
||||
/// <summary>Distance moved on the LAST tick (= Speed * the server fixed step). The damage system rebuilds the
|
||||
/// swept segment as cur - Direction*LastStep — NEVER a fresh SystemAPI.Time.DeltaTime (this system runs in the
|
||||
/// PLAIN group where that dt is the wall-frame delta, not the fixed step). Prevents high-speed tunnelling.</summary>
|
||||
public float LastStep;
|
||||
|
||||
/// <summary>Region byte (RegionId.Base/Expedition), copied from the firing Spitter. The damage system skips any
|
||||
/// target whose RegionTag.Region != this — relevancy hides cross-region ghosts from CLIENTS, but the SERVER
|
||||
/// world holds base + expedition players 1000u apart, so server damage needs its OWN region guard.</summary>
|
||||
public byte Region;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Baked subscene singleton: the Spitter projectile ghost prefab + the concurrent soft-cap. The server reads it
|
||||
/// via GetSingleton (the prefab Entity lives HERE, never per-Spitter — mirrors AbilityDatabase / WaveEnemyPrefab).
|
||||
/// MaxLiveProjectiles bounds the RegionRelevancySystem O(ghosts x conn)/tick loop: a Spitter at/over the cap
|
||||
/// soft-fails its shot (no cooldown burn — the EB-2 turret soft-fail pattern).
|
||||
/// </summary>
|
||||
public struct SpitterProjectilePrefab : IComponentData
|
||||
{
|
||||
public Entity Prefab;
|
||||
public int MaxLiveProjectiles;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user