private static IEnumerator SetSimOrbit(SimulationParams simParams) { yield return(new WaitForEndOfFrame()); KCTDebug.Log($"Moving vessel to orbit. {simParams.SimulationBody.bodyName}:{simParams.SimOrbitAltitude}:{simParams.SimInclination}"); HyperEdit_Utilities.PutInOrbitAround(simParams.SimulationBody, simParams.SimOrbitAltitude, simParams.SimInclination); }
private void ProcessSimulation() { HighLogic.CurrentGame.Parameters.Flight.CanAutoSave = false; SimulationParams simParams = KCTGameStates.SimulationParams; if (FlightGlobals.ActiveVessel.loaded && !FlightGlobals.ActiveVessel.packed && !simParams.IsVesselMoved) { if (simParams.DisableFailures) { Utilities.ToggleFailures(!simParams.DisableFailures); } if (!simParams.SimulateInOrbit || !FlightDriver.CanRevertToPrelaunch) { // Either the player does not want to start in orbit or they saved and then loaded back into that save simParams.IsVesselMoved = true; return; } int secondsForMove = simParams.DelayMoveSeconds; if (_simMoveDeferTime == DateTime.MaxValue) { _simMoveDeferTime = DateTime.Now; } else if (DateTime.Now.CompareTo(_simMoveDeferTime.AddSeconds(secondsForMove)) > 0) { KCTDebug.Log($"Moving vessel to orbit. {simParams.SimulationBody.bodyName}:{simParams.SimOrbitAltitude}:{simParams.SimInclination}"); HyperEdit_Utilities.PutInOrbitAround(simParams.SimulationBody, simParams.SimOrbitAltitude, simParams.SimInclination); simParams.IsVesselMoved = true; _simMoveDeferTime = DateTime.MaxValue; } if (_simMoveDeferTime != DateTime.MaxValue && _simMoveSecondsRemain != (_simMoveDeferTime.AddSeconds(secondsForMove) - DateTime.Now).Seconds) { double remaining = (_simMoveDeferTime.AddSeconds(secondsForMove) - DateTime.Now).TotalSeconds; ScreenMessages.PostScreenMessage($"Moving vessel in {Math.Round(remaining)} seconds", (float)(remaining - Math.Floor(remaining)), ScreenMessageStyle.UPPER_CENTER); _simMoveSecondsRemain = (int)remaining; } } }