private void Awake() { if (!CompatibilityChecker.IsAllCompatible()) { //Removes RealChute parts from being seen if incompatible PartLoader.LoadedPartsList.Where(p => p.moduleInfos.Exists(m => m.moduleName == "RealChute" || m.moduleName == "ProceduralChute")) .ForEach(p => p.category = PartCategories.none); } else { GameEvents.onGUIEditorToolbarReady.Add(AddFilter); GameEvents.onGUIApplicationLauncherReady.Add(AddButton); GameEvents.onGUIApplicationLauncherDestroyed.Add(RemoveButton); } }
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 Update() { //Updating of size if possible if (!CompatibilityChecker.IsCompatible()) { return; } if ((!HighLogic.LoadedSceneIsEditor && !HighLogic.LoadedSceneIsFlight)) { return; } if (sizes.Count > 0 && 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; chutes.ForEach(c => c.materialsVisible = false); this.failedVisible = false; this.successfulVisible = false; } //Checks if size must update if (sizes.Count > 0 && lastSize != size) { UpdateScale(this.part, rcModule); } //Checks if case texture must update if (this.textures.caseNames.Length > 0 && lastCaseID != caseID) { UpdateCaseTexture(this.part, rcModule); } chutes.ForEach(c => c.SwitchType()); }
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); } } }
private void OnGUI() { //Handles GUI rendering if (!CompatibilityChecker.IsAllCompatible() || ((IntPtr.Size == 8) && (Environment.OSVersion.Platform == PlatformID.Win32NT))) { 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; }
public override void OnLoad(ConfigNode node) { if (!CompatibilityChecker.IsAllCompatible()) { return; } this.node = node; LoadParachutes(); float chuteMass = this.parachutes.Sum(p => p.chuteMass); this.part.mass = this.caseMass + chuteMass; if (HighLogic.LoadedScene == GameScenes.LOADING) { PersistentManager.instance.AddNode <RealChuteModule>(this.part.name, node); } }
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); }
public override void OnLoad(ConfigNode node) { if (!CompatibilityChecker.IsAllCompatible()) { return; } this.node = node; LoadParachutes(); if (HighLogic.LoadedScene == GameScenes.LOADING) { PersistentManager.Instance.AddNode <RealChuteModule>(this.part.name, node); } else { UpdateMass(); } }
public override void OnLoad(ConfigNode node) { if (!CompatibilityChecker.IsAllCompatible() || ((IntPtr.Size == 8) && (Environment.OSVersion.Platform == PlatformID.Win32NT))) { return; } //Gets the materials this.node = node; LoadParachutes(); float chuteMass = parachutes.Sum(p => p.mat.areaDensity * p.deployedArea); this.part.mass = caseMass + chuteMass; if (HighLogic.LoadedSceneIsFlight && staged || parachutes.All(p => p.deploymentState == DeploymentStates.CUT)) { StartCoroutine(UpdateOnReload()); } }
private void Update() { //Updating of size if possible if (!CompatibilityChecker.IsAllCompatible() || (!HighLogic.LoadedSceneIsEditor && !HighLogic.LoadedSceneIsFlight)) { return; } if (this.sizes.Count > 0 && this.part.transform.GetChild(0).localScale != Vector3.Scale(this.originalSize, this.sizes[this.size].size)) { UpdateScale(this.part, this.rcModule); } //If unselected if (!HighLogic.LoadedSceneIsEditor || !EditorLogic.fetch || EditorLogic.fetch.editorScreen != EditorScreen.Actions) { this.editorGUI.visible = false; return; } //Checks if the part is selected if (this.actionPanel.GetSelectedParts().Contains(this.part)) { this.editorGUI.visible = true; } else { this.editorGUI.visible = false; this.chutes.ForEach(c => c.templateGUI.materialsVisible = false); this.editorGUI.failedVisible = false; this.editorGUI.successfulVisible = false; } //Checks if size must update if (this.sizes.Count > 0 && this.lastSize != this.size) { UpdateScale(this.part, this.rcModule); } //Checks if case texture must update if (this.textures.cases.Count > 0 && this.lastCaseID != this.caseID) { UpdateCaseTexture(this.part, this.rcModule); } this.chutes.ForEach(c => c.SwitchType()); }
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)); } } }
private void Awake() { if (!CompatibilityChecker.IsAllCompatible() || ((IntPtr.Size == 8) && (Environment.OSVersion.Platform == PlatformID.Win32NT))) { Destroy(this); return; } this.window = new Rect(100, 100, 330, 130); this.buttonTexture.LoadImage(File.ReadAllBytes(Path.Combine(RCUtils.pluginDataURL, "RC_Icon.png"))); GameEvents.onGUIApplicationLauncherReady.Add(AddButton); GameEvents.onShowUI.Add(ShowUI); GameEvents.onHideUI.Add(HideUI); GameEvents.onGUIAstronautComplexSpawn.Add(HideUI); GameEvents.onGUIAstronautComplexDespawn.Add(ShowUI); GameEvents.onGUIRnDComplexSpawn.Add(HideUI); GameEvents.onGUIRnDComplexDespawn.Add(ShowUI); GameEvents.onGUIMissionControlSpawn.Add(HideUI); GameEvents.onGUIMissionControlDespawn.Add(ShowUI); GameEvents.onGUIAdministrationFacilitySpawn.Add(HideUI); GameEvents.onGUIAdministrationFacilityDespawn.Add(ShowUI); }
private void OnDestroy() { if (!CompatibilityChecker.IsAllCompatible()) { return; } this.destroying = true; CloseWindow(); RealChuteSettings.SaveSettings(); GameEvents.onShowUI.Remove(ShowUI); GameEvents.onHideUI.Remove(HideUI); GameEvents.onGUIAstronautComplexSpawn.Remove(HideUI); GameEvents.onGUIAstronautComplexDespawn.Remove(ShowUI); GameEvents.onGUIRnDComplexSpawn.Remove(HideUI); GameEvents.onGUIRnDComplexDespawn.Remove(ShowUI); GameEvents.onGUIMissionControlSpawn.Remove(HideUI); GameEvents.onGUIMissionControlDespawn.Remove(ShowUI); GameEvents.onGUIAdministrationFacilitySpawn.Remove(HideUI); GameEvents.onGUIAdministrationFacilityDespawn.Remove(ShowUI); }
private void Awake() { if (!CompatibilityChecker.IsAllCompatible()) { Destroy(this); return; } this.window = new Rect(100, 100, 350, 200); this.drag = new Rect(0, 0, 350, 30); this.level = RealChuteSettings.Instance.EngineerLevel.ToString(); GameEvents.onShowUI.Add(ShowUI); GameEvents.onHideUI.Add(HideUI); GameEvents.onGUIAstronautComplexSpawn.Add(HideUI); GameEvents.onGUIAstronautComplexDespawn.Add(ShowUI); GameEvents.onGUIRnDComplexSpawn.Add(HideUI); GameEvents.onGUIRnDComplexDespawn.Add(ShowUI); GameEvents.onGUIMissionControlSpawn.Add(HideUI); GameEvents.onGUIMissionControlDespawn.Add(ShowUI); GameEvents.onGUIAdministrationFacilitySpawn.Add(HideUI); GameEvents.onGUIAdministrationFacilityDespawn.Add(ShowUI); }
private void OnDestroy() { if (!CompatibilityChecker.IsAllCompatible() || ((IntPtr.Size == 8) && (Environment.OSVersion.Platform == PlatformID.Win32NT))) { return; } RealChuteSettings.SaveSettings(); GameEvents.onGUIApplicationLauncherReady.Remove(AddButton); GameEvents.onShowUI.Remove(ShowUI); GameEvents.onHideUI.Remove(HideUI); GameEvents.onGUIAstronautComplexSpawn.Remove(HideUI); GameEvents.onGUIAstronautComplexDespawn.Remove(ShowUI); GameEvents.onGUIRnDComplexSpawn.Remove(HideUI); GameEvents.onGUIRnDComplexDespawn.Remove(ShowUI); GameEvents.onGUIMissionControlSpawn.Remove(HideUI); GameEvents.onGUIMissionControlDespawn.Remove(ShowUI); GameEvents.onGUIAdministrationFacilitySpawn.Remove(HideUI); GameEvents.onGUIAdministrationFacilityDespawn.Remove(ShowUI); ApplicationLauncher.Instance.RemoveModApplication(button); }
private void OnDestroy() { if (!CompatibilityChecker.IsAllCompatible()) { return; } RealChuteSettings.SaveSettings(); GameEvents.onGUIApplicationLauncherReady.Remove(AddButton); GameEvents.onShowUI.Remove(ShowUI); GameEvents.onHideUI.Remove(HideUI); GameEvents.onGUIAstronautComplexSpawn.Remove(HideUI); GameEvents.onGUIAstronautComplexDespawn.Remove(ShowUI); GameEvents.onGUIRnDComplexSpawn.Remove(HideUI); GameEvents.onGUIRnDComplexDespawn.Remove(ShowUI); GameEvents.onGUIMissionControlSpawn.Remove(HideUI); GameEvents.onGUIMissionControlDespawn.Remove(ShowUI); GameEvents.onGUIAdministrationFacilitySpawn.Remove(HideUI); GameEvents.onGUIAdministrationFacilityDespawn.Remove(ShowUI); ApplicationLauncher.Instance.RemoveModApplication(button); }
public override void OnLoad(ConfigNode node) { if (!CompatibilityChecker.IsAllCompatible()) { return; } this.node = node; LoadChutes(); if (this.node.HasNode("SIZE")) { this.sizes = new List <SizeNode>(this.node.GetNodes("SIZE").Select(n => new SizeNode(n))); this.sizeLib.AddSizes(this.part.name, this.sizes); } //Top node original location AttachNode a; if (this.part.TryGetAttachNodeById("top", out a)) { this.top = a.originalPosition.y; } //Bottom node original location if (this.part.TryGetAttachNodeById("bottom", out a)) { this.bottom = a.originalPosition.y; } //Original part size if (this.debut == 0) { this.debut = this.part.transform.GetChild(0).localScale.y; } if (HighLogic.LoadedScene == GameScenes.LOADING) { PersistentManager.instance.AddNode <ProceduralChute>(this.part.name, node); } }
private void Awake() { if (!CompatibilityChecker.IsAllCompatible()) { Destroy(this); return; } this.window = new Rect(100, 100, 330, 200); this.drag = new Rect(0, 0, 330, 20); this.level = this.settings.engineerLevel.ToString(); this.buttonTexture.LoadImage(File.ReadAllBytes(Path.Combine(RCUtils.pluginDataURL, "RC_Icon.png"))); GameEvents.onGUIApplicationLauncherReady.Add(AddButton); GameEvents.onShowUI.Add(ShowUI); GameEvents.onHideUI.Add(HideUI); GameEvents.onGUIAstronautComplexSpawn.Add(HideUI); GameEvents.onGUIAstronautComplexDespawn.Add(ShowUI); GameEvents.onGUIRnDComplexSpawn.Add(HideUI); GameEvents.onGUIRnDComplexDespawn.Add(ShowUI); GameEvents.onGUIMissionControlSpawn.Add(HideUI); GameEvents.onGUIMissionControlDespawn.Add(ShowUI); GameEvents.onGUIAdministrationFacilitySpawn.Add(HideUI); GameEvents.onGUIAdministrationFacilityDespawn.Add(ShowUI); }
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.IsAllCompatible()) { return; } //Identification of the RealChuteModule if (this.part.Modules.Contains("RealChuteModule")) { this.rcModule = this.part.Modules["RealChuteModule"] as RealChuteModule; } else { return; } this.secondaryChute = this.rcModule.secondaryChute; if (!string.IsNullOrEmpty(this.textureLibrary)) { this.textureLib.TryGetConfig(this.textureLibrary, ref this.textures); } this.bodies = AtmoPlanets.fetch; this.body = this.bodies.GetBody(this.planets); //Initializes ChuteTemplates if (this.chutes.Count <= 0) { if (this.node == null && !PersistentManager.instance.TryGetNode <ProceduralChute>(this.part.name, ref this.node)) { return; } LoadChutes(); } this.chutes.ForEach(c => c.Initialize()); if (this.sizes.Count <= 0) { this.sizes = this.sizeLib.GetSizes(this.part.partInfo.name); } //Creates an instance of the texture library this.editorGUI = new EditorGUI(this); if (HighLogic.LoadedSceneIsEditor) { //Windows initiation this.editorGUI.window = new Rect(5, 370, 420, Screen.height - 375); this.chutes.ForEach(c => { c.templateGUI.materialsWindow = new Rect(this.editorGUI.matX, this.editorGUI.matY, 375, 275); c.templateGUI.drag = new Rect(0, 0, 375, 25); }); this.editorGUI.failedWindow = new Rect(Screen.width / 2 - 150, Screen.height / 2 - 150, 300, 300); this.editorGUI.successfulWindow = new Rect(Screen.width / 2 - 150, Screen.height / 2 - 25, 300, 50); this.editorGUI.presetsWindow = new Rect(Screen.width / 2 - 200, Screen.height / 2 - 250, 400, 500); this.editorGUI.presetsSaveWindow = new Rect(Screen.width / 2 - 175, Screen.height / 2 - 110, 350, 220); this.editorGUI.presetsWarningWindow = new Rect(Screen.width / 2 - 100, Screen.height / 2 - 50, 200, 100); if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER) { float level = 0; switch (EditorDriver.editorFacility) { case EditorFacility.VAB: level = ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.VehicleAssemblyBuilding); break; case EditorFacility.SPH: level = ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.SpaceplaneHangar); break; default: break; } if (GameVariables.Instance.UnlockedActionGroupsStock(level)) { Events.ForEach(e => e.guiActiveEditor = false); } } else { Events.ForEach(e => e.guiActiveEditor = false); } //Gets the original part state if (this.textures != null && this.caseID == -1) { if (this.caseID == -1) { if (this.textures.TryGetCase(this.currentCase, ref this.parachuteCase)) { this.caseID = this.textures.GetCaseIndex(this.parachuteCase.name); } } else { this.textures.TryGetCase(this.caseID, this.type, ref this.parachuteCase); } this.lastCaseID = this.caseID; } if (!this.initiated) { if (!this.bodies.TryGetBodyIndex("Kerbin", ref this.planets)) { this.planets = 0; } this.body = this.bodies.GetBody(planets); //Identification of the values from the RealChuteModule this.mustGoDown = this.rcModule.mustGoDown; this.deployOnGround = this.rcModule.deployOnGround; this.timer = this.rcModule.timer + "s"; this.cutSpeed = this.rcModule.cutSpeed.ToString(); if (this.rcModule.spareChutes != -1) { this.spares = this.rcModule.spareChutes.ToString(); } this.originalSize = this.part.transform.GetChild(0).localScale; this.initiated = true; } } else if (this.textures != null) { this.textures.TryGetCase(this.caseID, this.type, ref this.parachuteCase); this.lastCaseID = this.caseID; } if (this.parent == null) { this.parent = this.part.FindModelTransform(this.rcModule.parachutes[0].parachuteName).parent; } //Updates the part if (this.textures != null) { UpdateCaseTexture(this.part, this.rcModule); this.editorGUI.cases = this.textures.caseNames; this.editorGUI.canopies = this.textures.canopyNames; this.editorGUI.models = this.textures.modelNames; } UpdateScale(this.part, this.rcModule); }
public override string GetInfo() { if (!CompatibilityChecker.IsAllCompatible() || ((IntPtr.Size == 8) && (Environment.OSVersion.Platform == PlatformID.Win32NT))) { 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()); }
public override string GetInfo() { return(!CompatibilityChecker.IsAllCompatible() || !this.isTweakable || !this.part.Modules.Contains("RealChuteModule") ? string.Empty : "This RealChute part can be tweaked from the Action Groups window."); }
public override void OnStart(PartModule.StartState state) { if (!HighLogic.LoadedSceneIsEditor && !HighLogic.LoadedSceneIsFlight) { return; } if (!CompatibilityChecker.IsAllCompatible() || ((IntPtr.Size == 8) && (Environment.OSVersion.Platform == PlatformID.Win32NT))) { 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.IsAllCompatible() || !HighLogic.LoadedSceneIsFlight || FlightGlobals.ActiveVessel == null || this.part.Rigidbody == null || ((IntPtr.Size == 8) && (Environment.OSVersion.Platform == PlatformID.Win32NT))) { 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 (!CompatibilityChecker.IsAllCompatible() || ((IntPtr.Size == 8) && (Environment.OSVersion.Platform == PlatformID.Win32NT))) { 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) || !CompatibilityChecker.IsAllCompatible()) { return; } //Identification of the RealChuteModule if (this.part.Modules.Contains("RealChuteModule")) { rcModule = this.part.Modules["RealChuteModule"] as RealChuteModule; } else { return; } secondaryChute = rcModule.secondaryChute; if (textureLibrary != "none") { textureLib.TryGetConfig(textureLibrary, ref textures); } bodies = AtmoPlanets.fetch; //Initializes ChuteTemplates LoadChutes(); if (this.part.name.Contains("(Clone)(Clone)")) { if (this.part.symmetryCounterparts.Count > 0) { CopyFromOriginal(this.part.symmetryCounterparts.Find(p => !p.name.Contains("(Clone)(Clone)"))); } RCUtils.RemoveClone(this.part); } chutes.ForEach(c => c.Initialize()); if (sizes.Count <= 0) { sizes = sizeLib.GetSizes(this.part.partInfo.name); } //Creates an instance of the texture library editorGUI = new EditorGUI(this); if (textureLibrary != "none") { editorGUI.cases = textures.caseNames; editorGUI.canopies = textures.canopyNames; editorGUI.models = textures.modelNames; textures.TryGetCase(caseID, type, ref parachuteCase); lastCaseID = caseID; } if (HighLogic.LoadedSceneIsEditor) { //Windows initiation this.editorGUI.window = new Rect(5, 370, 420, Screen.height - 375); this.chutes.ForEach(c => c.materialsWindow = new Rect(editorGUI.matX, editorGUI.matY, 375, 275)); this.editorGUI.failedWindow = new Rect(Screen.width / 2 - 150, Screen.height / 2 - 150, 300, 300); this.editorGUI.successfulWindow = new Rect(Screen.width / 2 - 150, Screen.height / 2 - 25, 300, 50); this.editorGUI.presetsWindow = new Rect(Screen.width / 2 - 200, Screen.height / 2 - 250, 400, 500); this.editorGUI.presetsSaveWindow = new Rect(Screen.width / 2 - 175, Screen.height / 2 - 110, 350, 220); this.editorGUI.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.parachutes[0].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) || !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); }