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 DelayedStart() { if (Utilities.CurrentGameIsMission()) { return; } KCTDebug.Log("DelayedStart start"); if (PresetManager.Instance?.ActivePreset == null || !PresetManager.Instance.ActivePreset.GeneralSettings.Enabled) { return; } if (KCT_GUI.IsPrimarilyDisabled) { return; } //The following should only be executed when fully enabled for the save if (KCTGameStates.ActiveKSC == null) { 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 (!KCTGameStates.VesselErrorAlerted) { var erroredVessels = new List <BuildListVessel>(); foreach (KSCItem KSC in KCTGameStates.KSCs) //this is faster on subsequent scene changes { foreach (BuildListVessel blv in KSC.VABList) { if (!blv.AllPartsValid) { KCTDebug.Log(blv.ShipName + " contains invalid parts!"); erroredVessels.Add(blv); } } foreach (BuildListVessel blv in KSC.VABWarehouse) { if (!blv.AllPartsValid) { KCTDebug.Log(blv.ShipName + " contains invalid parts!"); erroredVessels.Add(blv); } } foreach (BuildListVessel blv in KSC.SPHList) { if (!blv.AllPartsValid) { KCTDebug.Log(blv.ShipName + " contains invalid parts!"); erroredVessels.Add(blv); } } foreach (BuildListVessel blv in KSC.SPHWarehouse) { if (!blv.AllPartsValid) { KCTDebug.Log(blv.ShipName + " contains invalid parts!"); erroredVessels.Add(blv); } } } if (erroredVessels.Count > 0) { PopUpVesselError(erroredVessels); } KCTGameStates.VesselErrorAlerted = true; } if (HighLogic.LoadedSceneIsEditor && KCTGameStates.EditorShipEditingMode) { KCTDebug.Log($"Editing {KCTGameStates.EditedVessel.ShipName}"); EditorLogic.fetch.shipNameField.text = KCTGameStates.EditedVessel.ShipName; } if (HighLogic.LoadedScene == GameScenes.SPACECENTER) { KCTDebug.Log("SP Start"); if (!KCT_GUI.IsPrimarilyDisabled) { if (ToolbarManager.ToolbarAvailable && KCTGameStates.Settings.PreferBlizzyToolbar) { if (KCTGameStates.ShowWindows[0]) { KCT_GUI.ToggleVisibility(true); } else { if (KCTEvents.Instance != null && KCTGameStates.ToolbarControl != null) { if (KCTGameStates.ShowWindows[0]) { KCT_GUI.ToggleVisibility(true); } } } } KCT_GUI.ResetBLWindow(); } else { KCT_GUI.GUIStates.ShowBuildList = false; KCTGameStates.ShowWindows[0] = false; } KCTDebug.Log("SP UI done"); if (KCTGameStates.IsFirstStart) { KCTDebug.Log("Showing first start."); KCTGameStates.IsFirstStart = false; KCT_GUI.GUIStates.ShowFirstRun = true; //initialize the proper launchpad KCTGameStates.ActiveKSC.ActiveLPInstance.level = Utilities.GetBuildingUpgradeLevel(SpaceCenterFacility.LaunchPad); } KCTDebug.Log("SP switch starting"); KCTGameStates.ActiveKSC.SwitchLaunchPad(KCTGameStates.ActiveKSC.ActiveLaunchPadID); KCTDebug.Log("SP switch done"); foreach (KSCItem ksc in KCTGameStates.KSCs) { for (int i = 0; i < ksc.Recon_Rollout.Count; i++) { ReconRollout rr = ksc.Recon_Rollout[i]; if (rr.RRType != ReconRollout.RolloutReconType.Reconditioning && 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++) { AirlaunchPrep ap = ksc.AirlaunchPrep[i]; if (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"); } if (HighLogic.LoadedSceneIsFlight && KCTGameStates.IsSimulatedFlight) { Utilities.EnableSimulationLocks(); if (KCTGameStates.SimulationParams.SimulationUT > 0 && FlightDriver.CanRevertToPrelaunch) // Used for checking whether the player has saved and then loaded back into that save { KCTDebug.Log($"Setting simulation UT to {KCTGameStates.SimulationParams.SimulationUT}"); Planetarium.SetUniversalTime(KCTGameStates.SimulationParams.SimulationUT); } AddSimulationWatermark(); } if (KCTGameStates.IsSimulatedFlight && HighLogic.LoadedSceneIsGame && !HighLogic.LoadedSceneIsFlight) { string msg = "Current save appears to be a simulation with no way to automatically revert to the pre-simulation state. An older save needs to be loaded manually now."; PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), "errorPopup", "KCT Simulation error", msg, "Understood", false, HighLogic.UISkin); } KCTDebug.Log("DelayedStart finished"); }
public static void DelayedStart() { const string logBlockName = nameof(KerbalConstructionTime) + "." + nameof(DelayedStart); using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All)) { if (KCT_Utilities.CurrentGameIsMission()) { return; } Log.Trace("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 (GameStates.ActiveKSC == null) { KCT_Utilities.SetActiveKSCToRSS(); } CheckVesselsForMissingParts(); if (HighLogic.LoadedSceneIsEditor) { if (GameStates.EditorShipEditingMode) { Log.Trace("Editing " + GameStates.editedVessel.shipName); EditorLogic.fetch.shipNameField.text = GameStates.editedVessel.shipName; } } if (HighLogic.LoadedScene == GameScenes.SPACECENTER) { Log.Trace("SP Start"); if (!KCT_GUI.PrimarilyDisabled) { if (ToolbarManager.ToolbarAvailable && GameStates.settings.PreferBlizzyToolbar) { if (GameStates.showWindows[0]) { KCT_GUI.ClickOn(); } else { if (KCTEvents.instance != null && KCTEvents.instance.KCTButtonStock != null) { if (GameStates.showWindows[0]) { KCT_GUI.ClickOn(); } } } } KCT_GUI.ResetBLWindow(); } else { KCT_GUI.showBuildList = false; GameStates.showWindows[0] = false; } Log.Trace("SP UI done"); if (GameStates.firstStart) { Log.Trace("Showing first start."); GameStates.firstStart = false; KCT_GUI.showFirstRun = true; //initialize the proper launchpad GameStates.ActiveKSC.ActiveLPInstance.level = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.LaunchPad); } Log.Trace("SP switch starting"); GameStates.ActiveKSC.SwitchLaunchPad(GameStates.ActiveKSC.ActiveLaunchPadID); Log.Trace("SP switch done"); foreach (SpaceCenterConstruction ksc in GameStates.KSCs) { //foreach (KCT_Recon_Rollout rr in ksc.Recon_Rollout) for (int i = 0; i < ksc.Recon_Rollout.Count; i++) { Recon_Rollout rr = ksc.Recon_Rollout[i]; if (rr.RRType != Recon_Rollout.RolloutReconType.Reconditioning && KCT_Utilities.FindBLVesselByID(new Guid(rr.associatedID)) == null) { Log.Trace("Invalid Recon_Rollout at " + ksc.KSCName + ". ID " + rr.associatedID + " not found."); ksc.Recon_Rollout.Remove(rr); i--; } } } Log.Trace("SP done"); } } }
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 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(); } } }