Tuning Knobs
This commit is contained in:
@@ -165,6 +165,13 @@ namespace ProjectM.Server
|
||||
SystemAPI.SetComponent(cycleEntity, ts);
|
||||
}
|
||||
break;
|
||||
case DebugOp.SetTuning:
|
||||
if (SystemAPI.TryGetSingleton<TuningConfig>(out var tuningCfg))
|
||||
{
|
||||
TuningConfig.Apply(ref tuningCfg, (byte)cmd.ArgA, cmd.ArgB / 1000f);
|
||||
SystemAPI.SetSingleton(tuningCfg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
ecb.DestroyEntity(reqEntity);
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
#if UNITY_EDITOR
|
||||
using ProjectM.Simulation;
|
||||
using Unity.Collections;
|
||||
using Unity.Entities;
|
||||
using Unity.NetCode;
|
||||
|
||||
namespace ProjectM.Server
|
||||
{
|
||||
/// <summary>
|
||||
/// MC-0 — EDITOR-ONLY server owner of the authoritative <see cref="TuningConfig"/> singleton. Ensures+seeds it
|
||||
/// to <see cref="TuningConfig.Defaults"/> in OnCreate, then every <see cref="BroadcastPeriodTicks"/> ships the
|
||||
/// FULL config to every connection as a <see cref="DebugTuningReport"/> (so a PREDICTING client's DashSystem —
|
||||
/// including an MPPM thin client that has no overlay — converges on the tuned values; full state, not a delta,
|
||||
/// so a late-joiner converges in one report). The singleton is mutated by <c>DebugCommandReceiveSystem</c>'s
|
||||
/// SetTuning op (same plain server group). Verbatim <c>DevTelemetrySystem</c> shape. Plain server
|
||||
/// <see cref="SimulationSystemGroup"/> (NOT the predicted loop); non-Burst (managed-simple, editor-only).
|
||||
/// Stripped from builds; the wire TYPE <see cref="DebugTuningReport"/> + <see cref="TuningConfig"/> are
|
||||
/// unconditional, so in a release build no system creates the singleton and consumers fall back to Defaults().
|
||||
/// </summary>
|
||||
[WorldSystemFilter(WorldSystemFilterFlags.ServerSimulation)]
|
||||
[UpdateInGroup(typeof(SimulationSystemGroup))]
|
||||
public partial struct TuningBroadcastSystem : ISystem
|
||||
{
|
||||
const uint BroadcastPeriodTicks = 15;
|
||||
|
||||
public void OnCreate(ref SystemState state)
|
||||
{
|
||||
state.RequireForUpdate<NetworkTime>();
|
||||
if (state.GetEntityQuery(ComponentType.ReadWrite<TuningConfig>()).IsEmpty)
|
||||
{
|
||||
var e = state.EntityManager.CreateEntity(typeof(TuningConfig));
|
||||
state.EntityManager.SetComponentData(e, TuningConfig.Defaults());
|
||||
}
|
||||
}
|
||||
|
||||
public void OnUpdate(ref SystemState state)
|
||||
{
|
||||
var serverTick = SystemAPI.GetSingleton<NetworkTime>().ServerTick;
|
||||
if (!serverTick.IsValid)
|
||||
return;
|
||||
uint now = serverTick.TickIndexForValidTick;
|
||||
if (now == 0 || (now % BroadcastPeriodTicks) != 0)
|
||||
return;
|
||||
|
||||
var report = TuningConfig.ToReport(SystemAPI.GetSingleton<TuningConfig>());
|
||||
|
||||
var ecb = new EntityCommandBuffer(Allocator.Temp);
|
||||
foreach (var (netId, connEnt) in SystemAPI.Query<RefRO<NetworkId>>().WithEntityAccess())
|
||||
{
|
||||
var req = ecb.CreateEntity();
|
||||
ecb.AddComponent(req, report);
|
||||
ecb.AddComponent(req, new SendRpcCommandRequest { TargetConnection = connEnt });
|
||||
}
|
||||
ecb.Playback(state.EntityManager);
|
||||
ecb.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 58b4be546da44eb499b7cba0c7b04ea9
|
||||
Reference in New Issue
Block a user