protected override unsafe void OnUpdate() { if (ghostStatData == null) { return; } if (socket.AcceptNewConnection()) { socket.SendText(ghostList); } if (!socket.HasConnection) { return; } var connection = connectionGroup.ToComponentDataArray <NetworkSnapshotAckComponent>(Allocator.TempJob); if (connection.Length == 0) { connection.Dispose(); return; } var frame = connection[0].LastReceivedSnapshotByLocal; connection.Dispose(); if (frame <= lastFrame) { return; } if (lastFrame == 0) { lastFrame = frame - 1; } for (lastFrame = lastFrame + 1; lastFrame < frame; ++lastFrame) { for (int i = 0; i < ghostStatData.Length; ++i) { ghostStatData[i] = 0; } socket.SendBinary(ghostStatData, ghostStatData.Length); } var statBytes = (byte *)stats.GetUnsafeReadOnlyPtr(); for (int i = 0; i < ghostStatData.Length; ++i) { ghostStatData[i] = statBytes[i]; } socket.SendBinary(ghostStatData, ghostStatData.Length); }
protected override void OnUpdate() { if (m_Socket.AcceptNewConnection()) { m_StatsCollections = new List <GhostStatsCollectionSystem>(); foreach (var world in World.AllWorlds) { var stats = world.GetExistingSystem <GhostStatsCollectionSystem>(); if (stats != null) { m_StatsCollections.Add(stats); stats.GhostStatCount = 0; } } string legend = "["; for (int i = 0; i < m_StatsCollections.Count; ++i) { if (i > 0) { legend += ",\n"; } legend += String.Format("{{\"name\":\"{0}\",\"ghosts\":{1}}}", m_StatsCollections[i].GetName(), m_StatsCollections[i].GhostList); } legend += "]"; m_Socket.SendText(legend); } if (!m_Socket.HasConnection) { return; } if (m_StatsCollections == null || m_StatsCollections.Count == 0) { return; } for (var con = 0; con < m_StatsCollections.Count; ++con) { for (var i = 0; i < m_StatsCollections[con].GhostStatCount; ++i) { m_StatsCollections[con].GhostStatData[m_StatsCollections[con].GhostStatSize * i] = (byte)con; m_Socket.SendBinary(m_StatsCollections[con].GhostStatData, m_StatsCollections[con].GhostStatSize * i, m_StatsCollections[con].GhostStatSize); } m_StatsCollections[con].GhostStatCount = 0; } }