using Unity.Burst; using Unity.Entities; namespace Unity.NetCode.Extensions { [WorldSystemFilter(WorldSystemFilterFlags.LocalSimulation | WorldSystemFilterFlags.ClientSimulation, WorldSystemFilterFlags.LocalSimulation | WorldSystemFilterFlags.ClientSimulation)] public partial class NetCodePanelStats : ComponentSystemGroup { } [UpdateInGroup(typeof(NetCodePanelStats))] public partial struct InitializeNetcodePanelStatsSystem : ISystem { private EntityQuery m_LocalPlayerQuery; public void OnCreate(ref SystemState state) { m_LocalPlayerQuery = state.GetEntityQuery(ComponentType.ReadOnly(), ComponentType.ReadOnly(), ComponentType.ReadOnly(), ComponentType.Exclude()); state.RequireForUpdate(m_LocalPlayerQuery); } [BurstCompile] public void OnUpdate(ref SystemState state) { state.EntityManager.AddComponent(m_LocalPlayerQuery); foreach (var (playerName, ghostOwner, entity) in SystemAPI.Query,RefRO>() .WithAll() .WithEntityAccess()) { var stats = new PlayerStats { NetworkId = ghostOwner.ValueRO.NetworkId, Name = playerName.ValueRO.Name, }; state.EntityManager.SetComponentData(entity, stats); } } } }