public override void OnLoad(ConfigNode node) { if (!CompatibilityChecker.IsCompatible() || !this.part.Modules.Contains("RealChuteModule")) { return; } this.node = node; LoadChutes(); if (node.HasNode("SIZE")) { sizes = new List <SizeNode>(node.GetNodes("SIZE").Select(n => new SizeNode(n))); sizeLib.AddSizes(this.part.name, sizes); } //Top node original location if (this.part.findAttachNode("top") != null) { top = this.part.findAttachNode("top").originalPosition.y; } //Bottom node original location if (this.part.findAttachNode("bottom") != null) { bottom = this.part.findAttachNode("bottom").originalPosition.y; } //Original part size if (debut == 0) { debut = this.part.transform.GetChild(0).localScale.y; } }
public override void OnActive() { if (!CompatibilityChecker.IsCompatible()) { return; } //Activates the part ActivateRC(); }
private void Update() { //Updating of size if possible if (!CompatibilityChecker.IsCompatible()) { return; } if ((!HighLogic.LoadedSceneIsEditor && !HighLogic.LoadedSceneIsFlight) || ((this.part.Modules["RealChuteModule"] != null && !((RealChuteModule)this.part.Modules["RealChuteModule"]).isTweakable))) { return; } if (moduleNodes.Keys.Contains(this.part.partInfo.name) && this.part.transform.GetChild(0).localScale != Vector3.Scale(originalSize, sizes[size].size)) { UpdateScale(this.part, rcModule); } //If unselected if (!HighLogic.LoadedSceneIsEditor || !EditorLogic.fetch || EditorLogic.fetch.editorScreen != EditorLogic.EditorScreen.Actions || !this.part.Modules.Contains("RealChuteModule")) { this.visible = false; return; } //Checks if the part is selected if (actionPanel.GetSelectedParts().Contains(this.part)) { this.visible = true; } else { this.visible = false; this.materialsVisible = false; this.secMaterialsVisible = false; this.failedVisible = false; this.successfulVisible = false; } //Checks if size must update if (moduleNodes.Keys.Contains(this.part.partInfo.name) && lastSize != size) { UpdateScale(this.part, rcModule); } //Checks if case texture must update if (this.textures.caseNames.Length > 0 && lastCaseID != caseID) { UpdateCaseTexture(this.part, rcModule); } main.SwitchType(); if (secondaryChute) { secondary.SwitchType(); } }
private void Awake() { if (!CompatibilityChecker.IsCompatible() || instance != null) { Destroy(this); return; } instance = this; DontDestroyOnLoad(this); print("[RealChute]: Running RealChute " + RCUtils.assemblyVersion); }
public override string GetInfo() { if (!CompatibilityChecker.IsCompatible() || (!HighLogic.LoadedSceneIsEditor && !HighLogic.LoadedSceneIsFlight)) { return(string.Empty); } else if (this.part.Modules.Contains("RealChuteModule") && ((RealChuteModule)this.part.Modules["RealChuteModule"]).isTweakable) { return("This RealChute part can be tweaked from the Action Groups window."); } return(string.Empty); }
public override string GetInfo() { if (!CompatibilityChecker.IsCompatible() || !this.isTweakable) { return(string.Empty); } else if (this.part.Modules.Contains("RealChuteModule")) { return("This RealChute part can be tweaked from the Action Groups window."); } return(string.Empty); }
public override void OnLoad(ConfigNode node) { if (!CompatibilityChecker.IsCompatible()) { return; } //Gets the materials this.node = node; LoadParachutes(); float chuteMass = parachutes.Sum(p => p.mat.areaDensity * p.deployedArea); this.part.mass = caseMass + chuteMass; }
private void OnDestroy() { if (!CompatibilityChecker.IsCompatible()) { return; } RealChuteSettings.SaveSettings(); GameEvents.onGUIAstronautComplexDespawn.Remove(ShowUI); GameEvents.onGUIRnDComplexDespawn.Remove(ShowUI); GameEvents.onGUIMissionControlDespawn.Remove(ShowUI); GameEvents.onGUIAstronautComplexSpawn.Remove(HideUI); GameEvents.onGUIRnDComplexSpawn.Remove(HideUI); GameEvents.onGUIMissionControlSpawn.Remove(HideUI); }
private void OnGUI() { if (!CompatibilityChecker.IsCompatible()) { return; } if (!settings.hideIcon && this.showing) { this.visible = GUI.Toggle(this.button, this.visible, this.buttonTexture, this.buttonStyle); if (this.visible) { this.window = GUILayout.Window(this.id, this.window, Window, "RealChute Settings " + RCUtils.assemblyVersion, skins.window); } } }
private void OnGUI() { //Handles GUI rendering if (!CompatibilityChecker.IsCompatible()) { return; } if (HighLogic.LoadedSceneIsFlight || HighLogic.LoadedSceneIsEditor) { //Info window visibility if (this.visible && !this.hid) { this.window = GUILayout.Window(this.ID, this.window, Window, "RealChute Info Window " + RCUtils.assemblyVersion, skins.window); } } }
public override void OnLoad(ConfigNode node) { if (!CompatibilityChecker.IsCompatible()) { return; } //Gets the materials float chuteMass = materials.MaterialExists(material) ? materials.GetMaterial(material).areaDensity *deployedDiameter : 0; float secChuteMass = 0; if (secondaryChute && materials.MaterialExists(secMaterial)) { secChuteMass = materials.GetMaterial(secMaterial).areaDensity *secDeployedDiameter; } this.part.mass = caseMass + chuteMass + secChuteMass; }
private void OnGUI() { //Rendering manager if (!CompatibilityChecker.IsCompatible()) { return; } if (HighLogic.LoadedSceneIsEditor) { if ((this.part.Modules["RealChuteModule"] != null && !((RealChuteModule)this.part.Modules["RealChuteModule"]).isTweakable)) { return; } if (this.visible) { this.window = GUILayout.Window(this.mainId, this.window, Window, "RealChute Parachute Editor " + RCUtils.assemblyVersion, skins.window, GUILayout.MaxWidth(420), GUILayout.MaxHeight(Screen.height - 375)); } if (this.materialsVisible) { this.materialsWindow = GUILayout.Window(this.matId, this.materialsWindow, main.MaterialsWindow, "Main parachute material", skins.window, GUILayout.MaxWidth(280), GUILayout.MaxHeight(265)); } if (this.secMaterialsVisible) { this.secMaterialsWindow = GUILayout.Window(this.secMatId, this.secMaterialsWindow, secondary.MaterialsWindow, "Secondary parachute material", skins.window, GUILayout.MaxWidth(280), GUILayout.MaxHeight(265)); } if (this.failedVisible) { this.failedWindow = GUILayout.Window(this.failedId, this.failedWindow, ApplicationFailed, "Error", skins.window, GUILayout.MaxWidth(300), GUILayout.MaxHeight(300)); } if (this.successfulVisible) { this.successfulWindow = GUILayout.Window(this.successId, this.successfulWindow, ApplicationSucceeded, "Success", skins.window, GUILayout.MaxWidth(300), GUILayout.MaxHeight(200), GUILayout.ExpandHeight(true)); } if (this.presetVisible) { this.presetsWindow = GUILayout.Window(this.presetID, this.presetsWindow, Presets, "Presets", skins.window, GUILayout.MaxWidth(400), GUILayout.MaxHeight(500)); } if (this.presetSaveVisible) { this.presetsSaveWindow = GUILayout.Window(this.presetSaveId, this.presetsSaveWindow, SavePreset, "Save as preset", skins.window, GUILayout.MaxWidth(350), GUILayout.MaxHeight(400)); } if (this.presetWarningVisible) { this.presetsWarningWindow = GUILayout.Window(this.presetWarningId, this.presetsWarningWindow, PresetWarning, "Warning", skins.window, GUILayout.Width(200), GUILayout.Height(100)); } } }
private void Awake() { if (!CompatibilityChecker.IsCompatible()) { Destroy(this); return; } this.window = new Rect(100, 100, 330, 130); this.button = new Rect(30, 100, 32, 32); this.buttonTexture.LoadImage(File.ReadAllBytes(Path.Combine(RCUtils.pluginDataURL, "RC_Icon.png"))); GameEvents.onGUIAstronautComplexDespawn.Add(ShowUI); GameEvents.onGUIRnDComplexDespawn.Add(ShowUI); GameEvents.onGUIMissionControlDespawn.Add(ShowUI); GameEvents.onGUIAstronautComplexSpawn.Add(HideUI); GameEvents.onGUIRnDComplexSpawn.Add(HideUI); GameEvents.onGUIMissionControlSpawn.Add(HideUI); }
private void OnGUI() { //Rendering manager if (!CompatibilityChecker.IsCompatible() || !this.isTweakable || !this.part.Modules.Contains("RealChuteModule")) { return; } if (HighLogic.LoadedSceneIsEditor) { if (this.visible) { this.window = GUILayout.Window(this.mainId, this.window, Window, "RealChute Parachute Editor " + RCUtils.assemblyVersion, skins.window, GUILayout.MaxWidth(420), GUILayout.MaxHeight(Screen.height - 375)); } foreach (ChuteTemplate chute in chutes) { if (chute.materialsVisible) { chute.materialsWindow = GUILayout.Window(chute.matId, chute.materialsWindow, chute.MaterialsWindow, "Parachute material", skins.window, GUILayout.MaxWidth(375), GUILayout.MaxHeight(275)); } } if (this.failedVisible) { this.failedWindow = GUILayout.Window(this.failedId, this.failedWindow, ApplicationFailed, "Error", skins.window, GUILayout.MaxWidth(300), GUILayout.MaxHeight(300)); } if (this.successfulVisible) { this.successfulWindow = GUILayout.Window(this.successId, this.successfulWindow, ApplicationSucceeded, "Success", skins.window, GUILayout.MaxWidth(300), GUILayout.MaxHeight(200), GUILayout.ExpandHeight(true)); } if (this.presetVisible) { this.presetsWindow = GUILayout.Window(this.presetID, this.presetsWindow, Presets, "Presets", skins.window, GUILayout.MaxWidth(400), GUILayout.MaxHeight(500)); } if (this.presetSaveVisible) { this.presetsSaveWindow = GUILayout.Window(this.presetSaveId, this.presetsSaveWindow, SavePreset, "Save as preset", skins.window, GUILayout.MaxWidth(350), GUILayout.MaxHeight(400)); } if (this.presetWarningVisible) { this.presetsWarningWindow = GUILayout.Window(this.presetWarningId, this.presetsWarningWindow, PresetWarning, "Warning", skins.window, GUILayout.Width(200), GUILayout.Height(100)); } } }
public override void OnLoad(ConfigNode node) { if (!CompatibilityChecker.IsCompatible()) { return; } if ((HighLogic.LoadedSceneIsEditor || HighLogic.LoadedSceneIsFlight) && this.part.Modules.Contains("RealChuteModule") && !((RealChuteModule)this.part.Modules["RealChuteModule"]).isTweakable) { return; } //Size vectors if (node.GetNodes("SIZE").Length > 0 && sizes.Count <= 0) { sizes = node.GetNodes("SIZE").Select(n => new SizeNode(n)).ToList(); moduleNodes.Add(this.part.name, sizes); } //Top node original location if (this.part.findAttachNode("top") != null) { top = this.part.findAttachNode("top").originalPosition.y; } //Bottom node original location if (this.part.findAttachNode("bottom") != null) { bottom = this.part.findAttachNode("bottom").originalPosition.y; } //Original part size if (debut == 0) { debut = this.part.transform.GetChild(0).localScale.y; } }
public override void OnStart(PartModule.StartState state) { if ((!HighLogic.LoadedSceneIsEditor && !HighLogic.LoadedSceneIsFlight) || !CompatibilityChecker.IsCompatible()) { return; } //Identification of the RealChuteModule if (this.part.Modules.Contains("RealChuteModule")) { rcModule = this.part.Modules["RealChuteModule"] as RealChuteModule; } else { return; } if (!rcModule.isTweakable) { return; } secondaryChute = rcModule.secondaryChute; if (textureLibrary != "none") { textureLib.TryGetConfig(textureLibrary, ref textures); } bodies = AtmoPlanets.fetch; main = new ChuteTemplate(this, false); if (secondaryChute) { secondary = new ChuteTemplate(this, true); } //Initialization of sizes if (sizes.Count <= 0 && moduleNodes.Keys.Contains(this.part.partInfo.name)) { print("[RealChute]: Reloading size nodes for " + this.part.partInfo.name); moduleNodes.TryGetValue(this.part.partInfo.name, out sizes); } //Creates an instance of the texture library if (textureLibrary != "none") { cases = textures.caseNames; canopies = textures.canopyNames; models = textures.modelNames; textures.TryGetCase(caseID, type, ref parachuteCase); lastCaseID = caseID; } if (HighLogic.LoadedSceneIsEditor) { //Windows initiation this.window = new Rect(5, 370, 420, Screen.height - 375); this.materialsWindow = new Rect(matX, matY, 375, 280); this.secMaterialsWindow = new Rect(matX, matY, 375, 280); this.failedWindow = new Rect(Screen.width / 2 - 150, Screen.height / 2 - 150, 300, 300); this.successfulWindow = new Rect(Screen.width / 2 - 150, Screen.height / 2 - 25, 300, 50); this.presetsWindow = new Rect(Screen.width / 2 - 200, Screen.height / 2 - 250, 400, 500); this.presetsSaveWindow = new Rect(Screen.width / 2 - 175, Screen.height / 2 - 110, 350, 220); this.presetsWarningWindow = new Rect(Screen.width / 2 - 100, Screen.height / 2 - 50, 200, 100); if (!initiated) { planets = bodies.GetPlanetIndex("Kerbin"); //Gets the original part state if (textureLibrary != "none") { if (textures.TryGetCase(currentCase, ref parachuteCase)) { caseID = textures.GetCaseIndex(parachuteCase); } lastCaseID = caseID; } //Identification of the values from the RealChuteModule mustGoDown = rcModule.mustGoDown; deployOnGround = rcModule.deployOnGround; timer = rcModule.timer + "s"; cutSpeed = rcModule.cutSpeed.ToString(); if (rcModule.spareChutes != -1) { spares = rcModule.spareChutes.ToString(); } originalSize = this.part.transform.GetChild(0).localScale; initiated = true; } } if (parent == null) { parent = this.part.FindModelTransform(rcModule.parachuteName).parent; } //Updates the part if (textureLibrary != "none") { UpdateCaseTexture(this.part, rcModule); } UpdateScale(this.part, rcModule); }
public override void OnStart(PartModule.StartState state) { if (!HighLogic.LoadedSceneIsEditor && !HighLogic.LoadedSceneIsFlight) { return; } if (!CompatibilityChecker.IsCompatible()) { foreach (BaseAction action in Actions) { action.active = false; } foreach (BaseEvent evnt in Events) { evnt.active = false; evnt.guiActive = false; evnt.guiActiveEditor = false; } foreach (BaseField field in Fields) { field.guiActive = false; field.guiActiveEditor = false; } return; } //Staging icon this.part.stagingIcon = "PARACHUTES"; //Autoarming checkup settings = RealChuteSettings.fetch; //Part GUI Events["GUIDeploy"].active = true; Events["GUICut"].active = false; Events["GUISecCut"].active = false; Events["GUIArm"].active = true; Events["GUICutBoth"].active = false; Events["GUIRepack"].guiActiveUnfocused = false; if (spareChutes < 0) { Fields["chuteCount"].guiActive = false; } if (!secondaryChute) { Actions["ActionSecCut"].active = false; Actions["ActionCutBoth"].active = false; Actions["ActionCut"].guiName = "Cut chute"; Events["GUICut"].guiName = "Cut chute"; } if (settings.autoArm) { Events["GUIArm"].active = false; Actions["ActionArm"].active = false; } else { Events["GUIArm"].active = true; Actions["ActionArm"].active = true; } //Tweakables tooltip if (this.part.Modules.Contains("ProceduralChute") || !isTweakable) { foreach (BaseField field in Fields) { field.guiActiveEditor = false; } } else if (!secondaryChute) { Fields["secPreDeployedDiameter"].guiActiveEditor = false; Fields["secDeployedDiameter"].guiActiveEditor = false; Fields["secMinIsPressure"].guiActiveEditor = false; Fields["secMinDeployment"].guiActiveEditor = false; Fields["secMinPressure"].guiActiveEditor = false; Fields["secDeploymentAlt"].guiActiveEditor = false; Fields["secCutAlt"].guiActiveEditor = false; Fields["secPreDeploymentSpeed"].guiActiveEditor = false; Fields["secDeploymentSpeed"].guiActiveEditor = false; } //Initiates animations anim = this.part.FindModelAnimators(capName).FirstOrDefault(); //Initiates the Parachutes main = new Parachute(this, false); if (secondaryChute) { secondary = new Parachute(this, true); } //First initiation of the part if (!initiated) { initiated = true; capOff = false; armed = false; this.baseDrag = this.part.maximum_drag; if (spareChutes >= 0) { chuteCount = (int)spareChutes; } } //Flight loading if (HighLogic.LoadedSceneIsFlight) { //If the part has been staged in the past if (capOff) { this.part.stackIcon.SetIconColor(XKCDColors.Red); } System.Random random = new System.Random(); main.randomTime = (float)random.NextDouble(); if (secondaryChute) { secondary.randomTime = (float)random.NextDouble(); } } //GUI window = new Rect(200, 100, 350, 400); }
public override string GetInfo() { if (!CompatibilityChecker.IsCompatible()) { return(string.Empty); } //Info in the editor part window float chuteMass = parachutes.Sum(p => p.mat.areaDensity * p.deployedArea); this.part.mass = caseMass + chuteMass; StringBuilder builder = new StringBuilder(); builder.AppendFormat("Case mass: {0}\n", caseMass); if (timer > 0) { builder.AppendFormat("Deployment timer: {0}s\n", timer); } if (mustGoDown) { builder.AppendLine("Must go downwards to deploy: true"); } if (deployOnGround) { builder.AppendLine("Deploys on ground contact: true"); } if (spareChutes >= 0) { builder.AppendFormat("Spare chutes: {0}\n", spareChutes); } builder.AppendFormat("Autocut speed: {0}m/s\n", cutSpeed); if (!secondaryChute) { Parachute parachute = parachutes[0]; builder.AppendFormat("Parachute material: {0}\n", parachute.material); builder.AppendFormat("Drag coefficient: {0:0.00}\n", parachute.mat.dragCoefficient); builder.AppendFormat("Predeployed diameter: {0}m\n", parachute.preDeployedDiameter); builder.AppendFormat("Deployed diameter: {0}m\n", parachute.deployedDiameter); if (!parachute.minIsPressure) { builder.AppendFormat("Minimum deployment altitude: {0}m\n", parachute.minDeployment); } else { builder.AppendFormat("Minimum deployment pressure: {0}atm\n", parachute.minPressure); } builder.AppendFormat("Deployment altitude: {0}m\n", parachute.deploymentAlt); builder.AppendFormat("Predeployment speed: {0}s\n", parachute.preDeploymentSpeed); builder.AppendFormat("Deployment speed: {0}s\n", parachute.deploymentSpeed); if (parachute.cutAlt >= 0) { builder.AppendFormat("Autocut altitude: {0}m", parachute.cutAlt); } } //In case of more than one chute else { builder.Append("Parachute materials: ").AppendJoin(parachutes.Select(p => p.material), ", ").AppendLine(); builder.Append("Drag coefficients: ").AppendJoin(parachutes.Select(p => p.mat.dragCoefficient.ToString("0.00")), ", ").AppendLine(); builder.Append("Predeployed diameters: ").AppendJoin(parachutes.Select(p => p.preDeployedDiameter.ToString()), "m, ").AppendLine("m"); builder.Append("Deployed diameters: ").AppendJoin(parachutes.Select(p => p.deployedDiameter.ToString()), "m, ").AppendLine("m"); builder.Append("Minimum deployment clauses: ").AppendJoin(parachutes.Select(p => p.minIsPressure ? p.minPressure + "atm" : p.minDeployment + "m"), ", ").AppendLine(); builder.Append("Deployment altitudes: ").AppendJoin(parachutes.Select(p => p.deploymentAlt.ToString()), "m, ").AppendLine("m"); builder.Append("Predeployment speeds: ").AppendJoin(parachutes.Select(p => p.preDeploymentSpeed.ToString()), "s, ").AppendLine("s"); builder.Append("Deployment speeds: ").AppendJoin(parachutes.Select(p => p.deploymentSpeed.ToString()), "s, ").Append("s"); if (parachutes.Any(p => p.cutAlt != -1)) { builder.Append("\nAutocut altitudes: ").AppendJoin(parachutes.Select(p => p.cutAlt == -1 ? "-- " : p.cutAlt + "m"), ", "); } } return(builder.ToString()); }
private void FixedUpdate() { //Flight values if (!CompatibilityChecker.IsCompatible() || !HighLogic.LoadedSceneIsFlight || FlightGlobals.ActiveVessel == null || this.part.Rigidbody == null) { return; } pos = this.part.transform.position; ASL = FlightGlobals.getAltitudeAtPos(pos); if (this.vessel.mainBody.pqsController != null) { terrainAlt = this.vessel.pqsAltitude; if (this.vessel.mainBody.ocean && terrainAlt < 0) { terrainAlt = 0; } trueAlt = ASL - terrainAlt; } else { trueAlt = ASL; } atmPressure = this.vessel.mainBody.GetPressureAtAlt(ASL); atmDensity = this.vessel.mainBody.GetDensityAtAlt(ASL); Vector3 velocity = this.part.Rigidbody.velocity + Krakensbane.GetFrameVelocityV3f(); sqrSpeed = velocity.sqrMagnitude; dragVector = -velocity.normalized; if (!this.staged && GameSettings.LAUNCH_STAGES.GetKeyDown() && this.vessel.isActiveVessel && this.part.inverseStage == Staging.CurrentStage) { ActivateRC(); } if (!this.launched && !this.vessel.LandedOrSplashed) { this.launched = true; } if (this.launched && !this.staged && deployOnGround && !groundStop && this.vessel.LandedOrSplashed) { ActivateRC(); } if (this.staged) { //Checks if the parachute must disarm if (armed) { this.part.stackIcon.SetIconColor(XKCDColors.LightCyan); if (main.canDeploy || (secondaryChute && secondary.canDeploy)) { armed = false; } } //Parachute deployments if (!armed) { CheckForWait(); main.UpdateParachute(); if (secondaryChute) { secondary.UpdateParachute(); } //If both parachutes must be cut if (bothMustStop) { if (main.isDeployed) { main.Cut(); } if (secondary.isDeployed) { secondary.Cut(); } SetRepack(); } //Allows both parachutes to be cut at the same time if both are deployed if (secondaryChute && bothDeployed) { Events["GUICutBoth"].active = true; } else { Events["GUICutBoth"].active = false; } //If the parachute can't be deployed if (!oneWasDeployed && !settings.autoArm) { failedTimer.Start(); StagingReset(); Events["GUIDeploy"].active = true; Events["GUIArm"].active = true; } } } }
public override string GetInfo() { if (!CompatibilityChecker.IsCompatible()) { return(string.Empty); } //Info in the editor part window MaterialDefinition mat = new MaterialDefinition(), secMat = new MaterialDefinition(); float chuteMass = 0, secChuteMass = 0; if (materials.MaterialExists(material)) { mat = materials.GetMaterial(material); chuteMass = mat.areaDensity * deployedDiameter; } if (secondaryChute && materials.MaterialExists(secMaterial)) { secMat = materials.GetMaterial(secMaterial); secChuteMass = secMat.areaDensity * secDeployedDiameter; } this.part.mass = caseMass + chuteMass + secChuteMass; string infoList = string.Empty; infoList = String.Format("Parachute material: {0}\n", material); if (secondaryChute && secMaterial != material && secMaterial != "empty") { infoList += String.Format("Secondary parachute material: {0}\n", secMaterial); } infoList += String.Format("Case mass: {0}\n", caseMass); if (material == secMaterial) { infoList += String.Format("Drag coefficient: {0:0.00}\n", mat.dragCoefficient); } else { infoList += String.Format("Drag coefficients: {0:0.00}, {1:0.00}\n", mat.dragCoefficient, secMat.dragCoefficient); } if (timer > 0) { infoList += String.Format("Deployment timer: {0}s\n", timer); } if (mustGoDown) { infoList += "Must go downwards to deploy: true\n"; } if (deployOnGround) { infoList += "Deploys on ground contact: true\n"; } if (spareChutes >= 0) { infoList += String.Format("Spare chutes: {0}\n", spareChutes); } if (!secondaryChute) { infoList += String.Format("Predeployed diameter: {0}m\n", preDeployedDiameter); infoList += String.Format("Deployed diameter: {0}m\n", deployedDiameter); if (!minIsPressure) { infoList += String.Format("Minimum deployment altitude: {0}m\n", minDeployment); } else { infoList += String.Format("Minimum deployment pressure: {0}atm\n", minPressure); } infoList += String.Format("Deployment altitude: {0}m\n", deploymentAlt); infoList += String.Format("Predeployment speed: {0}s\n", preDeploymentSpeed); infoList += String.Format("Deployment speed: {0}s\n", deploymentSpeed); infoList += String.Format("Autocut speed: {0}m/s\n", cutSpeed); if (cutAlt >= 0) { infoList += String.Format("Autocut altitude: {0}m\n", cutAlt); } } //In case of dual chutes else { infoList += String.Format("Predeployed diameters: {0}m, {1}m\n", preDeployedDiameter, secPreDeployedDiameter); infoList += String.Format("Deployed diameters: {0}m, {1}m\n", deployedDiameter, secDeployedDiameter); if (!minIsPressure && !secMinIsPressure) { infoList += String.Format("Minimum deployment altitudes: {0}m, {1}m\n", minDeployment, secMinDeployment); } else if (minIsPressure && !secMinIsPressure) { infoList += String.Format("Minimum deployment clauses: {0}atm, {1}m\n", minDeployment, secMinDeployment); } else if (!minIsPressure && secMinIsPressure) { infoList += String.Format("Minimum deployment clauses: {0}m, {1}atm\n", minDeployment, secMinDeployment); } else if (minIsPressure && secMinIsPressure) { infoList += String.Format("Minimum deployment pressures: {0}atmm, {1}atm\n", minDeployment, secMinDeployment); } infoList += String.Format("Deployment altitudes: {0}m, {1}m\n", deploymentAlt, secDeploymentAlt); infoList += String.Format("Predeployment speeds: {0}s, {1}s\n", preDeploymentSpeed, secPreDeploymentSpeed); infoList += String.Format("Deployment speeds: {0}s, {1}s\n", deploymentSpeed, secDeploymentSpeed); infoList += String.Format("Autocut speed: {0}m/s\n", cutSpeed); if (cutAlt >= 0 && secCutAlt >= 0) { infoList += String.Format("Autocut altitudes: {0}m, {1}m\n", cutAlt, secCutAlt); } else if (cutAlt >= 0 && secCutAlt < 0) { infoList += String.Format("Main chute autocut altutude: {0}m\n", cutAlt); } else if (cutAlt < 0 && secCutAlt >= 0) { infoList += String.Format("Secondary chute autocut altitude: {0}m\n", secCutAlt); } } return(infoList); }
private void Update() { if (!CompatibilityChecker.IsCompatible()) { return; } if (HighLogic.LoadedSceneIsFlight) { //Makes the chute icon blink if failed if (failedTimer.isRunning) { if (failedTimer.elapsed.TotalSeconds <= 2.5) { if (!displayed) { ScreenMessages.PostScreenMessage("Parachute deployment failed.", 2, ScreenMessageStyle.UPPER_CENTER); if (groundStop) { ScreenMessages.PostScreenMessage("Reason: stopped on the ground.", 2, ScreenMessageStyle.UPPER_CENTER); } else if (atmPressure == 0) { ScreenMessages.PostScreenMessage("Reason: in space.", 2, ScreenMessageStyle.UPPER_CENTER); } else { ScreenMessages.PostScreenMessage("Reason: too high.", 2, ScreenMessageStyle.UPPER_CENTER); } } displayed = true; double time = failedTimer.elapsed.TotalSeconds; if (time < 0.5 || (time >= 1 && time < 1.5) || (time >= 2)) { this.part.stackIcon.SetIconColor(XKCDColors.Red); } else { this.part.stackIcon.SetIconColor(XKCDColors.White); } } else { displayed = false; this.part.stackIcon.SetIconColor(XKCDColors.White); failedTimer.Reset(); } } if (settings.autoArm) { Events["GUIArm"].guiActive = false; } Events["GUIDisarm"].guiActive = (armed || showDisarm); Events["GUIDisarm"].guiActiveUnfocused = (armed || showDisarm); } if (HighLogic.LoadedSceneIsEditor) { //Updates the spare chute count correctly chuteCount = (int)spareChutes; if (spareChutes < 0) { Fields["chuteCount"].guiActive = false; } //Calculates parachute mass this.part.mass = caseMass + parachutes.Sum(p => p.chuteMass); if (settings.autoArm) { Actions["ActionArm"].active = false; } } }
public override void OnStart(PartModule.StartState state) { if (!HighLogic.LoadedSceneIsEditor && !HighLogic.LoadedSceneIsFlight) { return; } if (!CompatibilityChecker.IsCompatible()) { foreach (BaseAction action in Actions) { action.active = false; } foreach (BaseEvent evnt in Events) { evnt.active = false; evnt.guiActive = false; evnt.guiActiveEditor = false; } Fields["chuteCount"].guiActive = false; return; } //Staging icon this.part.stagingIcon = "PARACHUTES"; //Autoarming checkup settings = RealChuteSettings.fetch; //Part GUI Events["GUIDeploy"].active = true; Events["GUICut"].active = false; Events["GUIArm"].active = true; Events["GUIRepack"].guiActiveUnfocused = false; if (spareChutes < 0) { Fields["chuteCount"].guiActive = false; } if (!secondaryChute) { Actions["ActionCut"].guiName = "Cut chute"; Events["GUICut"].guiName = "Cut chute"; } if (settings.autoArm) { Events["GUIArm"].active = false; Actions["ActionArm"].active = false; } else { Events["GUIArm"].active = true; Actions["ActionArm"].active = true; } //Initiates the Parachutes LoadParachutes(); parachutes.ForEach(p => p.Initialize()); //First initiation of the part if (!initiated) { initiated = true; capOff = false; armed = false; this.baseDrag = this.part.maximum_drag; if (spareChutes >= 0) { chuteCount = (int)spareChutes; } } //Flight loading if (HighLogic.LoadedSceneIsFlight) { //If the part has been staged in the past if (capOff) { this.part.stackIcon.SetIconColor(XKCDColors.Red); } System.Random random = new System.Random(); parachutes.ForEach(p => p.randomTime = (float)random.NextDouble()); //Hide/show UI event addition GameEvents.onHideUI.Add(HideUI); GameEvents.onShowUI.Add(ShowUI); } //GUI window = new Rect(200, 100, 350, 400); }
private void FixedUpdate() { //Flight values if (!CompatibilityChecker.IsCompatible() || !HighLogic.LoadedSceneIsFlight || FlightGlobals.ActiveVessel == null || this.part.Rigidbody == null) { return; } pos = this.part.transform.position; ASL = FlightGlobals.getAltitudeAtPos(pos); trueAlt = this.vessel.GetTrueAlt(ASL); atmPressure = this.vessel.mainBody.GetPressureAtAlt(ASL); atmDensity = this.vessel.mainBody.GetDensityAtAlt(ASL); Vector3 velocity = this.part.Rigidbody.velocity + Krakensbane.GetFrameVelocityV3f(); sqrSpeed = velocity.sqrMagnitude; dragVector = -velocity.normalized; if (!this.staged && GameSettings.LAUNCH_STAGES.GetKeyDown() && this.vessel.isActiveVessel && this.part.inverseStage == Staging.CurrentStage) { ActivateRC(); } if (this.deployOnGround && !this.staged) { if (!this.launched && !this.vessel.LandedOrSplashed) { if (!this.vessel.LandedOrSplashed) { //Dampening timer if (!this.launchTimer.isRunning) { this.launchTimer.Start(); } if (this.launchTimer.elapsedMilliseconds >= 3000) { this.launchTimer.Reset(); this.launched = true; } } else if (this.launchTimer.isRunning) { launchTimer.Reset(); } } if (this.launched && !groundStop && this.vessel.LandedOrSplashed) { ActivateRC(); } } if (this.staged) { //Checks if the parachute must disarm if (armed) { this.part.stackIcon.SetIconColor(XKCDColors.LightCyan); if (parachutes.Any(p => p.canDeploy)) { armed = false; } } //Parachute deployments if (!armed) { if (wait) { CheckForWait(); if (wait) { return; } } //Parachutes parachutes.ForEach(p => p.UpdateParachute()); //If all parachutes must be cut if (allMustStop) { GUICut(); SetRepack(); } //If the parachute can't be deployed if (!oneWasDeployed && !settings.autoArm) { failedTimer.Start(); StagingReset(); Events["GUIDeploy"].active = true; Events["GUIArm"].active = true; } } } }
private void Update() { if ((HighLogic.LoadedSceneIsFlight || HighLogic.LoadedSceneIsEditor) && !CompatibilityChecker.IsCompatible()) { return; } if (HighLogic.LoadedSceneIsFlight) { //Makes the chute icon blink if failed if (failedTimer.IsRunning) { if (failedTimer.Elapsed.TotalSeconds <= 2.5) { if (!displayed) { ScreenMessages.PostScreenMessage("Parachute deployment failed.", 2, ScreenMessageStyle.UPPER_CENTER); if (groundStop) { ScreenMessages.PostScreenMessage("Reason: stopped on the ground.", 2, ScreenMessageStyle.UPPER_CENTER); } else if (atmPressure == 0) { ScreenMessages.PostScreenMessage("Reason: in space.", 2, ScreenMessageStyle.UPPER_CENTER); } else { ScreenMessages.PostScreenMessage("Reason: too high.", 2, ScreenMessageStyle.UPPER_CENTER); } } displayed = true; double time = failedTimer.Elapsed.TotalSeconds; if (time < 0.5 || (time >= 1 && time < 1.5) || (time >= 2)) { this.part.stackIcon.SetIconColor(XKCDColors.Red); } else { this.part.stackIcon.SetIconColor(XKCDColors.White); } } else { displayed = false; this.part.stackIcon.SetIconColor(XKCDColors.White); failedTimer.Reset(); } } //Hides the window if F2 is pressed if (HighLogic.LoadedSceneIsFlight && Input.GetKeyDown(KeyCode.F2)) { if (this.visible || this.hid) { this.visible = !this.visible; this.hid = !this.hid; } } if (settings.autoArm) { Events["GUIArm"].guiActive = false; } if (armed) { Events["GUIDisarm"].guiActive = true; } else { Events["GUIDisarm"].guiActive = false; } } if (HighLogic.LoadedSceneIsEditor) { //Tweakables pressure/altitude predeployment clauses if (!this.part.Modules.Contains("ProceduralChute") && isTweakable) { //Main chute if (this.minIsPressure) { Fields["minDeployment"].guiActiveEditor = false; Fields["minPressure"].guiActiveEditor = true; } else { Fields["minDeployment"].guiActiveEditor = true; Fields["minPressure"].guiActiveEditor = false; } //Secondary chute if (this.secondaryChute) { if (this.secMinIsPressure) { Fields["secMinDeployment"].guiActiveEditor = false; Fields["secMinPressure"].guiActiveEditor = true; } else { Fields["secMinDeployment"].guiActiveEditor = true; Fields["secMinPressure"].guiActiveEditor = false; } } } //Updates the spare chute count correctly chuteCount = (int)spareChutes; if (spareChutes < 0) { Fields["chuteCount"].guiActive = false; } //Calculates parachute mass this.part.mass = caseMass + (secondaryChute ? main.chuteMass + secondary.chuteMass : main.chuteMass); if (settings.autoArm) { Actions["ActionArm"].active = false; } } }