Ejemplo n.º 1
0
        protected void StartSimulation()
        {
            Profiler.BeginSample("StartSimulation");
            try
            {
                simulationRunning = true;
                resultReady       = false;
                stopwatch.Start(); //starts a timer that times how long the simulation takes

                //Create two FuelFlowSimulations, one for vacuum and one for atmosphere
                List <Part> parts = (HighLogic.LoadedSceneIsEditor ? EditorLogic.fetch.ship.parts : vessel.parts);

                if (HighLogic.LoadedSceneIsEditor)
                {
                    if (needRebuild > 0)
                    {
                        PartSet.BuildPartSets(parts, null);
                        needRebuild--;
                    }
                }
                else
                {
                    vessel.UpdateResourceSetsIfDirty();
                }

                Profiler.BeginSample("StartSimulation_Init");

                sims[0].Init(parts, dVLinearThrust);
                sims[1].Init(parts, dVLinearThrust);

                Profiler.EndSample();

                //Run the simulation in a separate thread
                ThreadPool.QueueUserWorkItem(RunSimulation, sims);
                //Profiler.BeginSample("StartSimulation_Run");
                //RunSimulation(sims);
                //Profiler.EndSample();
            }
            catch (Exception e)
            {
                print("Exception in MechJebModuleStageStats.StartSimulation(): " + e + "\n" + e.StackTrace);

                // Stop timing the simulation
                stopwatch.Stop();
                millisecondsBetweenSimulations = 500;
                stopwatch.Reset();

                // Start counting down the time to the next simulation
                stopwatch.Start();
                simulationRunning = false;
            }
            Profiler.EndSample();
        }
 private void UpdateCrossfeedSets(ShipConstruct ship)
 {
     PartSet.BuildPartSets(ship.parts, null);
 }