Example #1
0
        /// <summary>
        /// Parachute deployment.
        /// </summary>
        /// <param name="delay">Delay before deploying the chute</param>
        IEnumerator DelayedChuteDeployment(float delay = 1f)
        {
            if (deployingChute)
            {
                yield break;
            }
            deployingChute = true; // Indicate that we're deploying our chute.
            ejected        = true; // Also indicate that we've ejected.
            yield return(new WaitForSeconds(delay));

            if (kerbalEVA == null)
            {
                yield break;
            }
            kerbalEVA.vessel.altimeterDisplayState = AltimeterDisplayState.AGL;
            if (chute != null && !kerbalEVA.IsSeated() && !kerbalEVA.vessel.LandedOrSplashed) // Check that the kerbal hasn't regained their seat or already landed.
            {
                Debug.Log("[BDArmory.KerbalSafety]: " + kerbalName + " is falling, deploying halo parachute at " + kerbalEVA.vessel.radarAltitude + "m.");
                if (chute.deploymentState != ModuleParachute.deploymentStates.SEMIDEPLOYED)
                {
                    chute.deploymentState = ModuleParachute.deploymentStates.STOWED; // Reset the deployment state.
                }
                chute.deployAltitude = 30f;
                chute.Deploy();
            }
            if (kerbalEVA.vessel.LandedOrSplashed)
            {
                Debug.Log("[BDArmory.KerbalSafety]: " + kerbalEVA.vessel.vesselName + " has already landed, not deploying chute.");
            }
            if (FlightGlobals.ActiveVessel == kerbalEVA.vessel)
            {
                LoadedVesselSwitcher.Instance.TriggerSwitchVessel(1f);
            }
        }
Example #2
0
        /// <summary>
        /// Parachute deployment.
        /// </summary>
        /// <param name="delay">Delay before deploying the chute</param>
        IEnumerator DelayedChuteDeployment(float delay = 1f)
        {
            if (deployingChute)
            {
                yield break;
            }
            deployingChute = true; // Indicate that we're deploying our chute.
            ejected        = true; // Also indicate that we've ejected.
            yield return(new WaitForSeconds(delay));

            if (kerbalEVA == null)
            {
                yield break;
            }
            kerbalEVA.vessel.altimeterDisplayState = AltimeterDisplayState.AGL;
            if (chute != null && !kerbalEVA.IsSeated() && !kerbalEVA.vessel.LandedOrSplashed) // Check that the kerbal hasn't regained their seat or already landed.
            {
                Debug.Log("[KerbalSafety]: " + kerbalName + " is falling, deploying halo parachute.");
                if (chute.deploymentState != ModuleParachute.deploymentStates.SEMIDEPLOYED)
                {
                    chute.deploymentState = ModuleParachute.deploymentStates.STOWED; // Reset the deployment state.
                }
                chute.deployAltitude = 30f;
                chute.Deploy();
                // var crew = kerbal.GetComponent<ProtoCrewMember>();
                // if (crew != null && KerbalSafetyManager.Instance.kerbals.ContainsKey(crew.displayName))
                //     StartCoroutine(KerbalSafetyManager.Instance.kerbals[crew.displayName].PostEjection());
            }
            if (kerbalEVA.vessel.LandedOrSplashed)
            {
                Debug.Log("[KerbalSafety]: " + kerbalEVA.vessel.vesselName + " has already landed, not deploying chute.");
            }
        }
Example #3
0
        public IEnumerator deployChute(Vessel v)
        {
            printDebug("Priming chute");
            if (!v.evaController.part.Modules.Contains("ModuleEvaChute"))
            {
                printDebug("No ModuleEvaChute!!! Oops...");
                yield  break;
            }
            printDebug("checking chute module...");
            ModuleEvaChute chuteModule = (ModuleEvaChute)v.evaController.part.Modules ["ModuleEvaChute"];

            printDebug("deployment state: " + chuteModule.deploymentSafeState + "; enabled: " + chuteModule.enabled);
            chuteModule.deploymentSafeState = ModuleParachute.deploymentSafeStates.UNSAFE;             // FIXME: is it immediate???

            printDebug($"counting {paraglidingDeployDelay} sec...");
            yield return(new WaitForSeconds(paraglidingDeployDelay));             // 5 seconds to deploy chute. TODO: Make configurable

            printDebug("Deploying chute");
            chuteModule.Deploy();

            // Set low forward pitch so uncontrolled kerbal doesn't gain lot of speed
            chuteModule.chuteDefaultForwardPitch = paraglidingChutePitch;
        }
        public IEnumerator deployChute(Vessel v, float paraglidingDeployDelay, float paraglidingChutePitch)
        {
            Log.detail("Priming chute - KSP14");
            if (!hasChute(v))
            {
                Log.detail("No ModuleEvaChute!!! Oops...");
                yield break;
            }
            Log.detail("checking chute module...");
            ModuleEvaChute chuteModule = (ModuleEvaChute)v.evaController.part.Modules ["ModuleEvaChute"];

            Log.detail("deployment state: {0}; enabled: {1}", chuteModule.deploymentSafeState, chuteModule.enabled);
            chuteModule.deploymentSafeState = ModuleParachute.deploymentSafeStates.UNSAFE;             // FIXME: is it immediate???

            Log.detail("counting {0} sec...", paraglidingDeployDelay);
            yield return(new WaitForSeconds(paraglidingDeployDelay));             // 5 seconds to deploy chute. TODO: Make configurable

            Log.detail("Deploying chute");
            chuteModule.Deploy();

            // Set low forward pitch so uncontrolled kerbal doesn't gain lot of speed
            chuteModule.chuteDefaultForwardPitch = paraglidingChutePitch;
        }