private void GamePlaySimulation(GameStateManager gameStateManager) { if (inputQueue.Count > 0) { simulationStep = inputQueue.Peek().time; } simulationGameTime.SetElapsedMilliseconds(simulationStep); Update(simulationGameTime, gameStateManager); while(inputQueue.Count >0) { Command nextCommand = inputQueue.Dequeue(); gameStateManager.getFromId(nextCommand.ID).Direction = nextCommand.direction; while(simulationStep > 0) { if(simulationStep > defaultSimulationStep) { simulationGameTime.SetElapsedMilliseconds(defaultSimulationStep); simulationStep -= defaultSimulationStep; } else { simulationGameTime.SetElapsedMilliseconds(simulationStep); simulationStep = 0; } Update(simulationGameTime, gameStateManager); } if(inputQueue.Count > 0) { simulationStep = Convert.ToInt32(NextSimulationStep(nextCommand, inputQueue.Peek())); simulationGameTime.SimulationTime -= simulationStep; } else { simulationGameTime.SimulationTime -= defaultSimulationStep; } } while(simulationGameTime.SimulationTime > 0) { simulationGameTime.SimulationTime -= defaultSimulationStep; simulationGameTime.SetElapsedMilliseconds(defaultSimulationStep); Update(simulationGameTime, gameStateManager); } }