public bool leavingSeat = false; // Whether the kerbal is about to leave their seat. #endregion #region Field definitions // [KSPField(isPersistant = true, guiActive = true, guiActiveEditor = true, guiName = "#LOC_BDArmory_EjectOnImpendingDoom", // Eject if doomed // groupName = "pilotAI_Ejection", groupDisplayName = "#LOC_BDArmory_PilotAI_Ejection", groupStartCollapsed = true), // UI_FloatRange(minValue = 0f, maxValue = 1f, stepIncrement = 0.02f, scene = UI_Scene.All)] // public float ejectOnImpendingDoom = 0.2f; // Time to impact at which to eject. #endregion /// <summary> /// Begin managing a crew member in a part. /// </summary> /// <param name="crew">The proto crew member.</param> /// <param name="part">The part.</param> public IEnumerator Configure(ProtoCrewMember crew, Part part) { if (crew == null) { Debug.LogError("[KerbalSafety]: Cannot manage null crew."); Destroy(this); yield break; } if (part == null) { Debug.LogError("[KerbalSafety]: Crew cannot exist outside of a part."); Destroy(this); yield break; } while (!part.vessel.loaded) { yield return(new WaitForFixedUpdate()); // Wait for the vessel to be loaded. (Avoids kerbals not being registered in seats.) } kerbalName = crew.displayName; this.crew = crew; this.crew.ResetInventory(); // Reset the inventory to a chute and a jetpack. this.part = part; if (part.IsKerbalEVA()) { this.kerbalEVA = part.GetComponent <KerbalEVA>(); if (kerbalEVA.IsSeated()) { var seats = part.vessel.FindPartModulesImplementing <KerbalSeat>(); bool found = false; foreach (var s in seats) { if (s.Occupant == part) { seat = s; found = true; break; } } if (!found) { Debug.LogError("[KerbalSafety]: Failed to find the kerbal seat that " + kerbalName + " occupies."); yield break; } } else // Free-falling EVA kerbal. { ejected = true; } chute = kerbalEVA.vessel.FindPartModuleImplementing <ModuleEvaChute>(); if (chute != null) { chute.deploymentState = ModuleEvaChute.deploymentStates.STOWED; // Make sure the chute is stowed. } } AddHandlers(); KerbalSafetyManager.Instance.kerbals.Add(crew, this); Debug.Log("[KerbalSafety]: Managing the safety of " + kerbalName + " in " + part.vessel.vesselName + "."); }
public override void OnAwake() { base.OnAwake(); if (chute == null) { chute = part.FindModuleImplementing <ModuleEvaChute>(); } }
public void Start() { kerbal = part.Modules.GetModule <KerbalEVA>(); evaChute = part.Modules.GetModule <ModuleEvaChute>(); inventory = kerbal.ModuleInventoryPartReference; props = PartLoader.LoadedPartsList.Where(p => p.partPrefab.FindModuleImplementing <ModuleWearableProp>()) .ToDictionary(x => x.name, x => x.partPrefab.FindModuleImplementing <ModuleWearableProp>()); InitializeProps(); }
private void ConfigureKerbalEVA(KerbalEVA kerbalEVA) { chute = kerbalEVA.vessel.FindPartModuleImplementing <ModuleEvaChute>(); if (chute != null) { chute.deploymentState = ModuleEvaChute.deploymentStates.STOWED; // Make sure the chute is stowed. } if ((Versioning.version_major == 1 && Versioning.version_minor > 10) || Versioning.version_major > 1) // Introduced in 1.11 { DisableConstructionMode(kerbalEVA); if (BDArmorySettings.KERBAL_SAFETY_INVENTORY == 2) { RemoveJetpack(kerbalEVA); } } }
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; }