public static void PopUpVesselError(List <KCT_BuildListVessel> errored) { DialogGUIBase[] options = new DialogGUIBase[2]; options[0] = new DialogGUIButton("Understood", () => { }); // new DialogGUIBase("Understood", () => { }); //do nothing and close the window options[1] = new DialogGUIButton("Delete Vessels", () => { foreach (KCT_BuildListVessel blv in errored) { blv.RemoveFromBuildList(); KCT_Utilities.AddFunds(blv.cost, TransactionReasons.VesselRollout); //remove any associated recon_rollout } }); string txt = "The following KCT vessels contain missing or invalid parts and have been quarantined. Either add the missing parts back into your game or delete the vessels. A file containing the ship names and missing parts has been added to your save folder.\n"; string txtToWrite = ""; foreach (KCT_BuildListVessel blv in errored) { txt += blv.shipName + "\n"; txtToWrite += blv.shipName + "\n"; txtToWrite += String.Join("\n", blv.MissingParts().ToArray()); txtToWrite += "\n\n"; } //HighLogic.SaveFolder //make new file for missing ships string filename = KSPUtil.ApplicationRootPath + "/saves/" + HighLogic.SaveFolder + "/missingParts.txt"; System.IO.File.WriteAllText(filename, txtToWrite); //remove all rollout and recon items since they're invalid without the ships foreach (KCT_BuildListVessel blv in errored) { //remove any associated recon_rollout foreach (KCT_KSC ksc in KCT_GameStates.KSCs) { for (int i = 0; i < ksc.Recon_Rollout.Count; i++) { KCT_Recon_Rollout rr = ksc.Recon_Rollout[i]; if (rr.associatedID == blv.id.ToString()) { ksc.Recon_Rollout.Remove(rr); i--; } } } } MultiOptionDialog diag = new MultiOptionDialog("missingPartsPopup", txt, "Vessels Contain Missing Parts", null, options); PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), diag, false, HighLogic.UISkin); //PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), "Vessel Contains Missing Parts", "The KCT vessel " + errored.shipName + " contains missing or invalid parts. You will not be able to do anything with the vessel until the parts are available again.", "Understood", false, HighLogic.UISkin); }
public void vesselSituationChange(GameEvents.HostedFromToAction <Vessel, Vessel.Situations> ev) { if (ev.from == Vessel.Situations.PRELAUNCH && ev.host == FlightGlobals.ActiveVessel) { if (!KCT_GameStates.settings.enabledForSave) { return; } if (KCT_GameStates.flightSimulated && KCT_GameStates.simulationTimeLimit > 0) { KCT_GameStates.simulationEndTime = Planetarium.GetUniversalTime() + (KCT_GameStates.simulationTimeLimit); KCT_Utilities.SpendFunds(KCT_GameStates.FundsToChargeAtSimEnd, TransactionReasons.None); } if (ev.host.protoVessel.landedAt == "LaunchPad" && !KCT_GameStates.flightSimulated && KCT_GameStates.settings.Reconditioning) { KCT_Recon_Rollout reconditioning = KCT_GameStates.ActiveKSC.Recon_Rollout.FirstOrDefault(r => ((IKCTBuildItem)r).GetItemName() == "LaunchPad Reconditioning"); if (reconditioning == null) { KCT_GameStates.ActiveKSC.Recon_Rollout.Add(new KCT_Recon_Rollout(ev.host, KCT_Recon_Rollout.RolloutReconType.Reconditioning, ev.host.id.ToString())); } } } }
public static void DelayedStart() { if (KCT_Utilities.CurrentGameIsMission()) { return; } KCTDebug.Log("DelayedStart start"); if (KCT_PresetManager.Instance?.ActivePreset == null || !KCT_PresetManager.Instance.ActivePreset.generalSettings.Enabled) { return; } if (KCT_GUI.PrimarilyDisabled) { return; } //The following should only be executed when fully enabled for the save if (KCT_GameStates.ActiveKSC == null) { KCT_Utilities.SetActiveKSCToRSS(); } KCTDebug.Log("Checking vessels for missing parts."); //check that all parts are valid in all ships. If not, warn the user and disable that vessel (once that code is written) if (!KCT_GameStates.vesselErrorAlerted) { List <KCT_BuildListVessel> erroredVessels = new List <KCT_BuildListVessel>(); foreach (KCT_KSC KSC in KCT_GameStates.KSCs) //this is faster on subsequent scene changes { foreach (KCT_BuildListVessel blv in KSC.VABList) { if (!blv.allPartsValid) { //error! KCTDebug.Log(blv.shipName + " contains invalid parts!"); erroredVessels.Add(blv); } } foreach (KCT_BuildListVessel blv in KSC.VABWarehouse) { if (!blv.allPartsValid) { //error! KCTDebug.Log(blv.shipName + " contains invalid parts!"); erroredVessels.Add(blv); } } foreach (KCT_BuildListVessel blv in KSC.SPHList) { if (!blv.allPartsValid) { //error! KCTDebug.Log(blv.shipName + " contains invalid parts!"); erroredVessels.Add(blv); } } foreach (KCT_BuildListVessel blv in KSC.SPHWarehouse) { if (!blv.allPartsValid) { //error! KCTDebug.Log(blv.shipName + " contains invalid parts!"); erroredVessels.Add(blv); } } } if (erroredVessels.Count > 0) { PopUpVesselError(erroredVessels); } KCT_GameStates.vesselErrorAlerted = true; } if (HighLogic.LoadedSceneIsEditor) { if (KCT_GameStates.EditorShipEditingMode) { KCTDebug.Log("Editing " + KCT_GameStates.editedVessel.shipName); EditorLogic.fetch.shipNameField.text = KCT_GameStates.editedVessel.shipName; } } if (HighLogic.LoadedScene == GameScenes.SPACECENTER) { KCTDebug.Log("SP Start"); if (!KCT_GUI.PrimarilyDisabled) { if (ToolbarManager.ToolbarAvailable && KCT_GameStates.settings.PreferBlizzyToolbar) { if (KCT_GameStates.showWindows[0]) { KCT_GUI.ClickOn(); } else { //if (KCT_Events.instance != null && KCT_Events.instance.KCTButtonStock != null) if (KCT_Events.instance != null && KCT_GameStates.toolbarControl != null) { if (KCT_GameStates.showWindows[0]) { KCT_GUI.ClickOn(); } } } } KCT_GUI.ResetBLWindow(); } else { KCT_GUI.showBuildList = false; KCT_GameStates.showWindows[0] = false; } KCTDebug.Log("SP UI done"); if (KCT_GameStates.firstStart) { KCTDebug.Log("Showing first start."); KCT_GameStates.firstStart = false; KCT_GUI.showFirstRun = true; //initialize the proper launchpad KCT_GameStates.ActiveKSC.ActiveLPInstance.level = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.LaunchPad); } KCTDebug.Log("SP switch starting"); KCT_GameStates.ActiveKSC.SwitchLaunchPad(KCT_GameStates.ActiveKSC.ActiveLaunchPadID); KCTDebug.Log("SP switch done"); foreach (KCT_KSC ksc in KCT_GameStates.KSCs) { for (int i = 0; i < ksc.Recon_Rollout.Count; i++) { KCT_Recon_Rollout rr = ksc.Recon_Rollout[i]; if (rr.RRType != KCT_Recon_Rollout.RolloutReconType.Reconditioning && KCT_Utilities.FindBLVesselByID(new Guid(rr.associatedID)) == null) { KCTDebug.Log("Invalid Recon_Rollout at " + ksc.KSCName + ". ID " + rr.associatedID + " not found."); ksc.Recon_Rollout.Remove(rr); i--; } } for (int i = 0; i < ksc.AirlaunchPrep.Count; i++) { KCT_AirlaunchPrep ap = ksc.AirlaunchPrep[i]; if (KCT_Utilities.FindBLVesselByID(new Guid(ap.associatedID)) == null) { KCTDebug.Log("Invalid KCT_AirlaunchPrep at " + ksc.KSCName + ". ID " + ap.associatedID + " not found."); ksc.AirlaunchPrep.Remove(ap); i--; } } } KCTDebug.Log("SP done"); } KCTDebug.Log("DelayedStart finished"); }
public void Start() { if (KCT_Utilities.CurrentGameIsMission()) { return; } KCTDebug.Log("Start called"); // Subscribe to events from KSP and other mods if (!KCT_Events.instance.subscribedToEvents) { KCT_Events.instance.SubscribeToEvents(); } KCT_GameStates.settings.Save(); //Save the settings file, with defaults if it doesn't exist KCT_PresetManager.Instance.SaveActiveToSaveData(); // Ghetto event queue if (HighLogic.LoadedScene == GameScenes.EDITOR) { InvokeRepeating("EditorRecalculation", 1, 1); KCT_GUI.buildRateForDisplay = null; if (!KCT_GUI.PrimarilyDisabled) { KCT_Utilities.RecalculateEditorBuildTime(EditorLogic.fetch.ship); } } if (KCT_GUI.PrimarilyDisabled) { if (InputLockManager.GetControlLock("KCTLaunchLock") == ControlTypes.EDITOR_LAUNCH) { InputLockManager.RemoveControlLock("KCTLaunchLock"); } } KACWrapper.InitKACWrapper(); if (!KCT_PresetManager.Instance.ActivePreset.generalSettings.Enabled) { if (InputLockManager.GetControlLock("KCTKSCLock") == ControlTypes.KSC_FACILITIES) { InputLockManager.RemoveControlLock("KCTKSCLock"); } return; } //Begin primary mod functions KCT_GameStates.UT = Planetarium.GetUniversalTime(); KCT_GUI.guiDataSaver.Load(); switch (HighLogic.LoadedScene) { case GameScenes.EDITOR: //if (HighLogic.LoadedSceneIsEditor) { KCT_GUI.hideAll(); if (!KCT_GUI.PrimarilyDisabled) { KCT_GUI.showEditorGUI = KCT_GameStates.showWindows[1]; if (KCT_GUI.showEditorGUI) { KCT_GUI.ClickOn(); } else { KCT_GUI.ClickOff(); } } } break; case GameScenes.SPACECENTER: //else if (HighLogic.LoadedScene == GameScenes.SPACECENTER) { bool shouldStart = KCT_GUI.showFirstRun; KCT_GUI.hideAll(); if (!shouldStart) { KCT_GUI.showBuildList = KCT_GameStates.showWindows[0]; if (KCT_GUI.showBuildList) { KCT_GUI.ClickOn(); } else { KCT_GUI.ClickOff(); } } KCT_GUI.showFirstRun = shouldStart; } break; case GameScenes.FLIGHT: if (/*HighLogic.LoadedSceneIsFlight && */ FlightGlobals.ActiveVessel.situation == Vessel.Situations.PRELAUNCH && FlightGlobals.ActiveVessel.GetCrewCount() == 0 && KCT_GameStates.launchedCrew.Count > 0) { KerbalRoster roster = HighLogic.CurrentGame.CrewRoster; for (int i = 0; i < FlightGlobals.ActiveVessel.parts.Count; i++) { Part p = FlightGlobals.ActiveVessel.parts[i]; //KCTDebug.Log("craft: " + p.craftID); KCTDebug.LogError("Part being tested: " + p.partInfo.title); { CrewedPart cP = KCT_GameStates.launchedCrew.Find(part => part.partID == p.craftID); if (cP == null) { continue; } List <ProtoCrewMember> crewList = cP.crewList; KCTDebug.LogError("cP.crewList.Count: " + cP.crewList.Count); foreach (ProtoCrewMember crewMember in crewList) { if (crewMember != null) { ProtoCrewMember finalCrewMember = crewMember; if (crewMember.type == ProtoCrewMember.KerbalType.Crew) { finalCrewMember = roster.Crew.FirstOrDefault(c => c.name == crewMember.name); } else if (crewMember.type == ProtoCrewMember.KerbalType.Tourist) { finalCrewMember = roster.Tourist.FirstOrDefault(c => c.name == crewMember.name); } if (finalCrewMember == null) { KCTDebug.LogError("Error when assigning " + crewMember.name + " to " + p.partInfo.name + ". Cannot find Kerbal in list."); continue; } try { KCTDebug.Log("Assigning " + finalCrewMember.name + " to " + p.partInfo.name); if (p.AddCrewmember(finalCrewMember)) //p.AddCrewmemberAt(finalCrewMember, crewList.IndexOf(crewMember))) { finalCrewMember.rosterStatus = ProtoCrewMember.RosterStatus.Assigned; if (finalCrewMember.seat != null) { finalCrewMember.seat.SpawnCrew(); } } else { KCTDebug.LogError("Error when assigning " + crewMember.name + " to " + p.partInfo.name); finalCrewMember.rosterStatus = ProtoCrewMember.RosterStatus.Available; continue; } } catch { KCTDebug.LogError("Error when assigning " + crewMember.name + " to " + p.partInfo.name); finalCrewMember.rosterStatus = ProtoCrewMember.RosterStatus.Available; continue; } } } } } KCT_GameStates.launchedCrew.Clear(); } //if (HighLogic.LoadedSceneIsFlight) { KCT_GUI.hideAll(); if (KCT_GameStates.launchedVessel != null && FlightGlobals.ActiveVessel != null && FlightGlobals.ActiveVessel.situation == Vessel.Situations.PRELAUNCH) { KCT_GameStates.launchedVessel.KSC = null; //it's invalid now KCTDebug.Log("Attempting to remove launched vessel from build list"); bool removed = KCT_GameStates.launchedVessel.RemoveFromBuildList(); if (removed) //Only do these when the vessel is first removed from the list { //Add the cost of the ship to the funds so it can be removed again by KSP KCT_Utilities.AddFunds(KCT_GameStates.launchedVessel.cost, TransactionReasons.VesselRollout); FlightGlobals.ActiveVessel.vesselName = KCT_GameStates.launchedVessel.shipName; } KCT_Recon_Rollout rollout = KCT_GameStates.ActiveKSC.Recon_Rollout.FirstOrDefault(r => r.associatedID == KCT_GameStates.launchedVessel.id.ToString()); if (rollout != null) { KCT_GameStates.ActiveKSC.Recon_Rollout.Remove(rollout); } KCT_AirlaunchPrep alPrep = KCT_GameStates.ActiveKSC.AirlaunchPrep.FirstOrDefault(r => r.associatedID == KCT_GameStates.launchedVessel.id.ToString()); if (alPrep != null) { KCT_GameStates.ActiveKSC.AirlaunchPrep.Remove(alPrep); } AirlaunchParams alParams = KCT_GameStates.AirlaunchParams; if (alParams != null && alParams.KCTVesselId == KCT_GameStates.launchedVessel.id && (!alParams.KSPVesselId.HasValue || alParams.KSPVesselId == FlightGlobals.ActiveVessel.id)) { if (!alParams.KSPVesselId.HasValue) { alParams.KSPVesselId = FlightGlobals.ActiveVessel.id; } StartCoroutine(AirlaunchRoutine(alParams, FlightGlobals.ActiveVessel.id)); } } } break; } ratesUpdated = false; KCTDebug.Log("Start finished"); wfsOne = new WaitForSeconds(1f); wfsTwo = new WaitForSeconds(2f); wfsHalf = new WaitForSeconds(0.5f); DelayedStart(); UpdateTechlistIconColor(); StartCoroutine(HandleEditorButton_Coroutine()); }
public KCT_Recon_Rollout GetReconRollout(KCT_Recon_Rollout.RolloutReconType type) { return Recon_Rollout.FirstOrDefault(r => r.RRType == type); }
public KCT_KSC FromConfigNode(ConfigNode node) { VABUpgrades.Clear(); SPHUpgrades.Clear(); RDUpgrades.Clear(); VABList.Clear(); VABWarehouse.Clear(); SPHList.Clear(); SPHWarehouse.Clear(); KSCTech.Clear(); //TechList.Clear(); Recon_Rollout.Clear(); this.KSCName = node.GetValue("KSCName"); ConfigNode vabup = node.GetNode("VABUpgrades"); foreach (string upgrade in vabup.GetValues("Upgrade")) { this.VABUpgrades.Add(int.Parse(upgrade)); } ConfigNode sphup = node.GetNode("SPHUpgrades"); foreach (string upgrade in sphup.GetValues("Upgrade")) { this.SPHUpgrades.Add(int.Parse(upgrade)); } ConfigNode rdup = node.GetNode("RDUpgrades"); foreach (string upgrade in rdup.GetValues("Upgrade")) { this.RDUpgrades.Add(int.Parse(upgrade)); } ConfigNode tmp = node.GetNode("VABList"); foreach (ConfigNode vessel in tmp.GetNodes("KCTVessel")) { KCT_BuildListStorage.BuildListItem listItem = new KCT_BuildListStorage.BuildListItem(); ConfigNode.LoadObjectFromConfig(listItem, vessel); KCT_BuildListVessel blv = listItem.ToBuildListVessel(); blv.shipNode = vessel.GetNode("ShipNode"); this.VABList.Add(blv); } tmp = node.GetNode("SPHList"); foreach (ConfigNode vessel in tmp.GetNodes("KCTVessel")) { KCT_BuildListStorage.BuildListItem listItem = new KCT_BuildListStorage.BuildListItem(); ConfigNode.LoadObjectFromConfig(listItem, vessel); KCT_BuildListVessel blv = listItem.ToBuildListVessel(); blv.shipNode = vessel.GetNode("ShipNode"); this.SPHList.Add(blv); } tmp = node.GetNode("VABWarehouse"); foreach (ConfigNode vessel in tmp.GetNodes("KCTVessel")) { KCT_BuildListStorage.BuildListItem listItem = new KCT_BuildListStorage.BuildListItem(); ConfigNode.LoadObjectFromConfig(listItem, vessel); KCT_BuildListVessel blv = listItem.ToBuildListVessel(); blv.shipNode = vessel.GetNode("ShipNode"); this.VABWarehouse.Add(blv); } tmp = node.GetNode("SPHWarehouse"); foreach (ConfigNode vessel in tmp.GetNodes("KCTVessel")) { KCT_BuildListStorage.BuildListItem listItem = new KCT_BuildListStorage.BuildListItem(); ConfigNode.LoadObjectFromConfig(listItem, vessel); KCT_BuildListVessel blv = listItem.ToBuildListVessel(); blv.shipNode = vessel.GetNode("ShipNode"); this.SPHWarehouse.Add(blv); } /* tmp = node.GetNode("TechList"); foreach (ConfigNode techNode in tmp.GetNodes("Tech")) { KCT_TechStorageItem techStorageItem = new KCT_TechStorageItem(); ConfigNode.LoadObjectFromConfig(techStorageItem, techNode); KCT_TechItem techItem = techStorageItem.ToTechItem(); techItem.protoNode = new ProtoTechNode(techNode.GetNode("ProtoNode")); this.TechList.Add(techItem); }*/ tmp = node.GetNode("Recon_Rollout"); foreach (ConfigNode RRCN in tmp.GetNodes("Recon_Rollout_Item")) { KCT_Recon_Rollout tempRR = new KCT_Recon_Rollout(); ConfigNode.LoadObjectFromConfig(tempRR, RRCN); Recon_Rollout.Add(tempRR); } if (node.HasNode("KSCTech")) { tmp = node.GetNode("KSCTech"); foreach (ConfigNode upBuild in tmp.GetNodes("UpgradingBuilding")) { KCT_UpgradingBuilding tempUP = new KCT_UpgradingBuilding(); ConfigNode.LoadObjectFromConfig(tempUP, upBuild); KSCTech.Add(tempUP); } } return this; }
public KCT_KSC FromConfigNode(ConfigNode node) { VABUpgrades.Clear(); SPHUpgrades.Clear(); RDUpgrades.Clear(); VABList.Clear(); VABWarehouse.Clear(); SPHList.Clear(); SPHWarehouse.Clear(); KSCTech.Clear(); //TechList.Clear(); Recon_Rollout.Clear(); VABRates.Clear(); SPHRates.Clear(); this.KSCName = node.GetValue("KSCName"); if (!int.TryParse(node.GetValue("ActiveLPID"), out this.ActiveLaunchPadID)) { this.ActiveLaunchPadID = 0; } ConfigNode vabup = node.GetNode("VABUpgrades"); foreach (string upgrade in vabup.GetValues("Upgrade")) { this.VABUpgrades.Add(int.Parse(upgrade)); } ConfigNode sphup = node.GetNode("SPHUpgrades"); foreach (string upgrade in sphup.GetValues("Upgrade")) { this.SPHUpgrades.Add(int.Parse(upgrade)); } ConfigNode rdup = node.GetNode("RDUpgrades"); foreach (string upgrade in rdup.GetValues("Upgrade")) { this.RDUpgrades.Add(int.Parse(upgrade)); } ConfigNode tmp = node.GetNode("VABList"); foreach (ConfigNode vessel in tmp.GetNodes("KCTVessel")) { KCT_BuildListStorage.BuildListItem listItem = new KCT_BuildListStorage.BuildListItem(); ConfigNode.LoadObjectFromConfig(listItem, vessel); KCT_BuildListVessel blv = listItem.ToBuildListVessel(); blv.shipNode = vessel.GetNode("ShipNode"); blv.KSC = this; this.VABList.Add(blv); } tmp = node.GetNode("SPHList"); foreach (ConfigNode vessel in tmp.GetNodes("KCTVessel")) { KCT_BuildListStorage.BuildListItem listItem = new KCT_BuildListStorage.BuildListItem(); ConfigNode.LoadObjectFromConfig(listItem, vessel); KCT_BuildListVessel blv = listItem.ToBuildListVessel(); blv.shipNode = vessel.GetNode("ShipNode"); blv.KSC = this; this.SPHList.Add(blv); } tmp = node.GetNode("VABWarehouse"); foreach (ConfigNode vessel in tmp.GetNodes("KCTVessel")) { KCT_BuildListStorage.BuildListItem listItem = new KCT_BuildListStorage.BuildListItem(); ConfigNode.LoadObjectFromConfig(listItem, vessel); KCT_BuildListVessel blv = listItem.ToBuildListVessel(); blv.shipNode = vessel.GetNode("ShipNode"); blv.KSC = this; this.VABWarehouse.Add(blv); } tmp = node.GetNode("SPHWarehouse"); foreach (ConfigNode vessel in tmp.GetNodes("KCTVessel")) { KCT_BuildListStorage.BuildListItem listItem = new KCT_BuildListStorage.BuildListItem(); ConfigNode.LoadObjectFromConfig(listItem, vessel); KCT_BuildListVessel blv = listItem.ToBuildListVessel(); blv.shipNode = vessel.GetNode("ShipNode"); blv.KSC = this; this.SPHWarehouse.Add(blv); } /* tmp = node.GetNode("TechList"); * foreach (ConfigNode techNode in tmp.GetNodes("Tech")) * { * KCT_TechStorageItem techStorageItem = new KCT_TechStorageItem(); * ConfigNode.LoadObjectFromConfig(techStorageItem, techNode); * KCT_TechItem techItem = techStorageItem.ToTechItem(); * techItem.protoNode = new ProtoTechNode(techNode.GetNode("ProtoNode")); * this.TechList.Add(techItem); * }*/ tmp = node.GetNode("Recon_Rollout"); foreach (ConfigNode RRCN in tmp.GetNodes("Recon_Rollout_Item")) { KCT_Recon_Rollout tempRR = new KCT_Recon_Rollout(); ConfigNode.LoadObjectFromConfig(tempRR, RRCN); Recon_Rollout.Add(tempRR); } if (node.HasNode("KSCTech")) { tmp = node.GetNode("KSCTech"); foreach (ConfigNode upBuild in tmp.GetNodes("UpgradingBuilding")) { KCT_UpgradingBuilding tempUP = new KCT_UpgradingBuilding(); ConfigNode.LoadObjectFromConfig(tempUP, upBuild); KSCTech.Add(tempUP); } } if (node.HasNode("LaunchPads")) { LaunchPads.Clear(); tmp = node.GetNode("LaunchPads"); foreach (ConfigNode LP in tmp.GetNodes("KCT_LaunchPad")) { KCT_LaunchPad tempLP = new KCT_LaunchPad("LP0"); ConfigNode.LoadObjectFromConfig(tempLP, LP); tempLP.DestructionNode = LP.GetNode("DestructionState"); LaunchPads.Add(tempLP); } } if (node.HasNode("VABRateCache")) { foreach (string rate in node.GetNode("VABRateCache").GetValues("rate")) { double r; if (double.TryParse(rate, out r)) { VABRates.Add(r); } } } if (node.HasNode("SPHRateCache")) { foreach (string rate in node.GetNode("SPHRateCache").GetValues("rate")) { double r; if (double.TryParse(rate, out r)) { SPHRates.Add(r); } } } return(this); }
public KCT_Recon_Rollout GetReconRollout(KCT_Recon_Rollout.RolloutReconType type, string launchSite = "LaunchPad") { return Recon_Rollout.FirstOrDefault(r => r.RRType == type && r.launchPadID == launchSite); }
public static void DelayedStart() { // KCTDebug.Log(ScenarioUpgradeableFacilities.protoUpgradeables.Keys); // KCTDebug.Log(ScenarioUpgradeableFacilities.protoUpgradeables.Values.ElementAt(0).facilityRefs[0].name); /* if (!updateChecked) * { * if (KCT_GameStates.settings.CheckForUpdates && !KCT_GameStates.firstStart) //Check for updates * KCT_UpdateChecker.CheckForUpdate(false, KCT_GameStates.settings.VersionSpecific); * updateChecked = true; * }*/ if (!KCT_PresetManager.Instance.ActivePreset.generalSettings.Enabled) { return; } List <GameScenes> validScenes = new List <GameScenes> { GameScenes.SPACECENTER }; if (validScenes.Contains(HighLogic.LoadedScene)) { //Check for simulation save and load it. string backupFile = KSPUtil.ApplicationRootPath + "saves/" + HighLogic.SaveFolder + "/KCT_simulation_backup.sfs"; if (System.IO.File.Exists(backupFile)) { KCT_GameStates.LoadingSimulationSave = true; /* if (!KCT_GameStates.LoadingSimulationSave) * KCT_Utilities.LoadSimulationSave(); * else * System.IO.File.Delete(backupFile);*/ } } if (HighLogic.LoadedSceneIsFlight && KCT_GameStates.flightSimulated) { KCTDebug.Log("Simulation started"); KCT_GUI.hideAll(); KCT_GUI.showSimulationWindow = !KCT_GameStates.settings.NoSimGUI; KCT_GUI.showTimeRemaining = true; if (!KCT_GameStates.simulationInitialized) { Planetarium.SetUniversalTime(KCT_GameStates.simulationUT); KCT_GameStates.simulationInitialized = true; } } if (!HighLogic.LoadedSceneIsFlight && KCT_GameStates.FundsToChargeAtSimEnd != 0) { KCT_Utilities.SpendFunds(KCT_GameStates.FundsToChargeAtSimEnd, TransactionReasons.None); KCT_GameStates.FundsToChargeAtSimEnd = 0; } if (!HighLogic.LoadedSceneIsFlight && KCT_GameStates.FundsGivenForVessel != 0) { KCT_Utilities.SpendFunds(KCT_GameStates.FundsGivenForVessel, TransactionReasons.VesselRollout); KCT_GameStates.FundsGivenForVessel = 0; } if (HighLogic.LoadedSceneIsFlight && !KCT_GameStates.flightSimulated) { List <VesselType> invalidTypes = new List <VesselType> { VesselType.Debris, VesselType.SpaceObject, VesselType.Unknown }; if (!invalidTypes.Contains(FlightGlobals.ActiveVessel.vesselType) && !KCT_GameStates.BodiesVisited.Contains(FlightGlobals.ActiveVessel.mainBody.bodyName)) { KCT_GameStates.BodiesVisited.Add(FlightGlobals.ActiveVessel.mainBody.bodyName); var message = new ScreenMessage("[KCT] New simulation body unlocked: " + FlightGlobals.ActiveVessel.mainBody.bodyName, 4.0f, ScreenMessageStyle.UPPER_LEFT); ScreenMessages.PostScreenMessage(message, true); KCTDebug.Log("Unlocked sim body: " + FlightGlobals.ActiveVessel.mainBody.bodyName); } } if (KCT_GUI.PrimarilyDisabled) { return; } //The following should only be executed when fully enabled for the save //check that all parts are valid in all ships. If not, warn the user and disable that vessel (once that code is written) if (!KCT_GameStates.vesselErrorAlerted) { List <KCT_BuildListVessel> erroredVessels = new List <KCT_BuildListVessel>(); foreach (KCT_KSC KSC in KCT_GameStates.KSCs) //this is faster one subsequent scene changes { foreach (KCT_BuildListVessel blv in KSC.VABList) { if (!blv.allPartsValid) { //error! KCTDebug.Log(blv.shipName + " contains invalid parts!"); erroredVessels.Add(blv); } } foreach (KCT_BuildListVessel blv in KSC.VABWarehouse) { if (!blv.allPartsValid) { //error! KCTDebug.Log(blv.shipName + " contains invalid parts!"); erroredVessels.Add(blv); } } foreach (KCT_BuildListVessel blv in KSC.SPHList) { if (!blv.allPartsValid) { //error! KCTDebug.Log(blv.shipName + " contains invalid parts!"); erroredVessels.Add(blv); } } foreach (KCT_BuildListVessel blv in KSC.SPHWarehouse) { if (!blv.allPartsValid) { //error! KCTDebug.Log(blv.shipName + " contains invalid parts!"); erroredVessels.Add(blv); } } } if (erroredVessels.Count > 0) { PopUpVesselError(erroredVessels); } KCT_GameStates.vesselErrorAlerted = true; } foreach (KCT_KSC KSC in KCT_GameStates.KSCs) { KSC.RecalculateBuildRates(); KSC.RecalculateUpgradedBuildRates(); } if (!HighLogic.LoadedSceneIsFlight && KCT_GameStates.buildSimulatedVessel) { KCT_GameStates.buildSimulatedVessel = false; KCT_BuildListVessel toBuild = KCT_GameStates.launchedVessel.NewCopy(false); toBuild.buildPoints = KCT_Utilities.GetBuildTime(toBuild.ExtractedPartNodes, true, KCT_GUI.useInventory); KCT_Utilities.AddVesselToBuildList(toBuild, KCT_GUI.useInventory); } if (HighLogic.LoadedSceneIsFlight && !KCT_GameStates.flightSimulated) { KCT_GUI.hideAll(); if (FlightGlobals.ActiveVessel.situation == Vessel.Situations.PRELAUNCH && KCT_GameStates.launchedVessel != null) { bool removed = KCT_GameStates.launchedVessel.RemoveFromBuildList(); if (removed) //Only do these when the vessel is first removed from the list { //Add the cost of the ship to the funds so it can be removed again by KSP //KCT_Utilities.AddFunds(KCT_Utilities.GetTotalVesselCost(FlightGlobals.ActiveVessel.protoVessel), TransactionReasons.VesselRollout); KCT_Utilities.AddFunds(KCT_GameStates.launchedVessel.cost, TransactionReasons.VesselRollout); FlightGlobals.ActiveVessel.vesselName = KCT_GameStates.launchedVessel.shipName; } KCT_Recon_Rollout rollout = KCT_GameStates.ActiveKSC.Recon_Rollout.FirstOrDefault(r => r.associatedID == KCT_GameStates.launchedVessel.id.ToString()); if (rollout != null) { KCT_GameStates.ActiveKSC.Recon_Rollout.Remove(rollout); } } } if (HighLogic.LoadedSceneIsEditor) { if (KCT_GameStates.EditorShipEditingMode) { KCTDebug.Log("Editing " + KCT_GameStates.editedVessel.shipName); EditorLogic.fetch.shipNameField.Text = KCT_GameStates.editedVessel.shipName; } if (!KCT_GUI.PrimarilyDisabled) { if (KCT_GameStates.settings.OverrideLaunchButton) { KCTDebug.Log("Taking control of launch button"); EditorLogic.fetch.launchBtn.methodToInvoke = "ShowLaunchAlert"; EditorLogic.fetch.launchBtn.scriptWithMethodToInvoke = KerbalConstructionTime.instance; } else { InputLockManager.SetControlLock(ControlTypes.EDITOR_LAUNCH, "KCTLaunchLock"); } KCT_Utilities.RecalculateEditorBuildTime(EditorLogic.fetch.ship); } } if (HighLogic.LoadedScene == GameScenes.SPACECENTER) { if (!KCT_GUI.PrimarilyDisabled) { if (ToolbarManager.ToolbarAvailable && KCT_GameStates.settings.PreferBlizzyToolbar) { if (KCT_GameStates.showWindows[0]) { KCT_GUI.ClickOn(); } else { if (KCT_Events.instance != null && KCT_Events.instance.KCTButtonStock != null) { //KCT_Events.instance.KCTButtonStock.SetTrue(true); //KCT_GUI.clicked = true; if (KCT_GameStates.showWindows[0]) { KCT_GUI.ClickOn(); } } /* else * { * KCT_GUI.showEditorGUI = KCT_GameStates.showWindows[0]; * }*/ } } KCT_GUI.ResetBLWindow(); } else { KCT_GUI.showBuildList = false; KCT_GameStates.showWindows[0] = false; } if (KCT_GameStates.firstStart) { KCTDebug.Log("Showing first start."); KCT_GUI.showFirstRun = true; //initialize the proper launchpad KCT_GameStates.ActiveKSC.ActiveLPInstance.level = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.LaunchPad); } KCT_GameStates.firstStart = false; if (KCT_GameStates.LaunchFromTS) { KCT_GameStates.launchedVessel.Launch(); } KCT_GameStates.ActiveKSC.SwitchLaunchPad(KCT_GameStates.ActiveKSC.ActiveLaunchPadID); foreach (KCT_KSC ksc in KCT_GameStates.KSCs) { //foreach (KCT_Recon_Rollout rr in ksc.Recon_Rollout) for (int i = 0; i < ksc.Recon_Rollout.Count; i++) { KCT_Recon_Rollout rr = ksc.Recon_Rollout[i]; if (rr.RRType != KCT_Recon_Rollout.RolloutReconType.Reconditioning && KCT_Utilities.FindBLVesselByID(new Guid(rr.associatedID)) == null) { KCTDebug.Log("Invalid Recon_Rollout at " + ksc.KSCName + ". ID " + rr.associatedID + " not found."); ksc.Recon_Rollout.Remove(rr); i--; } } } } }
public static void DrawBuildListWindow(int windowID) { if (buildListWindowPosition.xMax > Screen.width) { buildListWindowPosition.x = Screen.width - buildListWindowPosition.width; } //GUI.skin = HighLogic.Skin; GUIStyle redText = new GUIStyle(GUI.skin.label); redText.normal.textColor = Color.red; GUIStyle yellowText = new GUIStyle(GUI.skin.label); yellowText.normal.textColor = Color.yellow; GUIStyle greenText = new GUIStyle(GUI.skin.label); greenText.normal.textColor = Color.green; int width1 = 120; int width2 = 100; int butW = 20; GUILayout.BeginVertical(); //GUILayout.Label("Current KSC: " + KCT_GameStates.ActiveKSC.KSCName); //List next vessel to finish GUILayout.BeginHorizontal(); GUILayout.Label("Next:", windowSkin.label); IKCTBuildItem buildItem = KCT_Utilities.NextThingToFinish(); if (buildItem != null) { //KCT_BuildListVessel ship = (KCT_BuildListVessel)buildItem; GUILayout.Label(buildItem.GetItemName()); if (buildItem.GetListType() == KCT_BuildListVessel.ListType.VAB || buildItem.GetListType() == KCT_BuildListVessel.ListType.Reconditioning) { GUILayout.Label("VAB", windowSkin.label); GUILayout.Label(KCT_Utilities.GetColonFormattedTime(buildItem.GetTimeLeft())); } else if (buildItem.GetListType() == KCT_BuildListVessel.ListType.SPH) { GUILayout.Label("SPH", windowSkin.label); GUILayout.Label(KCT_Utilities.GetColonFormattedTime(buildItem.GetTimeLeft())); } else if (buildItem.GetListType() == KCT_BuildListVessel.ListType.TechNode) { GUILayout.Label("Tech", windowSkin.label); GUILayout.Label(KCT_Utilities.GetColonFormattedTime(buildItem.GetTimeLeft())); } else if (buildItem.GetListType() == KCT_BuildListVessel.ListType.KSC) { GUILayout.Label("KSC", windowSkin.label); GUILayout.Label(KCT_Utilities.GetColonFormattedTime(buildItem.GetTimeLeft())); } if (!HighLogic.LoadedSceneIsEditor && TimeWarp.CurrentRateIndex == 0 && GUILayout.Button("Warp to" + System.Environment.NewLine + "Complete")) { KCT_GameStates.targetedItem = buildItem; KCT_GameStates.canWarp = true; KCT_Utilities.RampUpWarp(); KCT_GameStates.warpInitiated = true; } else if (!HighLogic.LoadedSceneIsEditor && TimeWarp.CurrentRateIndex > 0 && GUILayout.Button("Stop" + System.Environment.NewLine + "Warp")) { KCT_GameStates.canWarp = false; TimeWarp.SetRate(0, true); KCT_GameStates.lastWarpRate = 0; } if (KCT_GameStates.settings.AutoKACAlarams && KACWrapper.APIReady) { double UT = Planetarium.GetUniversalTime(); if (!KCT_Utilities.ApproximatelyEqual(KCT_GameStates.KACAlarmUT - UT, buildItem.GetTimeLeft())) { KCTDebug.Log("KAC Alarm being created!"); KCT_GameStates.KACAlarmUT = (buildItem.GetTimeLeft() + UT); KACWrapper.KACAPI.KACAlarm alarm = KACWrapper.KAC.Alarms.FirstOrDefault(a => a.ID == KCT_GameStates.KACAlarmId); if (alarm == null) { alarm = KACWrapper.KAC.Alarms.FirstOrDefault(a => (a.Name.StartsWith("KCT: "))); } if (alarm != null) { KCTDebug.Log("Removing existing alarm"); KACWrapper.KAC.DeleteAlarm(alarm.ID); } KCT_GameStates.KACAlarmId = KACWrapper.KAC.CreateAlarm(KACWrapper.KACAPI.AlarmTypeEnum.Raw, "KCT: " + buildItem.GetItemName() + " Complete", KCT_GameStates.KACAlarmUT); KCTDebug.Log("Alarm created with ID: " + KCT_GameStates.KACAlarmId); } } } else { GUILayout.Label("No Active Projects"); } GUILayout.EndHorizontal(); //Buttons for VAB/SPH lists List <string> buttonList = new List <string> { "VAB", "SPH", "KSC" }; if (KCT_Utilities.CurrentGameHasScience() && !KCT_GameStates.settings.InstantTechUnlock) { buttonList.Add("Tech"); } GUILayout.BeginHorizontal(); //if (HighLogic.LoadedScene == GameScenes.SPACECENTER) { buttonList.Add("Upgrades"); buttonList.Add("Settings"); } int lastSelected = listWindow; listWindow = GUILayout.Toolbar(listWindow, buttonList.ToArray()); if (HighLogic.LoadedScene == GameScenes.SPACECENTER && GUILayout.Button("Upgrades")) { showUpgradeWindow = true; showBuildList = false; showBLPlus = false; } if (HighLogic.LoadedScene == GameScenes.SPACECENTER && GUILayout.Button("Settings")) { showBuildList = false; showBLPlus = false; ShowSettings(); } GUILayout.EndHorizontal(); if (GUI.changed) { buildListWindowPosition.height = 1; showBLPlus = false; if (lastSelected == listWindow) { listWindow = -1; } } //Content of lists if (listWindow == 0) //VAB Build List { List <KCT_BuildListVessel> buildList = KCT_GameStates.ActiveKSC.VABList; GUILayout.BeginHorizontal(); // GUILayout.Space((butW + 4) * 3); GUILayout.Label("Name:"); GUILayout.Label("Progress:", GUILayout.Width(width1 / 2)); GUILayout.Label("Time Left:", GUILayout.Width(width2)); //GUILayout.Label("BP:", GUILayout.Width(width1 / 2 + 10)); GUILayout.EndHorizontal(); if (KCT_Utilities.ReconditioningActive(null)) { GUILayout.BeginHorizontal(); IKCTBuildItem item = (IKCTBuildItem)KCT_GameStates.ActiveKSC.GetReconditioning(); GUILayout.Label(item.GetItemName()); GUILayout.Label(KCT_GameStates.ActiveKSC.GetReconditioning().ProgressPercent().ToString() + "%", GUILayout.Width(width1 / 2)); GUILayout.Label(KCT_Utilities.GetColonFormattedTime(item.GetTimeLeft()), GUILayout.Width(width2)); //GUILayout.Label(Math.Round(KCT_GameStates.ActiveKSC.GetReconditioning().BP, 2).ToString(), GUILayout.Width(width1 / 2 + 10)); if (!HighLogic.LoadedSceneIsEditor && GUILayout.Button("Warp To", GUILayout.Width((butW + 4) * 2))) { KCT_GameStates.targetedItem = item; KCT_GameStates.canWarp = true; KCT_Utilities.RampUpWarp(item); KCT_GameStates.warpInitiated = true; } //GUILayout.Space((butW + 4) * 3); GUILayout.EndHorizontal(); } scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.Height(250)); { if (buildList.Count == 0) { GUILayout.Label("No vessels under construction! Go to the VAB to build more."); } for (int i = 0; i < buildList.Count; i++) { KCT_BuildListVessel b = buildList[i]; GUILayout.BeginHorizontal(); //GUILayout.Label(b.shipName, GUILayout.Width(width1)); if (!HighLogic.LoadedSceneIsEditor && GUILayout.Button("*", GUILayout.Width(butW))) { if (IDSelected == b.id) { showBLPlus = !showBLPlus; } else { showBLPlus = true; } IDSelected = b.id; } else if (HighLogic.LoadedSceneIsEditor) { //GUILayout.Space(butW); if (GUILayout.Button("X", GUILayout.Width(butW))) { InputLockManager.SetControlLock(ControlTypes.EDITOR_SOFT_LOCK, "KCTPopupLock"); IDSelected = b.id; DialogOption[] options = new DialogOption[2]; options[0] = new DialogOption("Yes", ScrapVessel); options[1] = new DialogOption("No", DummyVoid); MultiOptionDialog diag = new MultiOptionDialog("Are you sure you want to scrap this vessel?", windowTitle: "Scrap Vessel", options: options); PopupDialog.SpawnPopupDialog(diag, false, windowSkin); } } if (i > 0 && GUILayout.Button("^", GUILayout.Width(butW))) { buildList.RemoveAt(i); if (GameSettings.MODIFIER_KEY.GetKey()) { buildList.Insert(0, b); } else { buildList.Insert(i - 1, b); } } else if (i == 0) { // GUILayout.Space(butW + 4); } if (i < buildList.Count - 1 && GUILayout.Button("v", GUILayout.Width(butW))) { buildList.RemoveAt(i); if (GameSettings.MODIFIER_KEY.GetKey()) { buildList.Add(b); } else { buildList.Insert(i + 1, b); } } else if (i >= buildList.Count - 1) { // GUILayout.Space(butW + 4); } GUILayout.Label(b.shipName); GUILayout.Label(Math.Round(b.ProgressPercent(), 2).ToString() + "%", GUILayout.Width(width1 / 2)); if (b.buildRate > 0) { GUILayout.Label(KCT_Utilities.GetColonFormattedTime(b.timeLeft), GUILayout.Width(width2)); } else { GUILayout.Label("Est: " + KCT_Utilities.GetColonFormattedTime((b.buildPoints - b.progress) / KCT_Utilities.GetBuildRate(0, KCT_BuildListVessel.ListType.VAB, null)), GUILayout.Width(width2)); } // GUILayout.Label(Math.Round(b.buildPoints, 2).ToString(), GUILayout.Width(width1 / 2 + 10)); GUILayout.EndHorizontal(); } //ADD Storage here! buildList = KCT_GameStates.ActiveKSC.VABWarehouse; GUILayout.Label("__________________________________________________"); GUILayout.Label("VAB Storage"); if (HighLogic.LoadedSceneIsFlight && FlightGlobals.ActiveVessel != null && FlightGlobals.ActiveVessel.IsRecoverable && FlightGlobals.ActiveVessel.IsClearToSave() == ClearToSaveStatus.CLEAR && GUILayout.Button("Recover Active Vessel")) { KCT_GameStates.recoveredVessel = new KCT_BuildListVessel(FlightGlobals.ActiveVessel); KCT_GameStates.recoveredVessel.type = KCT_BuildListVessel.ListType.VAB; KCT_GameStates.recoveredVessel.launchSite = "LaunchPad"; // HighLogic.LoadScene(GameScenes.SPACECENTER); //ShipConstruction.RecoverVesselFromFlight(FlightGlobals.ActiveVessel.protoVessel, HighLogic.CurrentGame.flightState); GameEvents.OnVesselRecoveryRequested.Fire(FlightGlobals.ActiveVessel); } if (buildList.Count == 0) { GUILayout.Label("No vessels in storage!\nThey will be stored here when they are complete."); } KCT_Recon_Rollout rollout = KCT_GameStates.ActiveKSC.GetReconRollout(KCT_Recon_Rollout.RolloutReconType.Rollout); //KCT_Recon_Rollout rollback = KCT_GameStates.ActiveKSC.GetReconRollout(KCT_Recon_Rollout.RolloutReconType.Rollback); bool rolloutEnabled = KCT_GameStates.settings.Reconditioning && KCT_GameStates.timeSettings.RolloutReconSplit > 0; for (int i = 0; i < buildList.Count; i++) { KCT_BuildListVessel b = buildList[i]; KCT_Recon_Rollout rollback = KCT_GameStates.ActiveKSC.Recon_Rollout.FirstOrDefault(r => r.associatedID == b.id.ToString() && r.RRType == KCT_Recon_Rollout.RolloutReconType.Rollback); KCT_Recon_Rollout recovery = KCT_GameStates.ActiveKSC.Recon_Rollout.FirstOrDefault(r => r.associatedID == b.id.ToString() && r.RRType == KCT_Recon_Rollout.RolloutReconType.Recovery); GUIStyle textColor = new GUIStyle(GUI.skin.label); GUIStyle buttonColor = new GUIStyle(GUI.skin.button); string status = "In Storage"; if (rollout != null && rollout.associatedID == b.id.ToString()) { status = "Rolling Out"; textColor = yellowText; if (rollout.AsBuildItem().IsComplete()) { status = "On the Pad"; textColor = greenText; } } else if (rollback != null) { status = "Rolling Back"; textColor = yellowText; } else if (recovery != null) { status = "Recovering"; textColor = redText; } GUILayout.BeginHorizontal(); if (!HighLogic.LoadedSceneIsEditor && status == "In Storage") { if (GUILayout.Button("*", GUILayout.Width(butW))) { if (IDSelected == b.id) { showBLPlus = !showBLPlus; } else { showBLPlus = true; } IDSelected = b.id; } } else { GUILayout.Space(butW + 4); } GUILayout.Label(b.shipName, textColor); GUILayout.Label(status + " ", textColor, GUILayout.ExpandWidth(false)); if (rolloutEnabled && !HighLogic.LoadedSceneIsEditor && recovery == null && (rollout == null || b.id.ToString() != rollout.associatedID) && rollback == null && GUILayout.Button("Rollout", GUILayout.ExpandWidth(false))) { if (rollout != null) { rollout.SwapRolloutType(); } KCT_GameStates.ActiveKSC.Recon_Rollout.Add(new KCT_Recon_Rollout(b, KCT_Recon_Rollout.RolloutReconType.Rollout, b.id.ToString())); } else if (rolloutEnabled && !HighLogic.LoadedSceneIsEditor && recovery == null && rollout != null && b.id.ToString() == rollout.associatedID && !rollout.AsBuildItem().IsComplete() && rollback == null && GUILayout.Button(KCT_Utilities.GetColonFormattedTime(rollout.AsBuildItem().GetTimeLeft()), GUILayout.ExpandWidth(false))) { rollout.SwapRolloutType(); } else if (rolloutEnabled && !HighLogic.LoadedSceneIsEditor && recovery == null && rollback != null && b.id.ToString() == rollback.associatedID && !rollback.AsBuildItem().IsComplete()) { if (rollout == null) { if (GUILayout.Button(KCT_Utilities.GetColonFormattedTime(rollback.AsBuildItem().GetTimeLeft()), GUILayout.ExpandWidth(false))) { rollback.SwapRolloutType(); } } else { GUILayout.Label(KCT_Utilities.GetColonFormattedTime(rollback.AsBuildItem().GetTimeLeft()), GUILayout.ExpandWidth(false)); } } else if (HighLogic.LoadedScene != GameScenes.TRACKSTATION && recovery == null && (!rolloutEnabled || (rollout != null && b.id.ToString() == rollout.associatedID && rollout.AsBuildItem().IsComplete()))) { if (rolloutEnabled && GameSettings.MODIFIER_KEY.GetKey() && GUILayout.Button("Roll Back", GUILayout.ExpandWidth(false))) { rollout.SwapRolloutType(); } else if (!GameSettings.MODIFIER_KEY.GetKey() && GUILayout.Button("Launch", GUILayout.ExpandWidth(false))) { bool operational = KCT_Utilities.LaunchFacilityIntact(KCT_BuildListVessel.ListType.VAB);//new PreFlightTests.FacilityOperational("LaunchPad", "building").Test(); if (!operational) { ScreenMessages.PostScreenMessage("You must repair the launchpad prior to launch!", 4.0f, ScreenMessageStyle.UPPER_CENTER); } else if (KCT_Utilities.ReconditioningActive(null)) { //can't launch now ScreenMessage message = new ScreenMessage("[KCT] Cannot launch while LaunchPad is being reconditioned. It will be finished in " + KCT_Utilities.GetFormattedTime(((IKCTBuildItem)KCT_GameStates.ActiveKSC.GetReconditioning()).GetTimeLeft()), 4.0f, ScreenMessageStyle.UPPER_CENTER); ScreenMessages.PostScreenMessage(message, true); } else { /*if (rollout != null) * KCT_GameStates.ActiveKSC.Recon_Rollout.Remove(rollout);*/ KCT_GameStates.launchedVessel = b; if (ShipConstruction.FindVesselsLandedAt(HighLogic.CurrentGame.flightState, "LaunchPad").Count == 0)// ShipConstruction.CheckLaunchSiteClear(HighLogic.CurrentGame.flightState, "LaunchPad", false)) { showBLPlus = false; // buildList.RemoveAt(i); if (!IsCrewable(b.ExtractedParts)) { b.Launch(); } else { showBuildList = false; centralWindowPosition.height = 1; KCT_GameStates.launchedCrew.Clear(); parts = KCT_GameStates.launchedVessel.ExtractedParts; pseudoParts = KCT_GameStates.launchedVessel.GetPseudoParts(); KCT_GameStates.launchedCrew = new List <CrewedPart>(); foreach (PseudoPart pp in pseudoParts) { KCT_GameStates.launchedCrew.Add(new CrewedPart(pp.uid, new List <ProtoCrewMember>())); } CrewFirstAvailable(); showShipRoster = true; } } else { showBuildList = false; showClearLaunch = true; } } } } else if (!HighLogic.LoadedSceneIsEditor && recovery != null) { GUILayout.Label(KCT_Utilities.GetColonFormattedTime(recovery.AsBuildItem().GetTimeLeft()), GUILayout.ExpandWidth(false)); } GUILayout.EndHorizontal(); } } GUILayout.EndScrollView(); } else if (listWindow == 1) //SPH Build List { List <KCT_BuildListVessel> buildList = KCT_GameStates.ActiveKSC.SPHList; GUILayout.BeginHorizontal(); // GUILayout.Space((butW + 4) * 3); GUILayout.Label("Name:"); GUILayout.Label("Progress:", GUILayout.Width(width1 / 2)); GUILayout.Label("Time Left:", GUILayout.Width(width2)); //GUILayout.Label("BP:", GUILayout.Width(width1 / 2 + 10)); GUILayout.EndHorizontal(); scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.Height(250)); { if (buildList.Count == 0) { GUILayout.Label("No vessels under construction! Go to the SPH to build more."); } for (int i = 0; i < buildList.Count; i++) { KCT_BuildListVessel b = buildList[i]; GUILayout.BeginHorizontal(); if (!HighLogic.LoadedSceneIsEditor && GUILayout.Button("*", GUILayout.Width(butW))) { if (IDSelected == b.id) { showBLPlus = !showBLPlus; } else { showBLPlus = true; } IDSelected = b.id; } else if (HighLogic.LoadedSceneIsEditor) { //GUILayout.Space(butW); if (GUILayout.Button("X", GUILayout.Width(butW))) { InputLockManager.SetControlLock(ControlTypes.EDITOR_SOFT_LOCK, "KCTPopupLock"); IDSelected = b.id; DialogOption[] options = new DialogOption[2]; options[0] = new DialogOption("Yes", ScrapVessel); options[1] = new DialogOption("No", DummyVoid); MultiOptionDialog diag = new MultiOptionDialog("Are you sure you want to scrap " + b.shipName + "?", windowTitle: "Scrap Vessel", options: options); PopupDialog.SpawnPopupDialog(diag, false, windowSkin); } } if (i > 0 && GUILayout.Button("^", GUILayout.Width(butW))) { buildList.RemoveAt(i); if (GameSettings.MODIFIER_KEY.GetKey()) { buildList.Insert(0, b); } else { buildList.Insert(i - 1, b); } } else if (i == 0) { // GUILayout.Space(butW + 4); } if (i < buildList.Count - 1 && GUILayout.Button("v", GUILayout.Width(butW))) { buildList.RemoveAt(i); if (GameSettings.MODIFIER_KEY.GetKey()) { buildList.Add(b); } else { buildList.Insert(i + 1, b); } } else if (i >= buildList.Count - 1) { // GUILayout.Space(butW + 4); } GUILayout.Label(b.shipName); GUILayout.Label(Math.Round(b.ProgressPercent(), 2).ToString() + "%", GUILayout.Width(width1 / 2)); if (b.buildRate > 0) { GUILayout.Label(KCT_Utilities.GetColonFormattedTime(b.timeLeft), GUILayout.Width(width2)); } else { GUILayout.Label("Est: " + KCT_Utilities.GetColonFormattedTime((b.buildPoints - b.progress) / KCT_Utilities.GetBuildRate(0, KCT_BuildListVessel.ListType.SPH, null)), GUILayout.Width(width2)); } //GUILayout.Label(Math.Round(b.buildPoints, 2).ToString(), GUILayout.Width(width1 / 2 + 10)); GUILayout.EndHorizontal(); } buildList = KCT_GameStates.ActiveKSC.SPHWarehouse; GUILayout.Label("__________________________________________________"); GUILayout.Label("SPH Storage"); if (HighLogic.LoadedSceneIsFlight && FlightGlobals.ActiveVessel != null && FlightGlobals.ActiveVessel.IsRecoverable && FlightGlobals.ActiveVessel.IsClearToSave() == ClearToSaveStatus.CLEAR && GUILayout.Button("Recover Active Vessel")) { KCT_GameStates.recoveredVessel = new KCT_BuildListVessel(FlightGlobals.ActiveVessel); KCT_GameStates.recoveredVessel.type = KCT_BuildListVessel.ListType.SPH; KCT_GameStates.recoveredVessel.launchSite = "Runway"; //ShipConstruction.RecoverVesselFromFlight(FlightGlobals.ActiveVessel.protoVessel, HighLogic.CurrentGame.flightState); GameEvents.OnVesselRecoveryRequested.Fire(FlightGlobals.ActiveVessel); } for (int i = 0; i < buildList.Count; i++) { KCT_BuildListVessel b = buildList[i]; string status = ""; KCT_Recon_Rollout recovery = KCT_GameStates.ActiveKSC.Recon_Rollout.FirstOrDefault(r => r.associatedID == b.id.ToString() && r.RRType == KCT_Recon_Rollout.RolloutReconType.Recovery); if (recovery != null) { status = "Recovering"; } GUILayout.BeginHorizontal(); if (!HighLogic.LoadedSceneIsEditor && status == "") { if (GUILayout.Button("*", GUILayout.Width(butW))) { if (IDSelected == b.id) { showBLPlus = !showBLPlus; } else { showBLPlus = true; } IDSelected = b.id; } } else { GUILayout.Space(butW + 4); } GUILayout.Label(b.shipName); GUILayout.Label(status + " ", GUILayout.ExpandWidth(false)); //ScenarioDestructibles.protoDestructibles["KSCRunway"]. if (HighLogic.LoadedScene != GameScenes.TRACKSTATION && recovery == null && GUILayout.Button("Launch", GUILayout.ExpandWidth(false))) { bool operational = KCT_Utilities.LaunchFacilityIntact(KCT_BuildListVessel.ListType.SPH);//new PreFlightTests.FacilityOperational("Runway", "building").Test(); if (!operational) { ScreenMessages.PostScreenMessage("You must repair the runway prior to launch!", 4.0f, ScreenMessageStyle.UPPER_CENTER); } else { showBLPlus = false; KCT_GameStates.launchedVessel = b; if (ShipConstruction.FindVesselsLandedAt(HighLogic.CurrentGame.flightState, "Runway").Count == 0) { if (!IsCrewable(b.ExtractedParts)) { b.Launch(); } else { showBuildList = false; centralWindowPosition.height = 1; KCT_GameStates.launchedCrew.Clear(); parts = KCT_GameStates.launchedVessel.ExtractedParts; pseudoParts = KCT_GameStates.launchedVessel.GetPseudoParts(); KCT_GameStates.launchedCrew = new List <CrewedPart>(); foreach (PseudoPart pp in pseudoParts) { KCT_GameStates.launchedCrew.Add(new CrewedPart(pp.uid, new List <ProtoCrewMember>())); } CrewFirstAvailable(); showShipRoster = true; } } else { showBuildList = false; showClearLaunch = true; } } } else if (recovery != null) { GUILayout.Label(KCT_Utilities.GetColonFormattedTime(recovery.AsBuildItem().GetTimeLeft()), GUILayout.ExpandWidth(false)); } GUILayout.EndHorizontal(); } if (buildList.Count == 0) { GUILayout.Label("No vessels in storage!\nThey will be stored here when they are complete."); } } GUILayout.EndScrollView(); } else if (listWindow == 2) //KSC things { List <KCT_UpgradingBuilding> KSCList = KCT_GameStates.ActiveKSC.KSCTech; GUILayout.BeginHorizontal(); GUILayout.Label("Name:"); GUILayout.Label("Progress:", GUILayout.Width(width1 / 2)); GUILayout.Label("Time Left:", GUILayout.Width(width1)); GUILayout.Space(70); GUILayout.EndHorizontal(); scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.Height(250)); if (KSCList.Count == 0) { GUILayout.Label("No upgrade projects are currently underway."); } foreach (KCT_UpgradingBuilding KCTTech in KSCList) { GUILayout.BeginHorizontal(); GUILayout.Label(KCTTech.AsIKCTBuildItem().GetItemName()); GUILayout.Label(Math.Round(100 * KCTTech.progress / KCTTech.BP, 2) + " %", GUILayout.Width(width1 / 2)); GUILayout.Label(KCT_Utilities.GetColonFormattedTime(KCTTech.AsIKCTBuildItem().GetTimeLeft()), GUILayout.Width(width1)); if (!HighLogic.LoadedSceneIsEditor && GUILayout.Button("Warp To", GUILayout.Width(70))) { KCT_GameStates.targetedItem = KCTTech; KCT_GameStates.canWarp = true; KCT_Utilities.RampUpWarp(KCTTech); KCT_GameStates.warpInitiated = true; } else if (HighLogic.LoadedSceneIsEditor) { GUILayout.Space(70); } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); } else if (listWindow == 3) //Tech nodes { List <KCT_TechItem> techList = KCT_GameStates.TechList; //GUILayout.Label("Tech Node Research"); GUILayout.BeginHorizontal(); GUILayout.Label("Node Name:"); GUILayout.Label("Progress:", GUILayout.Width(width1 / 2)); GUILayout.Label("Time Left:", GUILayout.Width(width1)); GUILayout.Space(70); GUILayout.EndHorizontal(); scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.Height(250)); if (techList.Count == 0) { GUILayout.Label("No tech nodes are being researched!\nBegin research by unlocking tech in the R&D building."); } for (int i = 0; i < techList.Count; i++) { KCT_TechItem t = techList[i]; GUILayout.BeginHorizontal(); GUILayout.Label(t.techName); GUILayout.Label(Math.Round(100 * t.progress / t.scienceCost, 2) + " %", GUILayout.Width(width1 / 2)); GUILayout.Label(KCT_Utilities.GetColonFormattedTime(t.TimeLeft), GUILayout.Width(width1)); if (!HighLogic.LoadedSceneIsEditor && GUILayout.Button("Warp To", GUILayout.Width(70))) { KCT_GameStates.targetedItem = t; KCT_GameStates.canWarp = true; KCT_Utilities.RampUpWarp(t); KCT_GameStates.warpInitiated = true; } else if (HighLogic.LoadedSceneIsEditor) { GUILayout.Space(70); } GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); } if (KCT_UpdateChecker.UpdateFound) { GUILayout.BeginHorizontal(); GUILayout.Label("Current Version: " + KCT_UpdateChecker.CurrentVersion); GUILayout.Label("Latest: " + KCT_UpdateChecker.WebVersion); GUILayout.EndHorizontal(); } if (KCT_SpecialSurpriseInside.instance.activated) { GUILayout.BeginHorizontal(); //jeb coin img, jeb coin amt, store button, daily challenge, SRB races GUILayout.Label(KCT_SpecialSurpriseInside.instance.jebCoinTex, GUILayout.ExpandWidth(false)); if (GUILayout.Button(" Jeb Coins: " + KCT_SpecialSurpriseInside.instance.TotalJebCoins, GUILayout.ExpandWidth(false))) { KCT_SpecialSurpriseInside.instance.JebCoinStore(); } GUILayout.Label(""); if (GUILayout.Button("Daily Challenge", GUILayout.ExpandWidth(false))) { KCT_SpecialSurpriseInside.instance.DailyChallengePopup(); } GUILayout.Label(""); if (GUILayout.Button("Race SRBs", GUILayout.ExpandWidth(false))) { KCT_SpecialSurpriseInside.instance.showRace = true; showBuildList = false; } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); }
public KCT_KSC FromConfigNode(ConfigNode node) { VABUpgrades.Clear(); SPHUpgrades.Clear(); RDUpgrades.Clear(); VABList.Clear(); VABWarehouse.Clear(); SPHList.Clear(); SPHWarehouse.Clear(); KSCTech.Clear(); //TechList.Clear(); Recon_Rollout.Clear(); this.KSCName = node.GetValue("KSCName"); ConfigNode vabup = node.GetNode("VABUpgrades"); foreach (string upgrade in vabup.GetValues("Upgrade")) { this.VABUpgrades.Add(int.Parse(upgrade)); } ConfigNode sphup = node.GetNode("SPHUpgrades"); foreach (string upgrade in sphup.GetValues("Upgrade")) { this.SPHUpgrades.Add(int.Parse(upgrade)); } ConfigNode rdup = node.GetNode("RDUpgrades"); foreach (string upgrade in rdup.GetValues("Upgrade")) { this.RDUpgrades.Add(int.Parse(upgrade)); } ConfigNode tmp = node.GetNode("VABList"); foreach (ConfigNode vessel in tmp.GetNodes("KCTVessel")) { KCT_BuildListStorage.BuildListItem listItem = new KCT_BuildListStorage.BuildListItem(); ConfigNode.LoadObjectFromConfig(listItem, vessel); KCT_BuildListVessel blv = listItem.ToBuildListVessel(); blv.shipNode = vessel.GetNode("ShipNode"); this.VABList.Add(blv); } tmp = node.GetNode("SPHList"); foreach (ConfigNode vessel in tmp.GetNodes("KCTVessel")) { KCT_BuildListStorage.BuildListItem listItem = new KCT_BuildListStorage.BuildListItem(); ConfigNode.LoadObjectFromConfig(listItem, vessel); KCT_BuildListVessel blv = listItem.ToBuildListVessel(); blv.shipNode = vessel.GetNode("ShipNode"); this.SPHList.Add(blv); } tmp = node.GetNode("VABWarehouse"); foreach (ConfigNode vessel in tmp.GetNodes("KCTVessel")) { KCT_BuildListStorage.BuildListItem listItem = new KCT_BuildListStorage.BuildListItem(); ConfigNode.LoadObjectFromConfig(listItem, vessel); KCT_BuildListVessel blv = listItem.ToBuildListVessel(); blv.shipNode = vessel.GetNode("ShipNode"); this.VABWarehouse.Add(blv); } tmp = node.GetNode("SPHWarehouse"); foreach (ConfigNode vessel in tmp.GetNodes("KCTVessel")) { KCT_BuildListStorage.BuildListItem listItem = new KCT_BuildListStorage.BuildListItem(); ConfigNode.LoadObjectFromConfig(listItem, vessel); KCT_BuildListVessel blv = listItem.ToBuildListVessel(); blv.shipNode = vessel.GetNode("ShipNode"); this.SPHWarehouse.Add(blv); } /* tmp = node.GetNode("TechList"); * foreach (ConfigNode techNode in tmp.GetNodes("Tech")) * { * KCT_TechStorageItem techStorageItem = new KCT_TechStorageItem(); * ConfigNode.LoadObjectFromConfig(techStorageItem, techNode); * KCT_TechItem techItem = techStorageItem.ToTechItem(); * techItem.protoNode = new ProtoTechNode(techNode.GetNode("ProtoNode")); * this.TechList.Add(techItem); * }*/ tmp = node.GetNode("Recon_Rollout"); foreach (ConfigNode RRCN in tmp.GetNodes("Recon_Rollout_Item")) { KCT_Recon_Rollout tempRR = new KCT_Recon_Rollout(); ConfigNode.LoadObjectFromConfig(tempRR, RRCN); Recon_Rollout.Add(tempRR); } if (node.HasNode("KSCTech")) { tmp = node.GetNode("KSCTech"); foreach (ConfigNode upBuild in tmp.GetNodes("UpgradingBuilding")) { KCT_UpgradingBuilding tempUP = new KCT_UpgradingBuilding(); ConfigNode.LoadObjectFromConfig(tempUP, upBuild); KSCTech.Add(tempUP); } } return(this); }
public KCT_KSC FromConfigNode(ConfigNode node) { VABUpgrades.Clear(); SPHUpgrades.Clear(); RDUpgrades.Clear(); VABList.Clear(); VABWarehouse.Clear(); SPHList.Clear(); SPHWarehouse.Clear(); VABPlans.Clear(); SPHPlans.Clear(); KSCTech.Clear(); //TechList.Clear(); Recon_Rollout.Clear(); AirlaunchPrep.Clear(); VABRates.Clear(); SPHRates.Clear(); this.KSCName = node.GetValue("KSCName"); if (!int.TryParse(node.GetValue("ActiveLPID"), out this.ActiveLaunchPadID)) { this.ActiveLaunchPadID = 0; } ConfigNode vabup = node.GetNode("VABUpgrades"); foreach (string upgrade in vabup.GetValues("Upgrade")) { this.VABUpgrades.Add(int.Parse(upgrade)); } ConfigNode sphup = node.GetNode("SPHUpgrades"); foreach (string upgrade in sphup.GetValues("Upgrade")) { this.SPHUpgrades.Add(int.Parse(upgrade)); } ConfigNode rdup = node.GetNode("RDUpgrades"); foreach (string upgrade in rdup.GetValues("Upgrade")) { this.RDUpgrades.Add(int.Parse(upgrade)); } ConfigNode tmp = node.GetNode("VABList"); foreach (ConfigNode vessel in tmp.GetNodes("KCTVessel")) { KCT_BuildListStorage.BuildListItem listItem = new KCT_BuildListStorage.BuildListItem(); ConfigNode.LoadObjectFromConfig(listItem, vessel); KCT_BuildListVessel blv = listItem.ToBuildListVessel(); blv.shipNode = vessel.GetNode("ShipNode"); blv.KSC = this; this.VABList.Add(blv); } tmp = node.GetNode("SPHList"); foreach (ConfigNode vessel in tmp.GetNodes("KCTVessel")) { KCT_BuildListStorage.BuildListItem listItem = new KCT_BuildListStorage.BuildListItem(); ConfigNode.LoadObjectFromConfig(listItem, vessel); KCT_BuildListVessel blv = listItem.ToBuildListVessel(); blv.shipNode = vessel.GetNode("ShipNode"); blv.KSC = this; this.SPHList.Add(blv); } tmp = node.GetNode("VABWarehouse"); foreach (ConfigNode vessel in tmp.GetNodes("KCTVessel")) { KCT_BuildListStorage.BuildListItem listItem = new KCT_BuildListStorage.BuildListItem(); ConfigNode.LoadObjectFromConfig(listItem, vessel); KCT_BuildListVessel blv = listItem.ToBuildListVessel(); blv.shipNode = vessel.GetNode("ShipNode"); blv.KSC = this; this.VABWarehouse.Add(blv); } tmp = node.GetNode("SPHWarehouse"); foreach (ConfigNode vessel in tmp.GetNodes("KCTVessel")) { KCT_BuildListStorage.BuildListItem listItem = new KCT_BuildListStorage.BuildListItem(); ConfigNode.LoadObjectFromConfig(listItem, vessel); KCT_BuildListVessel blv = listItem.ToBuildListVessel(); blv.shipNode = vessel.GetNode("ShipNode"); blv.KSC = this; this.SPHWarehouse.Add(blv); } if (node.TryGetNode("VABPlans", ref tmp)) { if (tmp.HasNode("KCTVessel")) { foreach (ConfigNode vessel in tmp.GetNodes("KCTVessel")) { KCT_BuildListStorage.BuildListItem listItem = new KCT_BuildListStorage.BuildListItem(); ConfigNode.LoadObjectFromConfig(listItem, vessel); KCT_BuildListVessel blv = listItem.ToBuildListVessel(); blv.shipNode = vessel.GetNode("ShipNode"); blv.KSC = this; if (this.VABPlans.ContainsKey(blv.shipName)) { this.VABPlans.Remove(blv.shipName); } this.VABPlans.Add(blv.shipName, blv); } } } if (node.TryGetNode("SPHPlans", ref tmp)) { if (tmp.HasNode("KCTVessel")) { foreach (ConfigNode vessel in tmp.GetNodes("KCTVessel")) { KCT_BuildListStorage.BuildListItem listItem = new KCT_BuildListStorage.BuildListItem(); ConfigNode.LoadObjectFromConfig(listItem, vessel); KCT_BuildListVessel blv = listItem.ToBuildListVessel(); blv.shipNode = vessel.GetNode("ShipNode"); blv.KSC = this; if (this.SPHPlans.ContainsKey(blv.shipName)) { this.SPHPlans.Remove(blv.shipName); } this.SPHPlans.Add(blv.shipName, blv); } } } tmp = node.GetNode("Recon_Rollout"); foreach (ConfigNode RRCN in tmp.GetNodes("Recon_Rollout_Item")) { KCT_Recon_Rollout tempRR = new KCT_Recon_Rollout(); ConfigNode.LoadObjectFromConfig(tempRR, RRCN); Recon_Rollout.Add(tempRR); } if (node.TryGetNode("Airlaunch_Prep", ref tmp)) { foreach (ConfigNode APCN in tmp.GetNodes("Airlaunch_Prep_Item")) { KCT_AirlaunchPrep temp = new KCT_AirlaunchPrep(); ConfigNode.LoadObjectFromConfig(temp, APCN); AirlaunchPrep.Add(temp); } } if (node.HasNode("KSCTech")) { tmp = node.GetNode("KSCTech"); foreach (ConfigNode upBuild in tmp.GetNodes("UpgradingBuilding")) { KCT_UpgradingBuilding tempUP = new KCT_UpgradingBuilding(); tempUP.Load(upBuild); KSCTech.Add(tempUP); } } if (node.HasNode("LaunchPads")) { LaunchPads.Clear(); tmp = node.GetNode("LaunchPads"); foreach (ConfigNode LP in tmp.GetNodes("KCT_LaunchPad")) { KCT_LaunchPad tempLP = new KCT_LaunchPad("LP0"); ConfigNode.LoadObjectFromConfig(tempLP, LP); tempLP.DestructionNode = LP.GetNode("DestructionState"); LaunchPads.Add(tempLP); } } if (node.HasNode("VABRateCache")) { foreach (string rate in node.GetNode("VABRateCache").GetValues("rate")) { double r; if (double.TryParse(rate, out r)) { VABRates.Add(r); } } } if (node.HasNode("SPHRateCache")) { foreach (string rate in node.GetNode("SPHRateCache").GetValues("rate")) { double r; if (double.TryParse(rate, out r)) { SPHRates.Add(r); } } } return(this); }
public static void DrawBuildListWindow(int windowID) { if (buildListWindowPosition.xMax > Screen.width) buildListWindowPosition.x = Screen.width - buildListWindowPosition.width; //if (Input.touchCount == 0) MouseOnRolloutButton = false; //GUI.skin = HighLogic.UISkin; GUIStyle redText = new GUIStyle(GUI.skin.label); redText.normal.textColor = Color.red; GUIStyle yellowText = new GUIStyle(GUI.skin.label); yellowText.normal.textColor = Color.yellow; GUIStyle greenText = new GUIStyle(GUI.skin.label); greenText.normal.textColor = Color.green; GUIStyle normalButton = new GUIStyle(GUI.skin.button); GUIStyle yellowButton = new GUIStyle(GUI.skin.button); yellowButton.normal.textColor = Color.yellow; yellowButton.hover.textColor = Color.yellow; yellowButton.active.textColor = Color.yellow; GUIStyle redButton = new GUIStyle(GUI.skin.button); redButton.normal.textColor = Color.red; redButton.hover.textColor = Color.red; redButton.active.textColor = Color.red; GUIStyle greenButton = new GUIStyle(GUI.skin.button); greenButton.normal.textColor = Color.green; greenButton.hover.textColor = Color.green; greenButton.active.textColor = Color.green; int width1 = 120; int width2 = 100; int butW = 20; GUILayout.BeginVertical(); //GUILayout.Label("Current KSC: " + KCT_GameStates.ActiveKSC.KSCName); //List next vessel to finish GUILayout.BeginHorizontal(); GUILayout.Label("Next:", windowSkin.label); IKCTBuildItem buildItem = KCT_Utilities.NextThingToFinish(); if (buildItem != null) { //KCT_BuildListVessel ship = (KCT_BuildListVessel)buildItem; string txt = buildItem.GetItemName(), locTxt = "VAB"; if (buildItem.GetListType() == KCT_BuildListVessel.ListType.Reconditioning) { KCT_Recon_Rollout reconRoll = buildItem as KCT_Recon_Rollout; if (reconRoll.RRType == KCT_Recon_Rollout.RolloutReconType.Reconditioning) { txt = "Reconditioning"; locTxt = reconRoll.launchPadID; } else if (reconRoll.RRType == KCT_Recon_Rollout.RolloutReconType.Rollout) { KCT_BuildListVessel associated = reconRoll.KSC.VABWarehouse.FirstOrDefault(blv => blv.id.ToString() == reconRoll.associatedID); txt = associated.shipName + " Rollout"; locTxt = reconRoll.launchPadID; } else if (reconRoll.RRType == KCT_Recon_Rollout.RolloutReconType.Rollback) { KCT_BuildListVessel associated = reconRoll.KSC.VABWarehouse.FirstOrDefault(blv => blv.id.ToString() == reconRoll.associatedID); txt = associated.shipName + " Rollback"; locTxt = reconRoll.launchPadID; } else { locTxt = "VAB"; } } else if (buildItem.GetListType() == KCT_BuildListVessel.ListType.VAB) { locTxt = "VAB"; } else if (buildItem.GetListType() == KCT_BuildListVessel.ListType.SPH) { locTxt = "SPH"; } else if (buildItem.GetListType() == KCT_BuildListVessel.ListType.TechNode) { locTxt = "Tech"; } else if (buildItem.GetListType() == KCT_BuildListVessel.ListType.KSC) { locTxt = "KSC"; } GUILayout.Label(txt); GUILayout.Label(locTxt, windowSkin.label); GUILayout.Label(MagiCore.Utilities.GetColonFormattedTime(buildItem.GetTimeLeft())); if (!HighLogic.LoadedSceneIsEditor && TimeWarp.CurrentRateIndex == 0 && GUILayout.Button("Warp to" + System.Environment.NewLine + "Complete")) { KCT_GameStates.targetedItem = buildItem; KCT_GameStates.canWarp = true; KCT_Utilities.RampUpWarp(); KCT_GameStates.warpInitiated = true; /* if (buildItem.GetBuildRate() > 0) { TimeWarp.fetch.WarpTo(Planetarium.GetUniversalTime() + buildItem.GetTimeLeft(), KCT_GameStates.settings.MaxTimeWarp, 1); }*/ } else if (!HighLogic.LoadedSceneIsEditor && TimeWarp.CurrentRateIndex > 0 && GUILayout.Button("Stop" + System.Environment.NewLine + "Warp")) { KCT_GameStates.canWarp = false; TimeWarp.SetRate(0, true); KCT_GameStates.lastWarpRate = 0; } if (KCT_GameStates.settings.AutoKACAlarms && KACWrapper.APIReady && buildItem.GetTimeLeft() > 30) //don't check if less than 30 seconds to completion. Might fix errors people are seeing { double UT = Planetarium.GetUniversalTime(); if (!KCT_Utilities.ApproximatelyEqual(KCT_GameStates.KACAlarmUT - UT, buildItem.GetTimeLeft())) { KCTDebug.Log("KAC Alarm being created!"); KCT_GameStates.KACAlarmUT = (buildItem.GetTimeLeft() + UT); KACWrapper.KACAPI.KACAlarm alarm = KACWrapper.KAC.Alarms.FirstOrDefault(a => a.ID == KCT_GameStates.KACAlarmId); if (alarm == null) { alarm = KACWrapper.KAC.Alarms.FirstOrDefault(a => (a.Name.StartsWith("KCT: "))); } if (alarm != null) { KCTDebug.Log("Removing existing alarm"); KACWrapper.KAC.DeleteAlarm(alarm.ID); } txt = "KCT: "; if (buildItem.GetListType() == KCT_BuildListVessel.ListType.Reconditioning) { KCT_Recon_Rollout reconRoll = buildItem as KCT_Recon_Rollout; if (reconRoll.RRType == KCT_Recon_Rollout.RolloutReconType.Reconditioning) { txt += reconRoll.launchPadID + " Reconditioning"; } else if (reconRoll.RRType == KCT_Recon_Rollout.RolloutReconType.Rollout) { KCT_BuildListVessel associated = reconRoll.KSC.VABWarehouse.FirstOrDefault(blv => blv.id.ToString() == reconRoll.associatedID); txt += associated.shipName + " rollout at " + reconRoll.launchPadID; } else if (reconRoll.RRType == KCT_Recon_Rollout.RolloutReconType.Rollback) { KCT_BuildListVessel associated = reconRoll.KSC.VABWarehouse.FirstOrDefault(blv => blv.id.ToString() == reconRoll.associatedID); txt += associated.shipName + " rollback at " + reconRoll.launchPadID; } else { txt += buildItem.GetItemName() + " Complete"; } } else txt += buildItem.GetItemName() + " Complete"; KCT_GameStates.KACAlarmId = KACWrapper.KAC.CreateAlarm(KACWrapper.KACAPI.AlarmTypeEnum.Raw, txt, KCT_GameStates.KACAlarmUT); KCTDebug.Log("Alarm created with ID: " + KCT_GameStates.KACAlarmId); } } } else { GUILayout.Label("No Active Projects"); } GUILayout.EndHorizontal(); //Buttons for VAB/SPH lists // List<string> buttonList = new List<string> { "VAB", "SPH", "KSC" }; //if (KCT_Utilities.CurrentGameHasScience() && !KCT_GameStates.settings.InstantTechUnlock) buttonList.Add("Tech"); GUILayout.BeginHorizontal(); //if (HighLogic.LoadedScene == GameScenes.SPACECENTER) { buttonList.Add("Upgrades"); buttonList.Add("Settings"); } // int lastSelected = listWindow; // listWindow = GUILayout.Toolbar(listWindow, buttonList.ToArray()); bool VABSelectedNew = GUILayout.Toggle(VABSelected, "VAB", GUI.skin.button); bool SPHSelectedNew = GUILayout.Toggle(SPHSelected, "SPH", GUI.skin.button); bool TechSelectedNew = false; if (KCT_Utilities.CurrentGameHasScience()) TechSelectedNew = GUILayout.Toggle(TechSelected, "Tech", GUI.skin.button); if (VABSelectedNew != VABSelected) SelectList("VAB"); else if (SPHSelectedNew != SPHSelected) SelectList("SPH"); else if (TechSelectedNew != TechSelected) SelectList("Tech"); if (HighLogic.LoadedScene == GameScenes.SPACECENTER && GUILayout.Button("Upgrades")) { showUpgradeWindow = true; showBuildList = false; showBLPlus = false; } if (HighLogic.LoadedScene == GameScenes.SPACECENTER && GUILayout.Button("Settings")) { showBuildList = false; showBLPlus = false; ShowSettings(); } GUILayout.EndHorizontal(); /* if (GUI.changed) { buildListWindowPosition.height = 1; showBLPlus = false; if (lastSelected == listWindow) { listWindow = -1; } }*/ //Content of lists if (listWindow == 0) //VAB Build List { List<KCT_BuildListVessel> buildList = KCT_GameStates.ActiveKSC.VABList; GUILayout.BeginHorizontal(); // GUILayout.Space((butW + 4) * 3); GUILayout.Label("Name:"); GUILayout.Label("Progress:", GUILayout.Width(width1 / 2)); GUILayout.Label("Time Left:", GUILayout.Width(width2)); //GUILayout.Label("BP:", GUILayout.Width(width1 / 2 + 10)); GUILayout.EndHorizontal(); //if (KCT_Utilities.ReconditioningActive(null)) foreach (KCT_Recon_Rollout reconditioning in KCT_GameStates.ActiveKSC.Recon_Rollout.FindAll(r => r.RRType == KCT_Recon_Rollout.RolloutReconType.Reconditioning)) { GUILayout.BeginHorizontal(); IKCTBuildItem item = reconditioning.AsBuildItem(); if (!HighLogic.LoadedSceneIsEditor && GUILayout.Button("Warp To", GUILayout.Width((butW + 4) * 3))) { KCT_GameStates.targetedItem = item; KCT_GameStates.canWarp = true; KCT_Utilities.RampUpWarp(item); KCT_GameStates.warpInitiated = true; /*if (item.GetBuildRate() > 0) { TimeWarp.fetch.WarpTo(Planetarium.GetUniversalTime() + item.GetTimeLeft(), KCT_GameStates.settings.MaxTimeWarp, 1); }*/ } GUILayout.Label("Reconditioning: "+reconditioning.launchPadID); GUILayout.Label(reconditioning.ProgressPercent().ToString() + "%", GUILayout.Width(width1 / 2)); GUILayout.Label(MagiCore.Utilities.GetColonFormattedTime(item.GetTimeLeft()), GUILayout.Width(width2)); //GUILayout.Label(Math.Round(KCT_GameStates.ActiveKSC.GetReconditioning().BP, 2).ToString(), GUILayout.Width(width1 / 2 + 10)); //GUILayout.Space((butW + 4) * 3); GUILayout.EndHorizontal(); } scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.Height(250)); { if (buildList.Count == 0) { GUILayout.Label("No vessels under construction! Go to the VAB to build more."); } for (int i = 0; i < buildList.Count; i++) { KCT_BuildListVessel b = buildList[i]; if (!b.allPartsValid) continue; GUILayout.BeginHorizontal(); //GUILayout.Label(b.shipName, GUILayout.Width(width1)); if (!HighLogic.LoadedSceneIsEditor && GUILayout.Button("*", GUILayout.Width(butW))) { if (IDSelected == b.id) showBLPlus = !showBLPlus; else showBLPlus = true; IDSelected = b.id; } else if (HighLogic.LoadedSceneIsEditor) { //GUILayout.Space(butW); if (GUILayout.Button("X", GUILayout.Width(butW))) { InputLockManager.SetControlLock(ControlTypes.EDITOR_SOFT_LOCK, "KCTPopupLock"); IDSelected = b.id; DialogGUIBase[] options = new DialogGUIBase[2]; options[0] = new DialogGUIButton("Yes", ScrapVessel); options[1] = new DialogGUIButton("No", DummyVoid); MultiOptionDialog diag = new MultiOptionDialog("Are you sure you want to scrap this vessel?", "Scrap Vessel", null, options: options); PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), diag, false, HighLogic.UISkin); } } if (i > 0 && GUILayout.Button("^", GUILayout.Width(butW))) { buildList.RemoveAt(i); if (GameSettings.MODIFIER_KEY.GetKey()) { buildList.Insert(0, b); } else { buildList.Insert(i - 1, b); } } else if (i == 0) { // GUILayout.Space(butW + 4); } if (i < buildList.Count - 1 && GUILayout.Button("v", GUILayout.Width(butW))) { buildList.RemoveAt(i); if (GameSettings.MODIFIER_KEY.GetKey()) { buildList.Add(b); } else { buildList.Insert(i + 1, b); } } else if (i >= buildList.Count - 1) { // GUILayout.Space(butW + 4); } GUILayout.Label(b.shipName); GUILayout.Label(Math.Round(b.ProgressPercent(), 2).ToString() + "%", GUILayout.Width(width1 / 2)); if (b.buildRate > 0) GUILayout.Label(MagiCore.Utilities.GetColonFormattedTime(b.timeLeft), GUILayout.Width(width2)); else GUILayout.Label("Est: " + MagiCore.Utilities.GetColonFormattedTime((b.buildPoints - b.progress) / KCT_Utilities.GetBuildRate(0, KCT_BuildListVessel.ListType.VAB, null)), GUILayout.Width(width2)); // GUILayout.Label(Math.Round(b.buildPoints, 2).ToString(), GUILayout.Width(width1 / 2 + 10)); GUILayout.EndHorizontal(); } //ADD Storage here! buildList = KCT_GameStates.ActiveKSC.VABWarehouse; GUILayout.Label("__________________________________________________"); GUILayout.Label("VAB Storage"); if (HighLogic.LoadedSceneIsFlight && FlightGlobals.ActiveVessel != null && FlightGlobals.ActiveVessel.IsRecoverable && FlightGlobals.ActiveVessel.IsClearToSave() == ClearToSaveStatus.CLEAR && GUILayout.Button("Recover Active Vessel")) { if (!KCT_Utilities.RecoverActiveVesselToStorage(KCT_BuildListVessel.ListType.VAB)) { PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), "Error!", "There was an error while recovering the ship. Sometimes reloading the scene and trying again works. Sometimes a vessel just can't be recovered this way and you must use the stock recover system.", "OK", false, HighLogic.UISkin); } } if (buildList.Count == 0) { GUILayout.Label("No vessels in storage!\nThey will be stored here when they are complete."); } //KCT_Recon_Rollout rollback = KCT_GameStates.ActiveKSC.GetReconRollout(KCT_Recon_Rollout.RolloutReconType.Rollback); bool rolloutEnabled = KCT_PresetManager.Instance.ActivePreset.generalSettings.ReconditioningTimes && KCT_PresetManager.Instance.ActivePreset.timeSettings.RolloutReconSplit > 0; for (int i = 0; i < buildList.Count; i++) { KCT_BuildListVessel b = buildList[i]; if (!b.allPartsValid) continue; string launchSite = b.launchSite; if (launchSite == "LaunchPad") { if (b.launchSiteID >= 0) launchSite = KCT_GameStates.ActiveKSC.LaunchPads[b.launchSiteID].name; else launchSite = KCT_GameStates.ActiveKSC.ActiveLPInstance.name; } KCT_Recon_Rollout rollout = KCT_GameStates.ActiveKSC.GetReconRollout(KCT_Recon_Rollout.RolloutReconType.Rollout, launchSite); KCT_Recon_Rollout rollback = KCT_GameStates.ActiveKSC.Recon_Rollout.FirstOrDefault(r => r.associatedID == b.id.ToString() && r.RRType == KCT_Recon_Rollout.RolloutReconType.Rollback); KCT_Recon_Rollout recovery = KCT_GameStates.ActiveKSC.Recon_Rollout.FirstOrDefault(r => r.associatedID == b.id.ToString() && r.RRType == KCT_Recon_Rollout.RolloutReconType.Recovery); GUIStyle textColor = new GUIStyle(GUI.skin.label); GUIStyle buttonColor = new GUIStyle(GUI.skin.button); VesselPadStatus padStatus = VesselPadStatus.InStorage; if (rollback != null) padStatus = VesselPadStatus.RollingBack; if (recovery != null) padStatus = VesselPadStatus.Recovering; string status = "In Storage"; if (rollout != null && rollout.associatedID == b.id.ToString()) { padStatus = VesselPadStatus.RollingOut; status = "Rolling Out to "+launchSite; textColor = yellowText; if (rollout.AsBuildItem().IsComplete()) { padStatus = VesselPadStatus.RolledOut; status = "At "+launchSite; textColor = greenText; } } else if (rollback != null) { status = "Rolling Back from "+launchSite; textColor = yellowText; } else if (recovery != null) { status = "Recovering"; textColor = redText; } GUILayout.BeginHorizontal(); if (!HighLogic.LoadedSceneIsEditor && (padStatus == VesselPadStatus.InStorage || padStatus == VesselPadStatus.RolledOut)) { if (GUILayout.Button("*", GUILayout.Width(butW))) { if (IDSelected == b.id) showBLPlus = !showBLPlus; else showBLPlus = true; IDSelected = b.id; } } else GUILayout.Space(butW + 4); GUILayout.Label(b.shipName, textColor); GUILayout.Label(status+" ", textColor, GUILayout.ExpandWidth(false)); bool siteHasActiveRolloutOrRollback = rollout != null || KCT_GameStates.ActiveKSC.GetReconRollout(KCT_Recon_Rollout.RolloutReconType.Rollback, launchSite) != null; if (rolloutEnabled && !HighLogic.LoadedSceneIsEditor && recovery == null && !siteHasActiveRolloutOrRollback) //rollout if the pad isn't busy { GUIStyle btnColor = greenButton; if (KCT_GameStates.ActiveKSC.ActiveLPInstance.destroyed) btnColor = redButton; else if (KCT_GameStates.ActiveKSC.GetReconditioning(KCT_GameStates.ActiveKSC.ActiveLPInstance.name) != null) btnColor = yellowButton; KCT_Recon_Rollout tmpRollout = new KCT_Recon_Rollout(b, KCT_Recon_Rollout.RolloutReconType.Rollout, b.id.ToString(), launchSite); string rolloutText = (i == MouseOnRolloutButton ? MagiCore.Utilities.GetColonFormattedTime(tmpRollout.AsBuildItem().GetTimeLeft()) : "Rollout"); if (GUILayout.Button(rolloutText, btnColor, GUILayout.ExpandWidth(false))) { List<string> facilityChecks = b.MeetsFacilityRequirements(); if (facilityChecks.Count == 0) { if (!KCT_GameStates.ActiveKSC.ActiveLPInstance.destroyed) { b.launchSiteID = KCT_GameStates.ActiveKSC.ActiveLaunchPadID; if (rollout != null) { rollout.SwapRolloutType(); } // tmpRollout.launchPadID = KCT_GameStates.ActiveKSC.ActiveLPInstance.name; KCT_GameStates.ActiveKSC.Recon_Rollout.Add(tmpRollout); } else { PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), "Cannot Launch!", "You must repair the launchpad before you can launch a vessel from it!", "Acknowledged", false, HighLogic.UISkin); } } else { PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), "Cannot Launch!", "Warning! This vessel did not pass the editor checks! Until you upgrade the VAB and/or Launchpad it cannot be launched. Listed below are the failed checks:\n" + String.Join("\n", facilityChecks.ToArray()), "Acknowledged", false, HighLogic.UISkin); } } if (Event.current.type == EventType.Repaint) if (GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition)) MouseOnRolloutButton = i; else if (i == MouseOnRolloutButton) MouseOnRolloutButton = -1; } else if (rolloutEnabled && !HighLogic.LoadedSceneIsEditor && recovery == null && rollout != null && b.id.ToString() == rollout.associatedID && !rollout.AsBuildItem().IsComplete() && rollback == null && GUILayout.Button(MagiCore.Utilities.GetColonFormattedTime(rollout.AsBuildItem().GetTimeLeft()), GUILayout.ExpandWidth(false))) //swap rollout to rollback { rollout.SwapRolloutType(); } else if (rolloutEnabled && !HighLogic.LoadedSceneIsEditor && recovery == null && rollback != null && !rollback.AsBuildItem().IsComplete()) { if (rollout == null) { if (GUILayout.Button(MagiCore.Utilities.GetColonFormattedTime(rollback.AsBuildItem().GetTimeLeft()), GUILayout.ExpandWidth(false))) //switch rollback back to rollout rollback.SwapRolloutType(); } else { GUILayout.Label(MagiCore.Utilities.GetColonFormattedTime(rollback.AsBuildItem().GetTimeLeft()), GUILayout.ExpandWidth(false)); } } else if (HighLogic.LoadedScene != GameScenes.TRACKSTATION && recovery == null && (!rolloutEnabled || (rollout != null && b.id.ToString() == rollout.associatedID && rollout.AsBuildItem().IsComplete()))) { KCT_LaunchPad pad = KCT_GameStates.ActiveKSC.LaunchPads.Find(lp => lp.name == launchSite); bool operational = pad!=null ? !pad.destroyed : !KCT_GameStates.ActiveKSC.ActiveLPInstance.destroyed; GUIStyle btnColor = greenButton; string launchTxt = "Launch"; if (!operational) { launchTxt = "Repairs Required"; btnColor = redButton; } else if (KCT_Utilities.ReconditioningActive(null, launchSite)) { launchTxt = "Reconditioning"; btnColor = yellowButton; } if (rolloutEnabled && GameSettings.MODIFIER_KEY.GetKey() && GUILayout.Button("Roll Back", GUILayout.ExpandWidth(false))) { rollout.SwapRolloutType(); } else if (!GameSettings.MODIFIER_KEY.GetKey() && GUILayout.Button(launchTxt, btnColor, GUILayout.ExpandWidth(false))) { if (b.launchSiteID >= 0) { KCT_GameStates.ActiveKSC.SwitchLaunchPad(b.launchSiteID); } b.launchSiteID = KCT_GameStates.ActiveKSC.ActiveLaunchPadID; List<string> facilityChecks = b.MeetsFacilityRequirements(); if (facilityChecks.Count == 0) { // bool operational = !KCT_GameStates.ActiveKSC.ActiveLPInstance.destroyed;// && KCT_Utilities.LaunchFacilityIntact(KCT_BuildListVessel.ListType.VAB);//new PreFlightTests.FacilityOperational("LaunchPad", "building").Test(); if (!operational) { //ScreenMessages.PostScreenMessage("You must repair the launchpad prior to launch!", 4.0f, ScreenMessageStyle.UPPER_CENTER); PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), "Cannot Launch!", "You must repair the launchpad before you can launch a vessel from it!", "Acknowledged", false, HighLogic.UISkin); } else if (KCT_Utilities.ReconditioningActive(null, launchSite)) { //can't launch now ScreenMessage message = new ScreenMessage("[KCT] Cannot launch while LaunchPad is being reconditioned. It will be finished in " + MagiCore.Utilities.GetFormattedTime(((IKCTBuildItem)KCT_GameStates.ActiveKSC.GetReconditioning(launchSite)).GetTimeLeft()), 4.0f, ScreenMessageStyle.UPPER_CENTER); ScreenMessages.PostScreenMessage(message); } else { /*if (rollout != null) KCT_GameStates.ActiveKSC.Recon_Rollout.Remove(rollout);*/ KCT_GameStates.launchedVessel = b; if (ShipConstruction.FindVesselsLandedAt(HighLogic.CurrentGame.flightState, b.launchSite).Count == 0)// ShipConstruction.CheckLaunchSiteClear(HighLogic.CurrentGame.flightState, "LaunchPad", false)) { showBLPlus = false; // buildList.RemoveAt(i); if (!IsCrewable(b.ExtractedParts)) b.Launch(); else { showBuildList = false; if (KCT_Events.instance.KCTButtonStock != null) { KCT_Events.instance.KCTButtonStock.SetFalse(); } centralWindowPosition.height = 1; KCT_GameStates.launchedCrew.Clear(); parts = KCT_GameStates.launchedVessel.ExtractedParts; pseudoParts = KCT_GameStates.launchedVessel.GetPseudoParts(); KCT_GameStates.launchedCrew = new List<CrewedPart>(); foreach (PseudoPart pp in pseudoParts) KCT_GameStates.launchedCrew.Add(new CrewedPart(pp.uid, new List<ProtoCrewMember>())); CrewFirstAvailable(); showShipRoster = true; } } else { showBuildList = false; showClearLaunch = true; } } } else { PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), "Cannot Launch!", "Warning! This vessel did not pass the editor checks! Until you upgrade the VAB and/or Launchpad it cannot be launched. Listed below are the failed checks:\n" + String.Join("\n", facilityChecks.ToArray()), "Acknowledged", false, HighLogic.UISkin); } } } else if (!HighLogic.LoadedSceneIsEditor && recovery != null) { GUILayout.Label(MagiCore.Utilities.GetColonFormattedTime(recovery.AsBuildItem().GetTimeLeft()), GUILayout.ExpandWidth(false)); } GUILayout.EndHorizontal(); } } GUILayout.EndScrollView(); GUILayout.BeginHorizontal(); int lpCount = KCT_GameStates.ActiveKSC.LaunchPadCount; if (lpCount > 1 && GUILayout.Button("<<", GUILayout.ExpandWidth(false))) { //Simple fix for mod function being "weird" in the negative direction //http://stackoverflow.com/questions/1082917/mod-of-negative-number-is-melting-my-brain KCT_GameStates.ActiveKSC.SwitchLaunchPad(((KCT_GameStates.ActiveKSC.ActiveLaunchPadID - 1) % lpCount + lpCount) % lpCount); } GUILayout.FlexibleSpace(); GUILayout.Label("Current: " + KCT_GameStates.ActiveKSC.ActiveLPInstance.name+" ("+(KCT_GameStates.ActiveKSC.ActiveLPInstance.level+1)+")"); if (costOfNewLP == -13) costOfNewLP = KCT_MathParsing.GetStandardFormulaValue("NewLaunchPadCost", new Dictionary<string, string> { { "N", KCT_GameStates.ActiveKSC.LaunchPads.Count.ToString() } }); // if (KCT_Utilities.KSCSwitcherInstalled) //todo // costOfNewLP = -1; //disable purchasing additional launchpads when playing with KSC Switcher (until upgrades are properly per KSC) if (GUILayout.Button("Rename", GUILayout.ExpandWidth(false))) { renamingLaunchPad = true; newName = KCT_GameStates.ActiveKSC.ActiveLPInstance.name; showRename = true; showBuildList = false; showBLPlus = false; } if (costOfNewLP >= 0 && GUILayout.Button("New", GUILayout.ExpandWidth(false))) { //open dialog to unlock new costOfNewLP = KCT_MathParsing.GetStandardFormulaValue("NewLaunchPadCost", new Dictionary<string, string> { { "N", KCT_GameStates.ActiveKSC.LaunchPads.Count.ToString() } }); DialogGUIBase[] options = new DialogGUIBase[2]; options[0] = new DialogGUIButton("Yes", () => { if (!KCT_Utilities.CurrentGameIsCareer()) { KCTDebug.Log("Building new launchpad!"); KCT_GameStates.ActiveKSC.LaunchPads.Add(new KCT_LaunchPad("LaunchPad " + (KCT_GameStates.ActiveKSC.LaunchPads.Count + 1), 2)); } else if (Funding.CanAfford((float)costOfNewLP)) { KCTDebug.Log("Building new launchpad!"); //take the funds KCT_Utilities.SpendFunds(costOfNewLP, TransactionReasons.StructureConstruction); //create new launchpad at level -1 KCT_GameStates.ActiveKSC.LaunchPads.Add(new KCT_LaunchPad("LaunchPad " + (KCT_GameStates.ActiveKSC.LaunchPads.Count + 1), -1)); //create new upgradeable KCT_UpgradingBuilding newPad = new KCT_UpgradingBuilding();//(null, 0, -1, "LaunchPad"); newPad.id = "SpaceCenter/LaunchPad"; newPad.isLaunchpad = true; newPad.launchpadID = KCT_GameStates.ActiveKSC.LaunchPads.Count-1; newPad.upgradeLevel = 0; newPad.currentLevel = -1; newPad.cost = costOfNewLP; newPad.SetBP(costOfNewLP); newPad.commonName = "LaunchPad " + (KCT_GameStates.ActiveKSC.LaunchPads.Count); KCT_GameStates.ActiveKSC.KSCTech.Add(newPad); } costOfNewLP = -13; }); options[1] = new DialogGUIButton("No", DummyVoid); MultiOptionDialog diag = new MultiOptionDialog("It will cost " + Math.Round(costOfNewLP, 2).ToString("N") + " funds to build a new launchpad. Would you like to build it?", "Build LaunchPad", null, 300, options); PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), diag, false, HighLogic.UISkin); } GUILayout.FlexibleSpace(); if (lpCount > 1 && GUILayout.Button(">>", GUILayout.ExpandWidth(false))) { KCT_GameStates.ActiveKSC.SwitchLaunchPad((KCT_GameStates.ActiveKSC.ActiveLaunchPadID + 1) % KCT_GameStates.ActiveKSC.LaunchPadCount); } GUILayout.EndHorizontal(); } else if (listWindow == 1) //SPH Build List { List<KCT_BuildListVessel> buildList = KCT_GameStates.ActiveKSC.SPHList; GUILayout.BeginHorizontal(); // GUILayout.Space((butW + 4) * 3); GUILayout.Label("Name:"); GUILayout.Label("Progress:", GUILayout.Width(width1 / 2)); GUILayout.Label("Time Left:", GUILayout.Width(width2)); //GUILayout.Label("BP:", GUILayout.Width(width1 / 2 + 10)); GUILayout.EndHorizontal(); scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.Height(250)); { if (buildList.Count == 0) { GUILayout.Label("No vessels under construction! Go to the SPH to build more."); } for (int i = 0; i < buildList.Count; i++) { KCT_BuildListVessel b = buildList[i]; if (!b.allPartsValid) continue; GUILayout.BeginHorizontal(); if (!HighLogic.LoadedSceneIsEditor && GUILayout.Button("*", GUILayout.Width(butW))) { if (IDSelected == b.id) showBLPlus = !showBLPlus; else showBLPlus = true; IDSelected = b.id; } else if (HighLogic.LoadedSceneIsEditor) { //GUILayout.Space(butW); if (GUILayout.Button("X", GUILayout.Width(butW))) { InputLockManager.SetControlLock(ControlTypes.EDITOR_SOFT_LOCK, "KCTPopupLock"); IDSelected = b.id; DialogGUIBase[] options = new DialogGUIBase[2]; options[0] = new DialogGUIButton("Yes", ScrapVessel); options[1] = new DialogGUIButton("No", DummyVoid); MultiOptionDialog diag = new MultiOptionDialog("Are you sure you want to scrap " + b.shipName + "?", "Scrap Vessel", null, 300, options); PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), diag, false, HighLogic.UISkin); } } if (i > 0 && GUILayout.Button("^", GUILayout.Width(butW))) { buildList.RemoveAt(i); if (GameSettings.MODIFIER_KEY.GetKey()) { buildList.Insert(0, b); } else { buildList.Insert(i - 1, b); } } else if (i == 0) { // GUILayout.Space(butW + 4); } if (i < buildList.Count - 1 && GUILayout.Button("v", GUILayout.Width(butW))) { buildList.RemoveAt(i); if (GameSettings.MODIFIER_KEY.GetKey()) { buildList.Add(b); } else { buildList.Insert(i + 1, b); } } else if (i >= buildList.Count - 1) { // GUILayout.Space(butW + 4); } GUILayout.Label(b.shipName); GUILayout.Label(Math.Round(b.ProgressPercent(), 2).ToString() + "%", GUILayout.Width(width1 / 2)); if (b.buildRate > 0) GUILayout.Label(MagiCore.Utilities.GetColonFormattedTime(b.timeLeft), GUILayout.Width(width2)); else GUILayout.Label("Est: " + MagiCore.Utilities.GetColonFormattedTime((b.buildPoints - b.progress) / KCT_Utilities.GetBuildRate(0, KCT_BuildListVessel.ListType.SPH, null)), GUILayout.Width(width2)); //GUILayout.Label(Math.Round(b.buildPoints, 2).ToString(), GUILayout.Width(width1 / 2 + 10)); GUILayout.EndHorizontal(); } buildList = KCT_GameStates.ActiveKSC.SPHWarehouse; GUILayout.Label("__________________________________________________"); GUILayout.Label("SPH Storage"); if (HighLogic.LoadedSceneIsFlight && FlightGlobals.ActiveVessel != null && FlightGlobals.ActiveVessel.IsRecoverable && FlightGlobals.ActiveVessel.IsClearToSave() == ClearToSaveStatus.CLEAR && GUILayout.Button("Recover Active Vessel")) { if (!KCT_Utilities.RecoverActiveVesselToStorage(KCT_BuildListVessel.ListType.SPH)) { PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), "Error!", "There was an error while recovering the ship. Sometimes reloading the scene and trying again works. Sometimes a vessel just can't be recovered this way and you must use the stock recover system.", "OK", false, HighLogic.UISkin); } } for (int i = 0; i < buildList.Count; i++) { KCT_BuildListVessel b = buildList[i]; if (!b.allPartsValid) continue; string status = ""; KCT_Recon_Rollout recovery = KCT_GameStates.ActiveKSC.Recon_Rollout.FirstOrDefault(r => r.associatedID == b.id.ToString() && r.RRType == KCT_Recon_Rollout.RolloutReconType.Recovery); if (recovery != null) status = "Recovering"; GUILayout.BeginHorizontal(); if (!HighLogic.LoadedSceneIsEditor && status == "") { if (GUILayout.Button("*", GUILayout.Width(butW))) { if (IDSelected == b.id) showBLPlus = !showBLPlus; else showBLPlus = true; IDSelected = b.id; } } else GUILayout.Space(butW + 4); GUILayout.Label(b.shipName); GUILayout.Label(status + " ", GUILayout.ExpandWidth(false)); //ScenarioDestructibles.protoDestructibles["KSCRunway"]. if (HighLogic.LoadedScene != GameScenes.TRACKSTATION && recovery == null && GUILayout.Button("Launch", GUILayout.ExpandWidth(false))) { List<string> facilityChecks = b.MeetsFacilityRequirements(); if (facilityChecks.Count == 0) { bool operational = KCT_Utilities.LaunchFacilityIntact(KCT_BuildListVessel.ListType.SPH);//new PreFlightTests.FacilityOperational("Runway", "building").Test(); if (!operational) { ScreenMessages.PostScreenMessage("You must repair the runway prior to launch!", 4.0f, ScreenMessageStyle.UPPER_CENTER); } else { showBLPlus = false; KCT_GameStates.launchedVessel = b; if (ShipConstruction.FindVesselsLandedAt(HighLogic.CurrentGame.flightState, "Runway").Count == 0) { if (!IsCrewable(b.ExtractedParts)) b.Launch(); else { showBuildList = false; if (KCT_Events.instance.KCTButtonStock != null) { KCT_Events.instance.KCTButtonStock.SetFalse(); } centralWindowPosition.height = 1; KCT_GameStates.launchedCrew.Clear(); parts = KCT_GameStates.launchedVessel.ExtractedParts; pseudoParts = KCT_GameStates.launchedVessel.GetPseudoParts(); KCT_GameStates.launchedCrew = new List<CrewedPart>(); foreach (PseudoPart pp in pseudoParts) KCT_GameStates.launchedCrew.Add(new CrewedPart(pp.uid, new List<ProtoCrewMember>())); CrewFirstAvailable(); showShipRoster = true; } } else { showBuildList = false; showClearLaunch = true; } } } else { PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), "Cannot Launch!", "Warning! This vessel did not pass the editor checks! Until you upgrade the SPH and/or Runway it cannot be launched. Listed below are the failed checks:\n" + String.Join("\n", facilityChecks.ToArray()), "Acknowledged", false, HighLogic.UISkin); } } else if (recovery != null) { GUILayout.Label(MagiCore.Utilities.GetColonFormattedTime(recovery.AsBuildItem().GetTimeLeft()), GUILayout.ExpandWidth(false)); } GUILayout.EndHorizontal(); } if (buildList.Count == 0) { GUILayout.Label("No vessels in storage!\nThey will be stored here when they are complete."); } } GUILayout.EndScrollView(); } else if (listWindow == 2) //Tech nodes { List<KCT_UpgradingBuilding> KSCList = KCT_GameStates.ActiveKSC.KSCTech; List<KCT_TechItem> techList = KCT_GameStates.TechList; //GUILayout.Label("Tech Node Research"); GUILayout.BeginHorizontal(); GUILayout.Label("Name:"); GUILayout.Label("Progress:", GUILayout.Width(width1/2)); GUILayout.Label("Time Left:", GUILayout.Width(width1)); GUILayout.Space(70); GUILayout.EndHorizontal(); scrollPos = GUILayout.BeginScrollView(scrollPos, GUILayout.Height(250)); if (KCT_Utilities.CurrentGameIsCareer()) { if (KSCList.Count == 0) GUILayout.Label("No KSC upgrade projects are currently underway."); foreach (KCT_UpgradingBuilding KCTTech in KSCList) { GUILayout.BeginHorizontal(); /* int i = KSCList.IndexOf(KCTTech); if (i > 0 && GUILayout.Button("^", GUILayout.Width(butW))) { KSCList.RemoveAt(i); if (GameSettings.MODIFIER_KEY.GetKey()) { KSCList.Insert(0, KCTTech); } else { KSCList.Insert(i - 1, KCTTech); } } if (i < KSCList.Count - 1 && GUILayout.Button("v", GUILayout.Width(butW))) { KSCList.RemoveAt(i); if (GameSettings.MODIFIER_KEY.GetKey()) { KSCList.Add(KCTTech); } else { KSCList.Insert(i + 1, KCTTech); } } */ GUILayout.Label(KCTTech.AsIKCTBuildItem().GetItemName()); GUILayout.Label(Math.Round(100 * KCTTech.progress / KCTTech.BP, 2) + " %", GUILayout.Width(width1 / 2)); GUILayout.Label(MagiCore.Utilities.GetColonFormattedTime(KCTTech.AsIKCTBuildItem().GetTimeLeft()), GUILayout.Width(width1)); if (!HighLogic.LoadedSceneIsEditor && GUILayout.Button("Warp To", GUILayout.Width(70))) { KCT_GameStates.targetedItem = KCTTech; KCT_GameStates.canWarp = true; KCT_Utilities.RampUpWarp(KCTTech); KCT_GameStates.warpInitiated = true; /*if (KCTTech.AsIKCTBuildItem().GetBuildRate() > 0) { TimeWarp.fetch.WarpTo(Planetarium.GetUniversalTime() + KCTTech.AsIKCTBuildItem().GetTimeLeft(), KCT_GameStates.settings.MaxTimeWarp, 1); }*/ } else if (HighLogic.LoadedSceneIsEditor) GUILayout.Space(70); GUILayout.EndHorizontal(); } } if (techList.Count == 0) GUILayout.Label("No tech nodes are being researched!\nBegin research by unlocking tech in the R&D building."); bool forceRecheck = false; int cancelID = -1; for (int i = 0; i < techList.Count; i++) { KCT_TechItem t = techList[i]; GUILayout.BeginHorizontal(); if (GUILayout.Button("X", GUILayout.Width(butW))) { forceRecheck = true; cancelID = i; DialogGUIBase[] options = new DialogGUIBase[2]; options[0] = new DialogGUIButton("Yes", () => { CancelTechNode(cancelID); }); options[1] = new DialogGUIButton("No", DummyVoid); MultiOptionDialog diag = new MultiOptionDialog("Are you sure you want to stop researching "+t.techName+"?", "Cancel Node?", null, 300, options); PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), diag, false, HighLogic.UISkin); /*if (CancelTechNode(i)) { i--; GUILayout.EndHorizontal(); continue; }*/ } if (i > 0 && t.BuildRate != techList[0].BuildRate) { if (i > 0 && GUILayout.Button("^", GUILayout.Width(butW))) { techList.RemoveAt(i); if (GameSettings.MODIFIER_KEY.GetKey()) { techList.Insert(0, t); } else { techList.Insert(i - 1, t); } forceRecheck = true; } } if ((i == 0 && t.BuildRate != techList[techList.Count - 1].BuildRate) || t.BuildRate != techList[techList.Count - 1].BuildRate) { if (i < techList.Count - 1 && GUILayout.Button("v", GUILayout.Width(butW))) { techList.RemoveAt(i); if (GameSettings.MODIFIER_KEY.GetKey()) { techList.Add(t); } else { techList.Insert(i + 1, t); } forceRecheck = true; } } if (forceRecheck) { forceRecheck = false; for (int j=0; j<techList.Count; j++) techList[j].UpdateBuildRate(j); } GUILayout.Label(t.techName); GUILayout.Label(Math.Round(100 * t.progress / t.scienceCost, 2) + " %", GUILayout.Width(width1/2)); if (t.BuildRate > 0) GUILayout.Label(MagiCore.Utilities.GetColonFormattedTime(t.TimeLeft), GUILayout.Width(width1)); else GUILayout.Label("Est: " + MagiCore.Utilities.GetColonFormattedTime(t.EstimatedTimeLeft), GUILayout.Width(width1)); if (t.BuildRate > 0) { if (!HighLogic.LoadedSceneIsEditor && GUILayout.Button("Warp", GUILayout.Width(45))) { KCT_GameStates.targetedItem = t; KCT_GameStates.canWarp = true; KCT_Utilities.RampUpWarp(t); KCT_GameStates.warpInitiated = true; } else if (HighLogic.LoadedSceneIsEditor) GUILayout.Space(45); } else GUILayout.Space(45); GUILayout.EndHorizontal(); } GUILayout.EndScrollView(); } if (KCT_UpdateChecker.UpdateFound) { GUILayout.BeginHorizontal(); GUILayout.Label("Current Version: " + KCT_UpdateChecker.CurrentVersion); GUILayout.Label("Latest: " + KCT_UpdateChecker.WebVersion); GUILayout.EndHorizontal(); } GUILayout.EndVertical(); // if (ToolbarManager.ToolbarAvailable && ToolbarManager.Instance != null && KCT_GameStates.settings.PreferBlizzyToolbar) if (!Input.GetMouseButtonDown(1) && !Input.GetMouseButtonDown(2)) GUI.DragWindow(); }
public static void DelayedStart() { // KCTDebug.Log(ScenarioUpgradeableFacilities.protoUpgradeables.Keys); // KCTDebug.Log(ScenarioUpgradeableFacilities.protoUpgradeables.Values.ElementAt(0).facilityRefs[0].name); if (!updateChecked) { if (KCT_GameStates.settings.CheckForUpdates && !KCT_GameStates.firstStart) //Check for updates { KCT_UpdateChecker.CheckForUpdate(false, KCT_GameStates.settings.VersionSpecific); } updateChecked = true; } if (!KCT_GameStates.settings.enabledForSave) { return; } List <GameScenes> validScenes = new List <GameScenes> { GameScenes.SPACECENTER }; if (validScenes.Contains(HighLogic.LoadedScene)) { //Check for simulation save and load it. string backupFile = KSPUtil.ApplicationRootPath + "saves/" + HighLogic.SaveFolder + "/KCT_simulation_backup.sfs"; if (System.IO.File.Exists(backupFile)) { KCT_GameStates.LoadingSimulationSave = true; /* if (!KCT_GameStates.LoadingSimulationSave) * KCT_Utilities.LoadSimulationSave(); * else * System.IO.File.Delete(backupFile);*/ } } if (HighLogic.LoadedSceneIsFlight && KCT_GameStates.flightSimulated) { KCTDebug.Log("Simulation started"); KCT_GUI.hideAll(); KCT_GUI.showSimulationWindow = !KCT_GameStates.settings.NoSimGUI; KCT_GUI.showTimeRemaining = true; Planetarium.SetUniversalTime(KCT_GameStates.simulationUT); } if (!HighLogic.LoadedSceneIsFlight && KCT_GameStates.FundsToChargeAtSimEnd != 0) { KCT_Utilities.SpendFunds(KCT_GameStates.FundsToChargeAtSimEnd, TransactionReasons.None); KCT_GameStates.FundsToChargeAtSimEnd = 0; } if (!HighLogic.LoadedSceneIsFlight && KCT_GameStates.FundsGivenForVessel != 0) { KCT_Utilities.SpendFunds(KCT_GameStates.FundsGivenForVessel, TransactionReasons.VesselRollout); KCT_GameStates.FundsGivenForVessel = 0; } if (HighLogic.LoadedSceneIsFlight && !KCT_GameStates.flightSimulated) { List <VesselType> invalidTypes = new List <VesselType> { VesselType.Debris, VesselType.SpaceObject, VesselType.Unknown }; if (!invalidTypes.Contains(FlightGlobals.ActiveVessel.vesselType) && !KCT_GameStates.BodiesVisited.Contains(FlightGlobals.ActiveVessel.mainBody.bodyName)) { KCT_GameStates.BodiesVisited.Add(FlightGlobals.ActiveVessel.mainBody.bodyName); var message = new ScreenMessage("[KCT] New simulation body unlocked: " + FlightGlobals.ActiveVessel.mainBody.bodyName, 4.0f, ScreenMessageStyle.UPPER_LEFT); ScreenMessages.PostScreenMessage(message, true); KCTDebug.Log("Unlocked sim body: " + FlightGlobals.ActiveVessel.mainBody.bodyName); } } if (KCT_GUI.PrimarilyDisabled) { return; } //The following should only be executed when fully enabled for the save foreach (KCT_KSC KSC in KCT_GameStates.KSCs) { KSC.RecalculateBuildRates(); KSC.RecalculateUpgradedBuildRates(); } if (!HighLogic.LoadedSceneIsFlight && KCT_GameStates.buildSimulatedVessel) { KCT_GameStates.buildSimulatedVessel = false; KCT_BuildListVessel toBuild = KCT_GameStates.launchedVessel.NewCopy(false); toBuild.buildPoints = KCT_Utilities.GetBuildTime(toBuild.ExtractedPartNodes, true, KCT_GUI.useInventory); KCT_Utilities.AddVesselToBuildList(toBuild, KCT_GUI.useInventory); } if (HighLogic.LoadedSceneIsFlight && !KCT_GameStates.flightSimulated) { KCT_GUI.hideAll(); if (FlightGlobals.ActiveVessel.situation == Vessel.Situations.PRELAUNCH && KCT_GameStates.launchedVessel != null) { bool removed = KCT_GameStates.launchedVessel.RemoveFromBuildList(); if (removed) //Only do these when the vessel is first removed from the list { //Add the cost of the ship to the funds so it can be removed again by KSP //KCT_Utilities.AddFunds(KCT_Utilities.GetTotalVesselCost(FlightGlobals.ActiveVessel.protoVessel), TransactionReasons.VesselRollout); KCT_Utilities.AddFunds(KCT_GameStates.launchedVessel.cost, TransactionReasons.VesselRollout); FlightGlobals.ActiveVessel.vesselName = KCT_GameStates.launchedVessel.shipName; } KCT_Recon_Rollout rollout = KCT_GameStates.ActiveKSC.Recon_Rollout.FirstOrDefault(r => r.associatedID == KCT_GameStates.launchedVessel.id.ToString()); if (rollout != null) { KCT_GameStates.ActiveKSC.Recon_Rollout.Remove(rollout); } } } if (HighLogic.LoadedSceneIsEditor) { if (KCT_GameStates.EditorShipEditingMode) { KCTDebug.Log("Editing " + KCT_GameStates.editedVessel.shipName); EditorLogic.fetch.shipNameField.Text = KCT_GameStates.editedVessel.shipName; } if (!KCT_GUI.PrimarilyDisabled) { if (KCT_GameStates.settings.OverrideLaunchButton) { KCTDebug.Log("Taking control of launch button"); EditorLogic.fetch.launchBtn.methodToInvoke = "ShowLaunchAlert"; EditorLogic.fetch.launchBtn.scriptWithMethodToInvoke = KerbalConstructionTime.instance; } else { InputLockManager.SetControlLock(ControlTypes.EDITOR_LAUNCH, "KCTLaunchLock"); } KCT_Utilities.RecalculateEditorBuildTime(EditorLogic.fetch.ship); } } if (HighLogic.LoadedScene == GameScenes.SPACECENTER) { if (KCT_Utilities.CurrentGameHasScience() && KCT_GameStates.TotalUpgradePoints == 0) { ConfigNode CN = new ConfigNode(); ResearchAndDevelopment.Instance.snapshot.Save(CN); ConfigNode[] techNodes = CN.GetNodes("Tech"); KCTDebug.Log("technodes length: " + techNodes.Length); KCT_GameStates.TotalUpgradePoints = techNodes.Length + 14; } if (!KCT_GUI.PrimarilyDisabled) { KCT_GUI.showBuildList = KCT_GameStates.showWindows[0]; KCT_GUI.ResetBLWindow(); } else { KCT_GUI.showBuildList = false; KCT_GameStates.showWindows[0] = false; } if (KCT_GameStates.firstStart) { KCTDebug.Log("Showing first start."); KCT_GUI.showFirstRun = true; } KCT_GameStates.firstStart = false; if (KCT_GameStates.LaunchFromTS) { KCT_GameStates.launchedVessel.Launch(); } } }