62e48a3b0b
The 2026-08-06 audit found the shipping scene was still the abandoned co-op-Hades game with LANTERN combat bolted on, and that a third of the codebase was live code for a direction abandoned on 2026-07-13. Operator chose deletion over freezing: "everything is saved in source control if needed. I want the project to be clean." DELETED (~140 source files, Scripts 335->231, Tests 77->43): - Enemy variants + boss (H3). ChargerAuthoring / SpitterAuthoring / SwarmerAuthoring were attached to ZERO prefabs, so LungeState / SpitterState / SwarmerTag were never baked: ~272 lines of Bursted AI passes, BossAISystem (261 lines) and the whole MixBands escalation curve could not match a single chunk at runtime, while 734 lines of green tests certified them. Both shipping enemy prefabs were already byte-identical in stats. - Run/room lifecycle: RunDirector FSM, RunInfo/RunMap/RoomPlan/RoomTag, route select, portal interact, ready-check, room field/teardown. - Meta shop, prep loadout, boons (incl. KillRewardSystem and DashTrailDamageSystem, which existed only to serve boon flags). - Build palette + structures, shared storage, inventory/equipment (already recorded PAUSED in CLAUDE.md). - The HUD panels driving all of the above (HudSystem 1168 -> 610). KEPT deliberately: BaseGridMath + BaseAnchor (8 systems use PlotCenter for spawn rings, respawn and dynamic light), the resource ledger + StorageMath, the save system, region/relevancy. Three of these were in the delete set until I checked their consumers — worth remembering that the file-level manifest was wrong about them. Also folds in audit finding M5: PlayerClass was a second, server-only copy of the byte FrameId already replicates. It existed for the meta shop; with that gone, FrameId is the single frame identity. Harvest is now single-sink (ledger). HarvestMath keeps its shape so LANTERN's carried-vs-banked cargo split lands in one place, not two. 295/295 EditMode green, zero compile errors. Subscene re-bake and Play validation follow in the next commit. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
144 lines
6.7 KiB
C#
144 lines
6.7 KiB
C#
using NUnit.Framework;
|
|
using ProjectM.Server;
|
|
using ProjectM.Simulation;
|
|
using Unity.Core;
|
|
using Unity.Entities;
|
|
using Unity.Mathematics;
|
|
using Unity.NetCode;
|
|
|
|
namespace ProjectM.Tests
|
|
{
|
|
/// <summary>
|
|
/// EditMode coverage for the MC-0/MC-1 DevTelemetry counter WIRING (the fun-gate is measured, not argued):
|
|
/// DashIFrameNegatedHits + DashState.NegatedCount (HealthApplyDamageSystem), DashesWasted (DashSystem
|
|
/// window-close edge, server-gated on the DevTelemetry singleton).
|
|
/// </summary>
|
|
public class TelemetryCountersTests
|
|
{
|
|
static void SetServerTick(World world, uint tick)
|
|
{
|
|
var em = world.EntityManager;
|
|
using var q = em.CreateEntityQuery(typeof(NetworkTime));
|
|
Entity e = q.IsEmpty ? em.CreateEntity(typeof(NetworkTime)) : q.GetSingletonEntity();
|
|
em.SetComponentData(e, new NetworkTime { ServerTick = new NetworkTick(tick) });
|
|
}
|
|
|
|
static (World world, SimulationSystemGroup group) MakeWorld<T>(string name, uint serverTick, bool withTelemetry)
|
|
where T : unmanaged, ISystem
|
|
{
|
|
var world = new World(name);
|
|
var group = world.GetOrCreateSystemManaged<SimulationSystemGroup>();
|
|
group.AddSystemToUpdateList(world.GetOrCreateSystem<T>());
|
|
group.SortSystems();
|
|
world.SetTime(new TimeData(elapsedTime: 0f, deltaTime: 1f / 60f));
|
|
SetServerTick(world, serverTick);
|
|
if (withTelemetry)
|
|
world.EntityManager.CreateEntity(typeof(DevTelemetry));
|
|
return (world, group);
|
|
}
|
|
|
|
static DevTelemetry Telemetry(EntityManager em)
|
|
{
|
|
using var q = em.CreateEntityQuery(typeof(DevTelemetry));
|
|
return q.GetSingleton<DevTelemetry>();
|
|
}
|
|
|
|
static Entity MakeDashingPlayer(EntityManager em, DashState ds)
|
|
{
|
|
var e = em.CreateEntity();
|
|
em.AddComponentData(e, ds);
|
|
em.AddComponentData(e, new DashCooldown { NextTick = 0 });
|
|
em.AddComponentData(e, new CharacterControl { MoveVelocity = float3.zero });
|
|
em.AddComponentData(e, CharacterComponent.GetDefault());
|
|
em.AddComponentData(e, new PlayerInput());
|
|
em.AddComponentData(e, new PlayerFacing { Direction = new float2(0, 1) });
|
|
em.AddComponent<Simulate>(e);
|
|
em.AddComponent<Dead>(e);
|
|
em.SetComponentEnabled<Dead>(e, false);
|
|
return e;
|
|
}
|
|
|
|
|
|
[Test]
|
|
public void Negation_Increments_DevTelemetry_And_DashState_NegatedCount()
|
|
{
|
|
var (world, group) = MakeWorld<HealthApplyDamageSystem>("TelemNegate", 113, withTelemetry: true);
|
|
using (world)
|
|
{
|
|
var em = world.EntityManager;
|
|
var e = em.CreateEntity(typeof(Health), typeof(DamageEvent), typeof(DashState));
|
|
em.SetComponentData(e, new Health { Current = 100f, Max = 100f });
|
|
em.SetComponentData(e, new DashState { StartTick = 100, IFrameUntilTick = 112, RecoverUntilTick = 121 });
|
|
var dmg = em.GetBuffer<DamageEvent>(e);
|
|
dmg.Add(new DamageEvent { Amount = 5f, SourceNetworkId = -1, SourceTick = 101 }); // in-window -> negated
|
|
dmg.Add(new DamageEvent { Amount = 6f, SourceNetworkId = -1, SourceTick = 111 }); // in-window -> negated
|
|
dmg.Add(new DamageEvent { Amount = 7f, SourceNetworkId = -1, SourceTick = 113 }); // outside -> applies
|
|
|
|
group.Update();
|
|
|
|
Assert.AreEqual(2u, Telemetry(em).DashIFrameNegatedHits, "Both in-window hits counted.");
|
|
Assert.AreEqual(2u, em.GetComponentData<DashState>(e).NegatedCount,
|
|
"NegatedCount written back onto DashState (the wasted-dash signal source).");
|
|
Assert.AreEqual(93f, em.GetComponentData<Health>(e).Current, 1e-4f, "Only the outside hit applied.");
|
|
}
|
|
}
|
|
|
|
[Test]
|
|
public void Wasted_Dash_Counts_Once_On_Window_Close_With_Zero_Negations()
|
|
{
|
|
// Window fully elapsed at tick 120 (recover ended at 109) and nothing was negated.
|
|
var (world, group) = MakeWorld<DashSystem>("TelemWasted", 120, withTelemetry: true);
|
|
using (world)
|
|
{
|
|
var em = world.EntityManager;
|
|
var e = MakeDashingPlayer(em, new DashState
|
|
{ Dir = new float2(0, 1), StartTick = 80, IFrameUntilTick = 100, RecoverUntilTick = 109, NegatedCount = 0 });
|
|
|
|
group.Update();
|
|
Assert.AreEqual(1u, Telemetry(em).DashesWasted, "A dash whose window negated nothing scores wasted.");
|
|
Assert.AreEqual(0u, em.GetComponentData<DashState>(e).RecoverUntilTick, "Close edge clears the window (one-shot).");
|
|
|
|
group.Update();
|
|
Assert.AreEqual(1u, Telemetry(em).DashesWasted, "The close edge fires exactly once.");
|
|
}
|
|
}
|
|
|
|
[Test]
|
|
public void Effective_Dash_Is_Not_Wasted()
|
|
{
|
|
var (world, group) = MakeWorld<DashSystem>("TelemEffective", 120, withTelemetry: true);
|
|
using (world)
|
|
{
|
|
var em = world.EntityManager;
|
|
MakeDashingPlayer(em, new DashState
|
|
{ Dir = new float2(0, 1), StartTick = 80, IFrameUntilTick = 100, RecoverUntilTick = 109, NegatedCount = 2 });
|
|
|
|
group.Update();
|
|
Assert.AreEqual(0u, Telemetry(em).DashesWasted, "A dash that negated hits is not wasted.");
|
|
}
|
|
}
|
|
|
|
[Test]
|
|
public void Without_Telemetry_Singleton_The_Close_Edge_Leaves_DashState_Intact()
|
|
{
|
|
// Client-world behavior: no DevTelemetry singleton -> no zeroing, so rollback re-simulation of the
|
|
// tail window stays correct on the client (the server is the only world that clears).
|
|
var (world, group) = MakeWorld<DashSystem>("TelemClientNoZero", 120, withTelemetry: false);
|
|
using (world)
|
|
{
|
|
var em = world.EntityManager;
|
|
var e = MakeDashingPlayer(em, new DashState
|
|
{ Dir = new float2(0, 1), StartTick = 80, IFrameUntilTick = 100, RecoverUntilTick = 109 });
|
|
|
|
group.Update();
|
|
Assert.AreEqual(109u, em.GetComponentData<DashState>(e).RecoverUntilTick,
|
|
"No telemetry singleton (client world): the window is never zeroed by the close edge.");
|
|
}
|
|
}
|
|
|
|
// 2026-08-07 audit purge: the three ChargerWhiffPunishesLanded tests are gone with the Charger. They
|
|
// exercised HealthApplyDamageSystem's LungeState.StaggerUntilTick branch, which no baked prefab could
|
|
// ever reach. The dash-window counters above still cover the telemetry plumbing itself.
|
|
}
|
|
}
|