56cf60cce3
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>
50 lines
2.0 KiB
C#
50 lines
2.0 KiB
C#
using NUnit.Framework;
|
|
using ProjectM.Simulation;
|
|
using Unity.Mathematics;
|
|
|
|
namespace ProjectM.Tests
|
|
{
|
|
/// <summary>
|
|
/// MC-2 pure-math tests for the new EnemyAIMath helpers: BandVelocity (Spitter range-band keep-distance) and
|
|
/// ClusterOffset (swarmer pack placement). No ECS world.
|
|
/// </summary>
|
|
public class EnemyAIMathMC2Tests
|
|
{
|
|
[Test]
|
|
public void BandVelocity_AdvancesWhenTooFar()
|
|
{
|
|
var v = EnemyAIMath.BandVelocity(new float3(0, 1, 0), new float3(20, 1, 0), 5f, 9f, 1.5f);
|
|
Assert.Greater(v.x, 0.1f, "too far -> moves toward the target");
|
|
Assert.AreEqual(0f, v.y, 1e-5f, "planar");
|
|
}
|
|
|
|
[Test]
|
|
public void BandVelocity_RetreatsWhenTooClose()
|
|
{
|
|
var v = EnemyAIMath.BandVelocity(new float3(0, 1, 0), new float3(3, 1, 0), 5f, 9f, 1.5f);
|
|
Assert.Less(v.x, -0.1f, "too close -> backs away from the target");
|
|
}
|
|
|
|
[Test]
|
|
public void BandVelocity_HoldsInBand()
|
|
{
|
|
var v = EnemyAIMath.BandVelocity(new float3(0, 1, 0), new float3(9, 1, 0), 5f, 9f, 1.5f);
|
|
Assert.AreEqual(0f, math.length(v), 1e-4f, "inside the dead-zone band -> hold and fire");
|
|
}
|
|
|
|
[Test]
|
|
public void ClusterOffset_SingleAtCentre_PackSpread()
|
|
{
|
|
var c = new float3(100, 1, 5);
|
|
var single = EnemyAIMath.ClusterOffset(c, 0, 1, 2.5f);
|
|
Assert.AreEqual(c.x, single.x, 1e-5f, "a lone swarmer spawns at the pack centre");
|
|
Assert.AreEqual(c.z, single.z, 1e-5f);
|
|
var a = EnemyAIMath.ClusterOffset(c, 0, 4, 2.5f);
|
|
var b = EnemyAIMath.ClusterOffset(c, 1, 4, 2.5f);
|
|
Assert.Greater(math.distance(a, b), 0.01f, "pack members get distinct offsets");
|
|
var again = EnemyAIMath.ClusterOffset(c, 2, 4, 2.5f);
|
|
Assert.AreEqual(0f, math.distance(again, EnemyAIMath.ClusterOffset(c, 2, 4, 2.5f)), 1e-5f, "deterministic");
|
|
}
|
|
}
|
|
}
|