private static CommandFrame Client_Simulate(ClientSimulator simulator, ExampleScene scene, int time, int?expectedCommandSeq = null) { logger.Warn("Begin client simulation: {0}ms", time); simulator.Simulate(); Assert.AreEqual(time + scene.Desc.SimulationDeltaTime, simulator.Time); var frame = simulator.CommandFrame; if (expectedCommandSeq == null) { Assert.IsNull(frame); } else { Assert.AreEqual(1, frame.Commands.Count); Assert.AreEqual(expectedCommandSeq.Value, frame.Commands[0].Sequence); } var ball = (RigidBodySnapshot)scene.Ball.Snapshot; logger.Debug("Ball position: {1}f, {2}f, {3}f", time, ball.Position.X, ball.Position.Y, ball.Position.Z); var cube = (RigidBodySnapshot)scene.Cube.Snapshot; logger.Debug("Cube position: {1}f, {2}f, {3}f", time, cube.Position.X, cube.Position.Y, cube.Position.Z); logger.Warn("End client simulation: {0}ms", time); return(frame); }
public void Update() { if (hasStopRequest) { return; } for (var msg = client.ReadMessage(); msg != null; msg = client.ReadMessage()) { OnClientMessage(msg); } if (isStarted) { simulator.Simulate(); var commandFrame = simulator.CommandFrame; if (commandFrame != null) { SendMessage(commandFrame); } } }