#if UNITY_EDITOR
using Unity.Collections;
using Unity.Entities;
using Unity.NetCode;
using UnityEngine;
namespace ProjectM.Client
{
///
/// MC-0 — EDITOR-ONLY client receiver for the periodic .
/// Drains the snapshot into (a plain static) so the IMGUI DebugOverlay
/// reads NO ECS state directly (the job-safety rule for presentation). Plain client
/// ; non-Burst (touches a managed static).
///
[WorldSystemFilter(WorldSystemFilterFlags.ClientSimulation)]
[UpdateInGroup(typeof(SimulationSystemGroup))]
public partial struct DevTelemetryReceiveSystem : ISystem
{
public void OnCreate(ref SystemState state)
{
var builder = new EntityQueryBuilder(Allocator.Temp)
.WithAll();
state.RequireForUpdate(state.GetEntityQuery(builder));
}
public void OnUpdate(ref SystemState state)
{
var ecb = new EntityCommandBuffer(Allocator.Temp);
foreach (var (report, reqEntity) in
SystemAPI.Query>()
.WithAll().WithEntityAccess())
{
var r = report.ValueRO;
DevTelemetryReadout.Latest = new DevTelemetryReadout.Snapshot
{
DashIFrameNegatedHits = r.DashIFrameNegatedHits,
DashesWasted = r.DashesWasted,
ChargerWhiffWindowsOpened = r.ChargerWhiffWindowsOpened,
ChargerWhiffPunishesLanded = r.ChargerWhiffPunishesLanded,
LiveEnemyCount = r.LiveEnemyCount,
LastSampleTick = r.LastSampleTick,
};
DevTelemetryReadout.HasData = true;
ecb.DestroyEntity(reqEntity);
}
ecb.Playback(state.EntityManager);
ecb.Dispose();
}
}
///
/// MC-0 — static bridge from the ECS telemetry receiver to the IMGUI DebugOverlay (so the overlay reads
/// a plain struct, never ECS state). Reset on play-enter so a fast-enter-playmode reload can't show stale data.
///
public static class DevTelemetryReadout
{
public struct Snapshot
{
public uint DashIFrameNegatedHits;
public uint DashesWasted;
public uint ChargerWhiffWindowsOpened;
public uint ChargerWhiffPunishesLanded;
public uint LiveEnemyCount;
public uint LastSampleTick;
}
public static Snapshot Latest;
public static bool HasData;
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
static void Reset()
{
Latest = default;
HasData = false;
}
}
}
#endif