private static BooleanValue IsRealTransition(Orbit.PatchTransitionType transition) { return(transition != Orbit.PatchTransitionType.INITIAL && transition != Orbit.PatchTransitionType.FINAL); }
public void ProcessWarpCommand(byte command) { int currentRate = TimeWarp.CurrentRateIndex; switch (command) { case WarpControlValues.warpRate1: TimeWarp.SetRate(0, USE_INSTANT_WARP, DISPLAY_MESSAGE); break; case WarpControlValues.warpRate2: case WarpControlValues.warpRate3: case WarpControlValues.warpRate4: case WarpControlValues.warpRate5: case WarpControlValues.warpRate6: case WarpControlValues.warpRate7: case WarpControlValues.warpRate8: SetWarpRate(command, false); break; case WarpControlValues.warpRatePhys1: TimeWarp.SetRate(0, USE_INSTANT_WARP, DISPLAY_MESSAGE); break; case WarpControlValues.warpRatePhys2: case WarpControlValues.warpRatePhys3: case WarpControlValues.warpRatePhys4: SetWarpRate(command - WarpControlValues.warpRatePhys1, true); break; case WarpControlValues.warpRateUp: int MaxRateIndex = 0; if (TimeWarp.fetch.Mode == TimeWarp.Modes.HIGH) { MaxRateIndex = TimeWarp.fetch.warpRates.Length; } else { MaxRateIndex = TimeWarp.fetch.physicsWarpRates.Length; } if (currentRate < MaxRateIndex) { TimeWarp.SetRate(currentRate + 1, USE_INSTANT_WARP, DISPLAY_MESSAGE); } else { Debug.Log("Simpit : Already at max warp rate."); } break; case WarpControlValues.warpRateDown: if (currentRate > 0) { TimeWarp.SetRate(currentRate - 1, USE_INSTANT_WARP, DISPLAY_MESSAGE); } else { Debug.Log("Simpit : Already at min warp rate."); } break; case WarpControlValues.warpNextManeuver: double timeOfNextManeuver = -1; if (FlightGlobals.ActiveVessel.patchedConicSolver != null) { if (FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes != null) { List <ManeuverNode> maneuvers = FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes; if (maneuvers[0] != null) { timeOfNextManeuver = maneuvers[0].UT; } } } if (timeOfNextManeuver > 0) { safeWarpTo(timeOfNextManeuver); } else { Debug.Log("Simpit : Cannot warp to next maneuver since the next maneuver could not be located"); } break; case WarpControlValues.warpSOIChange: Orbit.PatchTransitionType orbitType = FlightGlobals.ActiveVessel.GetOrbit().patchEndTransition; if (orbitType == Orbit.PatchTransitionType.ENCOUNTER || orbitType == Orbit.PatchTransitionType.ESCAPE) { safeWarpTo(FlightGlobals.ActiveVessel.GetOrbit().EndUT); } else { Debug.Log("Simpit : There is no SOI change to warp to. Orbit type : " + orbitType); } break; case WarpControlValues.warpApoapsis: double timeToApoapsis = FlightGlobals.ActiveVessel.GetOrbit().timeToAp; if (Double.IsNaN(timeToApoapsis) || Double.IsInfinity(timeToApoapsis)) { //This can happen in an escape trajectory for instance Debug.Log("Simpit : Cannot warp to apoasis since there is no apoapsis"); } else { safeWarpTo(Planetarium.GetUniversalTime() + timeToApoapsis); } break; case WarpControlValues.warpPeriapsis: double timeToPeriapsis = FlightGlobals.ActiveVessel.GetOrbit().timeToPe; if (Double.IsNaN(timeToPeriapsis) || Double.IsInfinity(timeToPeriapsis)) { //This can happen in an escape trajectory for instance Debug.Log("Simpit : Cannot warp to periapsis since there is no apoapsis"); } else { safeWarpTo(Planetarium.GetUniversalTime() + timeToPeriapsis); } break; case WarpControlValues.warpNextMorning: Vessel vessel = FlightGlobals.ActiveVessel; if (vessel.situation == Vessel.Situations.LANDED || vessel.situation == Vessel.Situations.SPLASHED || vessel.situation == Vessel.Situations.PRELAUNCH) { double timeToMorning = OrbitalComputations.TimeToDaylight(vessel.latitude, vessel.longitude, vessel.mainBody); safeWarpTo(Planetarium.GetUniversalTime() + timeToMorning); } else { Debug.Log("[SimPit] Cannot warp to next morning if not landed or splashed"); } break; case WarpControlValues.warpCancelAutoWarp: TimeWarp.fetch.CancelAutoWarp(); TimeWarp.SetRate(0, USE_INSTANT_WARP, DISPLAY_MESSAGE); break; default: break; } }