void OnDestroy() { SWConsole.Verbose("FrameSyncDebugger OnDestroy"); _tcpConnection.OnConnectionEstablished -= _tcpConnection_OnConnectionEstablished; _tcpConnection.OnConnectionNewPacket += _tcpConnection_OnConnectionNewPacket; _tcpConnection.Stop(); _tcpConnection = null; }
public void DidStep(FrameSyncEngine engine, FrameSyncGame game) { if (_watchStarted && game.gameState == FrameSyncGameState.Running) { _watchStarted = false; float ms = _watch.Stop(); SWConsole.Verbose($"Debugger DidStep {game.frameNumber} ms={ms}"); //_watcStarted might be in wrong state if (game.frameNumber == 0) { return; } _debugFrame.frameNumber = game.frameNumber; _debugFrame.elapsedMS = ms; _debugFrame.playerFrameOnServer = engine.PlayerFrameCountOnServer; _debugFrame.localServerFrameCount = engine.LocalServerFrameCount; _debugFrame.inputSampleInterval = FrameSyncTime.internalInputSampleInterval * 1000; _debugFrame.localStepInterval = FrameSyncTime.internalFixedDeltaTime * 1000; SWSystemDataFrame systemDataFrame = engine.GetSystemDataFrame(game.frameNumber); _debugFrame.hash = systemDataFrame.bytes.Crc32(); SWConsole.Verbose($"Debugger DidStep frame hash={_debugFrame.hash}"); InputFrame inputFrame = engine.GetInputFrame(game.frameNumber); FrameSyncInput input = _agent.frameSyncInput; FrameSyncInputConfig inputConfig = input.inputConfig; _debugFrame.inputs.Clear(); foreach (FrameSyncPlayer player in input._Players()) { _debugFrame.inputs[player.PlayerID.ToString()] = player.ExportDictionary(inputConfig, inputFrame.bytes); } _debugFrame.staticBehaviours.Clear(); List <StaticFrameSyncBehaviour> staticFrameSyncBehaviours = new List <StaticFrameSyncBehaviour>(StaticFrameSyncBehaviourManager._behaviours.Values); foreach (StaticFrameSyncBehaviour behaviour in staticFrameSyncBehaviours) { _debugFrame.staticBehaviours[behaviour.FrameSyncBehaviourID.ToString()] = behaviour.ExportDictionary(); } string json = JSONWriter.ToJson(_debugFrame); SWConsole.Verbose(json); if (game.type == FrameSyncGameType.Offline) { SendData(json, 1); } else { SendData(json, game.localPlayer.PlayerID); } } }
public void Initialize(FrameSyncAgent agent) { _tcpConnection = new SWTCPConnection(); _tcpConnection.OnConnectionEstablished += _tcpConnection_OnConnectionEstablished; _tcpConnection.OnConnectionNewPacket += _tcpConnection_OnConnectionNewPacket; SWConsole.Verbose("FrameSyncDebugger Initialized"); _agent = agent; _tcpConnection.Connect(_host, _port); _initialzied = true; }
private void _tcpConnection_OnConnectionEstablished(bool established) { SWConsole.Verbose($"FrameSyncDebugger: TCP Connection Established={established}"); }