예제 #1
0
        /// <summary>
        /// Wait until pre-flight checks for new vessel are complete.
        /// </summary>
        /// <param name="config">Config.</param>
        static void WaitForVesselPreFlightChecks(LaunchConfig config)
        {
            if (config.error != null)
            {
                throw new InvalidOperationException(config.error);
            }
            if (!config.preFlightChecksComplete)
            {
                throw new YieldException(new ParameterizedContinuationVoid <LaunchConfig>(WaitForVesselPreFlightChecks, config));
            }
            // Check launch site clear
            var vesselsToRecover = ShipConstruction.FindVesselsLandedAt(HighLogic.CurrentGame.flightState, config.LaunchSite);

            if (vesselsToRecover.Any())
            {
                // Recover existing vessels if the launch site is not clear
                if (!config.Recover)
                {
                    throw new InvalidOperationException("Launch site not clear");
                }
                foreach (var vessel in vesselsToRecover)
                {
                    ShipConstruction.RecoverVesselFromFlight(vessel, HighLogic.CurrentGame.flightState, true);
                }
            }
            // Do the actual launch - passed pre-flight checks, and launch site is clear.
            FlightDriver.StartWithNewLaunch(config.Path, EditorLogic.FlagURL, config.LaunchSite, config.manifest);
            throw new YieldException(new ParameterizedContinuationVoid <int>(WaitForVesselSwitch, 0));
        }
예제 #2
0
        /// <summary>
        /// Recover the kerbal when possible (has landed and isn't the active vessel).
        /// </summary>
        /// <param name="asap">Don't wait until the kerbal has landed.</param>
        public IEnumerator RecoverWhenPossible(bool asap = false)
        {
            if (asap)
            {
                if (KerbalSafetyManager.Instance.kerbals.ContainsKey(crew))
                {
                    KerbalSafetyManager.Instance.kerbals.Remove(crew); // Stop managing this kerbal.
                }
            }
            if (recovering)
            {
                yield break;
            }
            recovering = true;
            if (!asap)
            {
                yield return(new WaitUntil(() => kerbalEVA == null || kerbalEVA.vessel.LandedOrSplashed));

                yield return(new WaitForSeconds(5)); // Give it around 5s after landing, then recover the kerbal
            }
            yield return(new WaitUntil(() => kerbalEVA == null || FlightGlobals.ActiveVessel != kerbalEVA.vessel));

            if (kerbalEVA == null)
            {
                Debug.LogError("[BDArmory.KerbalSafety]: " + kerbalName + " on EVA is MIA.");
                yield break;
            }
            Debug.Log("[BDArmory.KerbalSafety]: Recovering " + kerbalName + ".");
            recovered = true;
            ShipConstruction.RecoverVesselFromFlight(kerbalEVA.vessel.protoVessel, HighLogic.CurrentGame.flightState, true);
        }
예제 #3
0
 /// <summary>
 /// Register all the crew members as recovered, then recover the vessel.
 /// </summary>
 /// <param name="vessel">The vessel to recover.</param>
 public void RecoverVesselNow(Vessel vessel)
 {
     foreach (var part in vessel.parts.ToList())
     {
         foreach (var crew in part.protoModuleCrew.ToList())
         {
             if (kerbals.ContainsKey(crew))
             {
                 kerbals[crew].recovered = true;
                 Debug.Log("[BDArmory.KerbalSafety]: Recovering " + kerbals[crew].kerbalName + ".");
                 kerbals[crew].RemoveHandlers();
             }
         }
     }
     ShipConstruction.RecoverVesselFromFlight(vessel.protoVessel, HighLogic.CurrentGame.flightState, true);
 }
예제 #4
0
        public static void DrawClearLaunch(int windowID)
        {
            GUILayout.BeginVertical();
            if (GUILayout.Button("Recover Flight and Proceed"))
            {
                GUIStates.ShowClearLaunch = false;

                List <ProtoVessel> list = ShipConstruction.FindVesselsLandedAt(HighLogic.CurrentGame.flightState, KCTGameStates.LaunchedVessel.LaunchSite);
                foreach (ProtoVessel pv in list)
                {
                    ShipConstruction.RecoverVesselFromFlight(pv, HighLogic.CurrentGame.flightState);
                }

                if (GUIStates.ShowAirlaunch)
                {
                    // Will be shown automatically as soon as GUIStates.showClearLaunch is set to false
                }
                else
                {
                    if (!IsCrewable(KCTGameStates.LaunchedVessel.ExtractedParts))
                    {
                        KCTGameStates.LaunchedVessel.Launch();
                    }
                    else
                    {
                        AssignInitialCrew();
                        GUIStates.ShowShipRoster = true;
                    }
                }
                _centralWindowPosition.height = 1;
            }

            if (GUILayout.Button("Cancel"))
            {
                KCTGameStates.LaunchedVessel  = null;
                GUIStates.ShowClearLaunch     = false;
                GUIStates.ShowAirlaunch       = false;
                GUIStates.ShowBuildList       = true;
                _centralWindowPosition.height = 1;
            }
            GUILayout.EndVertical();
            CenterWindow(ref _centralWindowPosition);
        }