예제 #1
0
파일: KCTEvents.cs 프로젝트: ntwest/KCT
        public void TechDisableEventFinal(bool save = false)
        {
            const string logBlockName = nameof(KCTEvents) + "." + nameof(TechDisableEventFinal);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                if (KCT_PresetManager.Instance != null && KCT_PresetManager.Instance.ActivePreset != null)
                {
                    if (KCT_PresetManager.Instance.ActivePreset.generalSettings.TechUnlockTimes && KCT_PresetManager.Instance.ActivePreset.generalSettings.BuildTimes)
                    {
                        foreach (KCT_TechItem tech in GameStates.TechList)
                        {
                            /* foreach (String partName in tech.UnlockedParts)
                             * {
                             *   AvailablePart expt = KCT_Utilities.GetAvailablePartByName(partName);
                             *   if (expt != null && ResearchAndDevelopment.IsExperimentalPart(expt))
                             *       if (!KCT_GameStates.ExperimentalParts.Contains(expt))
                             *           KCT_GameStates.ExperimentalParts.Add(expt);
                             * }*/
                            //ResearchAndDevelopment.AddExperimentalPart()
                            tech.DisableTech();
                        }

                        /*    foreach (AvailablePart expt in KCT_GameStates.ExperimentalParts)
                         *      ResearchAndDevelopment.AddExperimentalPart(expt);*/
                        //Need to somehow update the R&D instance
                        if (save)
                        {
                            GamePersistence.SaveGame("persistent", HighLogic.SaveFolder, SaveMode.OVERWRITE);
                        }
                    }
                }
            }
        }
예제 #2
0
파일: KSC.cs 프로젝트: ntwest/KCT
        public SpaceCenterConstruction(string name)
        {
            const string logBlockName = nameof(SpaceCenterConstruction) + "..ctor";

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                var sls  = PSystemSetup.Instance.StockLaunchSites.ToList();
                var nsls = PSystemSetup.Instance.NonStockLaunchSites.ToList();

                sls.ForEach(x =>
                {
                    Log.Info("Looking at Stock Launch Sites");
                    Log.Info(x.name);
                    Log.Info(x.launchSiteName);
                    Log.Info(x.nodeType.ToString());
                    Log.Info(x.pqsName);
                });
                nsls.ForEach(x =>
                {
                    Log.Info("Looking at NonStock Launch Sites");
                    Log.Info(x.name);
                    Log.Info(x.launchSiteName);
                    Log.Info(x.nodeType.ToString());
                    Log.Info(x.pqsName);
                });


                KSCName = name;
                //We propogate the tech list and upgrades throughout each KSC, since it doesn't make sense for each one to have its own tech.
                RDUpgrades[1] = GameStates.TechUpgradesTotal;
                //TechList = KCT_GameStates.ActiveKSC.TechList;
                LaunchPads.Add(new LaunchPad("LaunchPad", KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.LaunchPad)));
            }
        }
예제 #3
0
파일: GameStates.cs 프로젝트: ntwest/KCT
        public static void reset()
        {
            const string logBlockName = nameof(GameStates) + "." + nameof(reset);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                firstStart         = false;
                vesselErrorAlerted = false;

                PurchasedUpgrades = new List <int>()
                {
                    0, 0
                };
                targetedItem = null;
                KCT_GUI.ResetFormulaRateHolders();

                InventorySaleUpgrades = 0;
                InventorySalesFigures = 0;

                ExperimentalParts.Clear();
                MiscellaneousTempUpgrades = 0;

                BuildingMaxLevelCache.Clear();

                lastUT = 0;
            }
        }
예제 #4
0
파일: KCTEvents.cs 프로젝트: ntwest/KCT
        public void OnGUIAppLauncherReady()
        {
            const string logBlockName = nameof(KCTEvents) + "." + nameof(OnGUIAppLauncherReady);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                bool vis;
                if (ToolbarManager.ToolbarAvailable && GameStates.settings.PreferBlizzyToolbar)
                {
                    return;
                }

                if (ApplicationLauncher.Ready && (KCTButtonStock == null || !ApplicationLauncher.Instance.Contains(KCTButtonStock, out vis)))   //Add Stock button
                {
                    string texturePath = PluginAssemblyUtilities.iconKCTOn;
                    KCTEvents.instance.KCTButtonStock = ApplicationLauncher.Instance.AddModApplication(
                        KCT_GUI.ClickOn,
                        KCT_GUI.ClickOff,
                        KCT_GUI.onHoverOn,
                        KCT_GUI.onHoverOff,
                        KCTEvents.instance.DummyVoid,
                        KCTEvents.instance.DummyVoid,
                        ApplicationLauncher.AppScenes.FLIGHT | ApplicationLauncher.AppScenes.MAPVIEW | ApplicationLauncher.AppScenes.SPACECENTER | ApplicationLauncher.AppScenes.SPH | ApplicationLauncher.AppScenes.TRACKSTATION | ApplicationLauncher.AppScenes.VAB,
                        GameDatabase.Instance.GetTexture(texturePath, false));

                    ApplicationLauncher.Instance.EnableMutuallyExclusive(KCTEvents.instance.KCTButtonStock);

                    /*  if (HighLogic.LoadedScene == GameScenes.SPACECENTER && KCT_GameStates.showWindows[0])
                     * {
                     *    KCTButtonStock.SetTrue(true);
                     *    KCT_GUI.clicked = true;
                     * }*/
                }
            }
        }
예제 #5
0
파일: KSC.cs 프로젝트: ntwest/KCT
        public void SwitchLaunchPad(int LP_ID, bool updateDestrNode = true)
        {
            const string logBlockName = nameof(SpaceCenterConstruction) + "." + nameof(SwitchLaunchPad);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                Log.Trace("LP_ID = ".MemoizedConcat(LP_ID.MemoizedToString()));
                Log.Trace("updateDestrNode = ".MemoizedConcat(updateDestrNode.MemoizedToString()));

                //set the active LP's new state
                //activate new pad

                //LaunchPads[ActiveLaunchPadID].level = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.LaunchPad);
                //LaunchPads[ActiveLaunchPadID].destroyed = !KCT_Utilities.LaunchFacilityIntact(KCT_BuildListVessel.ListType.VAB); //Might want to remove this as well
                if (updateDestrNode)
                {
                    ActiveLPInstance.RefreshDestructionNode();
                }

                if (LaunchPads.Count <= LP_ID)
                {
                    Log.Error("LaunchPads List is Missing LaunchPad ID ".MemoizedConcat(LP_ID.MemoizedToString()));
                    return;
                }

                LaunchPads[LP_ID].SetActive();
            }
        }
예제 #6
0
파일: KCTEvents.cs 프로젝트: ntwest/KCT
        public void vesselSituationChange(GameEvents.HostedFromToAction <Vessel, Vessel.Situations> ev)
        {
            const string logBlockName = nameof(KCTEvents) + "." + nameof(vesselSituationChange);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                if (ev.from == Vessel.Situations.PRELAUNCH && ev.host == FlightGlobals.ActiveVessel)
                {
                    if (KCT_PresetManager.Instance.ActivePreset.generalSettings.Enabled &&
                        KCT_PresetManager.Instance.ActivePreset.generalSettings.ReconditioningTimes)
                    {
                        //KCT_Recon_Rollout reconditioning = KCT_GameStates.ActiveKSC.Recon_Rollout.FirstOrDefault(r => ((IKCTBuildItem)r).GetItemName() == "LaunchPad Reconditioning");
                        //if (reconditioning == null)
                        if (HighLogic.CurrentGame.editorFacility == EditorFacility.VAB)
                        {
                            string launchSite = FlightDriver.LaunchSiteName;
                            if (launchSite == "LaunchPad")
                            {
                                launchSite = GameStates.ActiveKSC.ActiveLPInstance.name;
                            }
                            GameStates.ActiveKSC.Recon_Rollout.Add(new Recon_Rollout(ev.host, Recon_Rollout.RolloutReconType.Reconditioning, ev.host.id.ToString(), launchSite));
                        }
                    }
                }
            }
        }
예제 #7
0
파일: KSC.cs 프로젝트: ntwest/KCT
        public Recon_Rollout GetReconditioning(string launchSite = "LaunchPad")
        {
            const string logBlockName = nameof(SpaceCenterConstruction) + "." + nameof(GetReconditioning);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                return(Recon_Rollout.FirstOrDefault(r => r.launchPadID == launchSite && ((IKCTBuildItem)r).GetItemName() == "LaunchPad Reconditioning"));
            }
        }
예제 #8
0
파일: KCTEvents.cs 프로젝트: ntwest/KCT
        public void TechDisableEvent()
        {
            const string logBlockName = nameof(KCTEvents) + "." + nameof(TechDisableEvent);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                TechDisableEventFinal(true);
            }
        }
예제 #9
0
파일: KSC.cs 프로젝트: ntwest/KCT
        public Recon_Rollout GetReconRollout(Recon_Rollout.RolloutReconType type, string launchSite = "LaunchPad")
        {
            const string logBlockName = nameof(SpaceCenterConstruction) + "." + nameof(GetReconRollout);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                return(Recon_Rollout.FirstOrDefault(r => r.RRType == type && r.launchPadID == launchSite));
            }
        }
예제 #10
0
파일: KCTEvents.cs 프로젝트: ntwest/KCT
        private void ShipModifiedEvent(ShipConstruct vessel)
        {
            const string logBlockName = nameof(KCTEvents) + "." + nameof(ShipModifiedEvent);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                KerbalConstructionTime.instance.editorRecalcuationRequired = true;
            }
        }
예제 #11
0
파일: KCTEvents.cs 프로젝트: ntwest/KCT
        public void FacilityContextMenuSpawn(KSCFacilityContextMenu menu)
        {
            const string logBlockName = nameof(KCTEvents) + "." + nameof(FacilityContextMenuSpawn);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                KerbalConstructionTime.instance.FacilityContextMenuSpawn(menu);
            }
        }
예제 #12
0
파일: KCTEvents.cs 프로젝트: ntwest/KCT
        public KCTEvents()
        {
            const string logBlockName = nameof(KCTEvents) + ".CTOR";

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                eventAdded = false;
            }
        }
예제 #13
0
        private static void CheckVesselsForMissingParts()
        {
            const string logBlockName = nameof(KerbalConstructionTime) + "." + nameof(DelayedStart);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                //check that all parts are valid in all ships. If not, warn the user and disable that vessel (once that code is written)
                if (!GameStates.vesselErrorAlerted)
                {
                    List <BuildListVessel> erroredVessels = new List <BuildListVessel>();
                    foreach (SpaceCenterConstruction KSC in GameStates.KSCs) //this is faster on subsequent scene changes
                    {
                        foreach (BuildListVessel blv in KSC.VABList)
                        {
                            if (!blv.allPartsValid)
                            {
                                //error!
                                Log.Trace(blv.shipName + " contains invalid parts!");
                                erroredVessels.Add(blv);
                            }
                        }
                        foreach (BuildListVessel blv in KSC.VABWarehouse)
                        {
                            if (!blv.allPartsValid)
                            {
                                //error!
                                Log.Trace(blv.shipName + " contains invalid parts!");
                                erroredVessels.Add(blv);
                            }
                        }
                        foreach (BuildListVessel blv in KSC.SPHList)
                        {
                            if (!blv.allPartsValid)
                            {
                                //error!
                                Log.Trace(blv.shipName + " contains invalid parts!");
                                erroredVessels.Add(blv);
                            }
                        }
                        foreach (BuildListVessel blv in KSC.SPHWarehouse)
                        {
                            if (!blv.allPartsValid)
                            {
                                //error!
                                Log.Trace(blv.shipName + " contains invalid parts!");
                                erroredVessels.Add(blv);
                            }
                        }
                    }
                    if (erroredVessels.Count > 0)
                    {
                        PopUpVesselError(erroredVessels);
                    }
                    GameStates.vesselErrorAlerted = true;
                }
            }
        }
예제 #14
0
파일: KCTEvents.cs 프로젝트: ntwest/KCT
        public void HideAllGUIs()
        {
            const string logBlockName = nameof(KCTEvents) + "." + nameof(HideAllGUIs);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                //KCT_GUI.hideAll();
                KCT_GUI.ClickOff();
            }
        }
예제 #15
0
        internal void FacilityContextMenuSpawn(KSCFacilityContextMenu menu)
        {
            const string logBlockName = nameof(KerbalConstructionTime) + "." + nameof(FacilityContextMenuSpawn);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                KCT_KSCContextMenuOverrider overrider = new KCT_KSCContextMenuOverrider(menu);
                StartCoroutine(overrider.OnContextMenuSpawn());
            }
        }
예제 #16
0
파일: KCTEvents.cs 프로젝트: ntwest/KCT
        public void TechUnlockEvent(GameEvents.HostTargetAction <RDTech, RDTech.OperationResult> ev)
        {
            const string logBlockName = nameof(KCTEvents) + "." + nameof(TechUnlockEvent);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                //TODO: Check if any of the parts are experimental, if so, do the normal KCT stuff and then set them experimental again
                if (!KCT_PresetManager.Instance.ActivePreset.generalSettings.Enabled)
                {
                    return;
                }
                if (ev.target == RDTech.OperationResult.Successful)
                {
                    KCT_TechItem tech = new KCT_TechItem();
                    if (ev.host != null)
                    {
                        tech = new KCT_TechItem(ev.host);
                    }

                    foreach (AvailablePart expt in ev.host.partsPurchased)
                    {
                        if (ResearchAndDevelopment.IsExperimentalPart(expt))
                        {
                            GameStates.ExperimentalParts.Add(expt);
                        }
                    }

                    //if (!KCT_GameStates.settings.InstantTechUnlock && !KCT_GameStates.settings.DisableBuildTime) tech.DisableTech();
                    if (!tech.isInList())
                    {
                        if (KCT_PresetManager.Instance.ActivePreset.generalSettings.TechUpgrades)
                        {
                            ScreenMessages.PostScreenMessage("[KCT] Upgrade Point Added!", 4.0f, ScreenMessageStyle.UPPER_LEFT);
                        }

                        if (KCT_PresetManager.Instance.ActivePreset.generalSettings.TechUnlockTimes && KCT_PresetManager.Instance.ActivePreset.generalSettings.BuildTimes)
                        {
                            GameStates.TechList.Add(tech);
                            foreach (KCT_TechItem techItem in GameStates.TechList)
                            {
                                techItem.UpdateBuildRate(GameStates.TechList.IndexOf(techItem));
                            }
                            double timeLeft = tech.BuildRate > 0 ? tech.TimeLeft : tech.EstimatedTimeLeft;
                            ScreenMessages.PostScreenMessage("[KCT] Node will unlock in " + MagiCore.Utilities.GetFormattedTime(timeLeft), 4.0f, ScreenMessageStyle.UPPER_LEFT);
                        }
                    }
                    else
                    {
                        ResearchAndDevelopment.Instance.AddScience(tech.scienceCost, TransactionReasons.RnDTechResearch);
                        ScreenMessages.PostScreenMessage("[KCT] This node is already being researched!", 4.0f, ScreenMessageStyle.UPPER_LEFT);
                        ScreenMessages.PostScreenMessage("[KCT] It will unlock in " + MagiCore.Utilities.GetFormattedTime((GameStates.TechList.First(t => t.techID == ev.host.techID)).TimeLeft), 4.0f, ScreenMessageStyle.UPPER_LEFT);
                    }
                }
            }
        }
예제 #17
0
        public void Awake()
        {
            const string logBlockName = nameof(KerbalConstructionTime) + "." + nameof(Awake);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                if (KCT_Utilities.CurrentGameIsMission())
                {
                    return;
                }
                GameStates.erroredDuringOnLoad.OnLoadStart();
                GameStates.PersistenceLoaded = false;

                instance = this;

                GameStates.settings.Load(); //Load the settings file, if it exists

                string SavedFile = KSPUtil.ApplicationRootPath + "/saves/" + HighLogic.SaveFolder + "/KCT_Settings.cfg";
                if (!System.IO.File.Exists(SavedFile))
                {
                    GameStates.firstStart = true;
                }

                if (KCT_PresetManager.Instance == null)
                {
                    KCT_PresetManager.Instance = new KCT_PresetManager();
                }
                KCT_PresetManager.Instance.SetActiveFromSaveData();


                //Add the toolbar button
                if (ToolbarManager.ToolbarAvailable && ToolbarManager.Instance != null && GameStates.settings.PreferBlizzyToolbar)
                {
                    Log.Trace("Adding Toolbar Button");
                    GameStates.kctToolbarButton = ToolbarManager.Instance.add("Kerbal_Construction_Time", "MainButton");
                    if (GameStates.kctToolbarButton != null)
                    {
                        if (KCT_PresetManager.PresetLoaded() && !KCT_PresetManager.Instance.ActivePreset.generalSettings.Enabled)
                        {
                            GameStates.kctToolbarButton.Visibility = new GameScenesVisibility(GameScenes.SPACECENTER);
                        }
                        else
                        {
                            GameStates.kctToolbarButton.Visibility = new GameScenesVisibility(new GameScenes[] { GameScenes.SPACECENTER, GameScenes.FLIGHT, GameScenes.TRACKSTATION, GameScenes.EDITOR });
                        }
                        GameStates.kctToolbarButton.TexturePath = KCT_Utilities.GetButtonTexture();
                        GameStates.kctToolbarButton.ToolTip     = "Kerbal Construction Time";
                        GameStates.kctToolbarButton.OnClick    += ((e) =>
                        {
                            KCT_GUI.ClickToggle();
                        });
                    }
                }
            }
        }
예제 #18
0
파일: KCTDebug.cs 프로젝트: ntwest/KCT
        public void OnLoadFinish()
        {
            const string logBlockName = nameof(KCT_OnLoadError) + "." + nameof(OnLoadFinish);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                OnLoadCalled   = false;
                OnLoadFinished = true;
                timer          = -1;
                Log.Info("OnLoad Complete");
            }
        }
예제 #19
0
파일: KCTEvents.cs 프로젝트: ntwest/KCT
        private void SYInventoryApplied()
        {
            const string logBlockName = nameof(KCTEvents) + "." + nameof(SYInventoryApplied);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                Log.Info("Inventory was applied. Recalculating.");
                if (HighLogic.LoadedSceneIsEditor)
                {
                    KerbalConstructionTime.instance.editorRecalcuationRequired = true;
                }
            }
        }
예제 #20
0
파일: KCTEvents.cs 프로젝트: ntwest/KCT
        public void RecoveryRequested(Vessel v)
        {
            const string logBlockName = nameof(KCTEvents) + "." + nameof(RecoveryRequested);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                //ShipBackup backup = ShipAssembly.MakeVesselBackup(v);
                //string tempFile = KSPUtil.ApplicationRootPath + "saves/" + HighLogic.SaveFolder + "/Ships/temp2.craft";
                //backup.SaveShip(tempFile);

                // KCT_GameStates.recoveryRequestVessel = backup; //ConfigNode.Load(tempFile);
            }
        }
예제 #21
0
파일: KCTDebug.cs 프로젝트: ntwest/KCT
        public void OnLoadStart()
        {
            const string logBlockName = nameof(KCT_OnLoadError) + "." + nameof(OnLoadStart);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                Log.Info("OnLoad Started");
                OnLoadCalled   = true;
                OnLoadFinished = false;
                timer          = 0;
                AlertFired     = false;
            }
        }
예제 #22
0
파일: KCTEvents.cs 프로젝트: ntwest/KCT
        public void FacilityDestroyed(DestructibleBuilding facility)
        {
            const string logBlockName = nameof(KCTEvents) + "." + nameof(FaciliyRepaired);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                if (facility.id.Contains("LaunchPad"))
                {
                    Log.Info("LaunchPad was damaged.");

                    //KCT_GameStates.ActiveKSC.LaunchPads[KCT_GameStates.ActiveKSC.ActiveLaunchPadID].destroyed = !KCT_Utilities.LaunchFacilityIntact(KCT_BuildListVessel.ListType.VAB);
                    GameStates.ActiveKSC.ActiveLPInstance.RefreshDestructionNode();
                }
            }
        }
예제 #23
0
파일: KCTEvents.cs 프로젝트: ntwest/KCT
        public void TechEnableEvent()
        {
            const string logBlockName = nameof(KCTEvents) + "." + nameof(TechEnableEvent);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                if (KCT_PresetManager.Instance.ActivePreset.generalSettings.TechUnlockTimes && KCT_PresetManager.Instance.ActivePreset.generalSettings.BuildTimes)
                {
                    foreach (KCT_TechItem techItem in GameStates.TechList)
                    {
                        techItem.EnableTech();
                    }
                }
            }
        }
예제 #24
0
파일: KCTEvents.cs 프로젝트: ntwest/KCT
        public void FacilityRepairingEvent(DestructibleBuilding facility)
        {
            const string logBlockName = nameof(KCTEvents) + "." + nameof(FacilityRepairingEvent);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                if (KCT_GUI.PrimarilyDisabled)
                {
                    return;
                }
                double cost = facility.RepairCost;
                double BP   = Math.Sqrt(cost) * 2000 * KCT_PresetManager.Instance.ActivePreset.timeSettings.OverallMultiplier;
                Log.Info("Facility being repaired for " + cost + " funds, resulting in a BP of " + BP);
                //facility.StopCoroutine("Repair");
            }
        }
예제 #25
0
파일: KCTEvents.cs 프로젝트: ntwest/KCT
        public void FaciliyRepaired(DestructibleBuilding facility)
        {
            const string logBlockName = nameof(KCTEvents) + "." + nameof(FaciliyRepaired);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                if (facility.id.Contains("LaunchPad"))
                {
                    Log.Info("LaunchPad was repaired.");

                    //KCT_GameStates.ActiveKSC.LaunchPads[KCT_GameStates.ActiveKSC.ActiveLaunchPadID].destroyed = false;
                    GameStates.ActiveKSC.ActiveLPInstance.RefreshDestructionNode();
                    GameStates.ActiveKSC.ActiveLPInstance.CompletelyRepairNode();
                }
            }
        }
예제 #26
0
파일: KCTEvents.cs 프로젝트: ntwest/KCT
        public void PersistenceLoadEvent(ConfigNode node)
        {
            const string logBlockName = nameof(KCTEvents) + "." + nameof(PersistenceLoadEvent);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                //KCT_GameStates.erroredDuringOnLoad.OnLoadStart();
                Log.Trace("Looking for tech nodes.");
                ConfigNode rnd = node.GetNodes("SCENARIO").FirstOrDefault(n => n.GetValue("name") == "ResearchAndDevelopment");
                if (rnd != null)
                {
                    GameStates.LastKnownTechCount = rnd.GetNodes("Tech").Length;
                    Log.Trace("Counting " + GameStates.LastKnownTechCount + " tech nodes.");
                }
                GameStates.PersistenceLoaded = true;
            }
        }
예제 #27
0
파일: KSC.cs 프로젝트: ntwest/KCT
        /// <summary>
        /// Finds the highest level LaunchPad on the KSC
        /// </summary>
        /// <returns>The instance of the highest level LaunchPad</returns>
        public LaunchPad GetHighestLevelLaunchPad()
        {
            const string logBlockName = nameof(SpaceCenterConstruction) + "." + nameof(GetHighestLevelLaunchPad);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                LaunchPad highest = LaunchPads[0];

                foreach (LaunchPad pad in LaunchPads)
                {
                    if (pad.level > highest.level)
                    {
                        highest = pad;
                    }
                }
                return(highest);
            }
        }
예제 #28
0
파일: KCTEvents.cs 프로젝트: ntwest/KCT
        public void launchScreenOpenEvent(GameEvents.VesselSpawnInfo v)
        {
            const string logBlockName = nameof(KCTEvents) + "." + nameof(launchScreenOpenEvent);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                if (!KCT_GUI.PrimarilyDisabled)
                {
                    // PopupDialog.SpawnPopupDialog(new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), "Warning!", "To launch vessels you must first build them in the VAB or SPH, then launch them through the main KCT window in the Space Center!", "Ok", false, HighLogic.UISkin);
                    //open the build list to the right page
                    string selection = (v.craftSubfolder.Contains("SPH")) ? "SPH" : "VAB";
                    KCT_GUI.ClickOn();
                    KCT_GUI.SelectList("");
                    KCT_GUI.SelectList(selection);
                    Log.Trace("Opening the GUI to the " + selection);
                }
            }
        }
예제 #29
0
        public void OnDestroy()//more toolbar stuff
        {
            const string logBlockName = nameof(KerbalConstructionTime) + "." + nameof(OnDestroy);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                if (GameStates.kctToolbarButton != null)
                {
                    GameStates.kctToolbarButton.Destroy();
                }
                if (KCTEvents.instance.KCTButtonStock != null)
                {
                    KSP.UI.Screens.ApplicationLauncher.Instance.RemoveModApplication(KCTEvents.instance.KCTButtonStock);
                }

                KCT_GUI.guiDataSaver.Save();
            }
        }
예제 #30
0
파일: KSC.cs 프로젝트: ntwest/KCT
        public void RecalculateBuildRates()
        {
            const string logBlockName = nameof(SpaceCenterConstruction) + "." + nameof(RecalculateBuildRates);

            using (EntryExitLogger.EntryExitLog(logBlockName, EntryExitLoggerOptions.All))
            {
                VABRates.Clear();
                SPHRates.Clear();
                double rate  = 0.1;
                int    index = 0;
                while (rate > 0)
                {
                    rate = KCT_MathParsing.ParseBuildRateFormula(BuildListVessel.ListType.VAB, index, this);
                    if (rate >= 0)
                    {
                        VABRates.Add(rate);
                    }
                    index++;
                }
                rate  = 0.1;
                index = 0;
                while (rate > 0)
                {
                    rate = KCT_MathParsing.ParseBuildRateFormula(BuildListVessel.ListType.SPH, index, this);
                    if (rate >= 0)
                    {
                        SPHRates.Add(rate);
                    }
                    index++;
                }

                Log.Trace("VAB Rates:");
                foreach (double v in VABRates)
                {
                    Log.Trace(v.ToString());
                }

                Log.Trace("SPH Rates:");
                foreach (double v in SPHRates)
                {
                    Log.Trace(v.ToString());
                }
            }
        }