public IEnumerator OnContextMenuSpawn() { yield return(new WaitForFixedUpdate()); if (KCT_PresetManager.Instance.ActivePreset.generalSettings.KSCUpgradeTimes && _menu != null) { SpaceCenterBuilding hostBuilding = getMember <SpaceCenterBuilding>("host"); KCTDebug.Log("Trying to override upgrade button of menu for " + hostBuilding.facilityName); UnityEngine.UI.Button button = getMember <UnityEngine.UI.Button>("UpgradeButton"); if (button == null) { KCTDebug.Log("Could not find UpgradeButton by name, using index instead.", true); button = getMember <UnityEngine.UI.Button>(2); } if (button != null) { KCTDebug.Log("Found upgrade button, overriding it."); button.onClick = new UnityEngine.UI.Button.ButtonClickedEvent(); //Clear existing KSP listener button.onClick.AddListener(handleUpgrade); } else { throw new Exception("UpgradeButton not found. Cannot override."); } } }
internal KerbalConstructionTime() { instance = this; if (ToolbarManager.ToolbarAvailable && ToolbarManager.Instance != null && KCT_GameStates.settings.PreferBlizzyToolbar) { KCTDebug.Log("Adding Toolbar Button"); KCT_GameStates.kctToolbarButton = ToolbarManager.Instance.add("Kerbal_Construction_Time", "MainButton"); if (KCT_GameStates.kctToolbarButton != null) { if (!KCT_GameStates.settings.enabledForSave) { KCT_GameStates.kctToolbarButton.Visibility = new GameScenesVisibility(GameScenes.SPACECENTER); } else { KCT_GameStates.kctToolbarButton.Visibility = new GameScenesVisibility(new GameScenes[] { GameScenes.SPACECENTER, GameScenes.FLIGHT, GameScenes.TRACKSTATION, GameScenes.EDITOR }); } KCT_GameStates.kctToolbarButton.TexturePath = KCT_Utilities.GetButtonTexture(); KCT_GameStates.kctToolbarButton.ToolTip = "Kerbal Construction Time"; KCT_GameStates.kctToolbarButton.OnClick += ((e) => { KCT_GUI.onClick(); }); } } }
public void BruteForceLocateVessel() { KCTDebug.Log("Brute force looking for " + shipName); bool found = false; found = KSC.VABList.Exists(b => b.id == this.id); if (found) { type = ListType.VAB; return; } found = KSC.VABWarehouse.Exists(b => b.id == this.id); if (found) { type = ListType.VAB; return; } found = KSC.SPHList.Exists(b => b.id == this.id); if (found) { type = ListType.SPH; return; } found = KSC.SPHWarehouse.Exists(b => b.id == this.id); if (found) { type = ListType.SPH; return; } if (!found) { KCTDebug.Log("Still can't find ship even after checking every list..."); //KCTDebug.Log("Guess we'll do it for every single KSC then!"); } }
public void BruteForceLocateVessel() { KCTDebug.Log($"Brute force looking for {ShipName}"); bool found = false; found = KSC.VABList.Exists(b => b.Id == Id); if (found) { Type = ListType.VAB; return; } found = KSC.VABWarehouse.Exists(b => b.Id == Id); if (found) { Type = ListType.VAB; return; } found = KSC.SPHList.Exists(b => b.Id == Id); if (found) { Type = ListType.SPH; return; } found = KSC.SPHWarehouse.Exists(b => b.Id == Id); if (found) { Type = ListType.SPH; return; } if (!found) { KCTDebug.Log("Still can't find ship even after checking every list..."); } }
public void SetActive() { try { KCTDebug.Log($"Switching to LaunchPad: {name} lvl: {level} destroyed? {IsDestroyed}"); KCTGameStates.ActiveKSC.ActiveLaunchPadID = KCTGameStates.ActiveKSC.LaunchPads.IndexOf(this); //set the level to this level if (Utilities.CurrentGameIsCareer()) { foreach (Upgradeables.UpgradeableFacility facility in GetUpgradeableFacilityReferences()) { KCTEvents.AllowedToUpgrade = true; facility.SetLevel(level); } } //set the destroyed state to this destroyed state //might need to do this one frame later? //RefreshDesctructibleState(); KCTGameStates.UpdateLaunchpadDestructionState = true; upgradeRepair = false; } catch (Exception ex) { KCTDebug.LogError("Error while calling SetActive: " + ex); } }
public void Upgrade() { KCTDebug.Log("Upgrading " + commonName + " to level " + upgradeLevel); if (isLaunchpad) { KSC.LaunchPads[launchpadID].level = upgradeLevel; KSC.LaunchPads[launchpadID].DestructionNode = new ConfigNode("DestructionState"); if (KCT_GameStates.activeKSCName != KSC.KSCName || KCT_GameStates.ActiveKSC.ActiveLaunchPadID != launchpadID) { UpgradeProcessed = true; return; } KSC.LaunchPads[launchpadID].Upgrade(upgradeLevel); } KCT_Events.allowedToUpgrade = true; foreach (Upgradeables.UpgradeableFacility facility in GetFacilityReferences()) { facility.SetLevel(upgradeLevel); } int newLvl = KCT_Utilities.BuildingUpgradeLevel(id); UpgradeProcessed = (newLvl == upgradeLevel); KCTDebug.Log($"Upgrade processed: {UpgradeProcessed} Current: {newLvl} Desired: {upgradeLevel}"); //KCT_Events.allowedToUpgrade = false; }
public void OnLoadFinish() { OnLoadCalled = false; OnLoadFinished = true; timer = -1; KCTDebug.Log("OnLoad Completed"); }
private static IEnumerator SetSimOrbit(SimulationParams simParams) { yield return(new WaitForEndOfFrame()); KCTDebug.Log($"Moving vessel to orbit. {simParams.SimulationBody.bodyName}:{simParams.SimOrbitAltitude}:{simParams.SimInclination}"); HyperEdit_Utilities.PutInOrbitAround(simParams.SimulationBody, simParams.SimOrbitAltitude, simParams.SimInclination); }
private IEnumerator EaseSimulationUT_Coroutine(double startUT, double targetUT) { const double dayInSeconds = 86_400; if (targetUT <= Planetarium.GetUniversalTime()) { yield break; } KCTDebug.Log($"Easing jump to simulation UT in {dayInSeconds}s steps"); int currentFrame = Time.frameCount; double nextUT = startUT; while (targetUT - nextUT > dayInSeconds) { nextUT += dayInSeconds; FlightDriver.fetch.framesBeforeInitialSave += Time.frameCount - currentFrame; currentFrame = Time.frameCount; OrbitPhysicsManager.HoldVesselUnpack(); Planetarium.SetUniversalTime(nextUT); yield return(new WaitForFixedUpdate()); } OrbitPhysicsManager.HoldVesselUnpack(); Planetarium.SetUniversalTime(targetUT); }
public void SetActive() { try { EnsureMassAndSizeInitialized(); KCTDebug.Log($"Switching to LaunchPad: {name} lvl: {level} destroyed? {IsDestroyed}"); KCTGameStates.ActiveKSC.ActiveLaunchPadID = KCTGameStates.ActiveKSC.LaunchPads.IndexOf(this); //set the level to this level if (Utilities.CurrentGameIsCareer()) { UpgradeableFacility facility = GetUpgradeableFacilityReference(); KCTEvents.AllowedToUpgrade = true; facility.SetLevel(level); } //set the destroyed state to this destroyed state UpdateLaunchpadDestructionState(false); } catch (Exception ex) { KCTDebug.LogError("Error while calling SetActive: " + ex); } }
private IEnumerator UpdateBuildRates() { do { yield return(new WaitForFixedUpdate()); // No way to know when KSP has finally initialized the ScenarioUpgradeableFacilities data } while (HighLogic.LoadedScene == GameScenes.SPACECENTER && ScenarioUpgradeableFacilities.GetFacilityLevelCount(SpaceCenterFacility.VehicleAssemblyBuilding) < 0); if (HighLogic.LoadedScene == GameScenes.SPACECENTER && ScenarioUpgradeableFacilities.GetFacilityLevelCount(SpaceCenterFacility.VehicleAssemblyBuilding) >= 0) { KCTDebug.Log("Updating build rates"); foreach (KSCItem KSC in KCTGameStates.KSCs) { KSC?.RecalculateBuildRates(); KSC?.RecalculateUpgradedBuildRates(); } KCTDebug.Log("Rates updated"); foreach (SpaceCenterFacility facility in Enum.GetValues(typeof(SpaceCenterFacility))) { KCTGameStates.BuildingMaxLevelCache[facility.ToString()] = ScenarioUpgradeableFacilities.GetFacilityLevelCount(facility); KCTDebug.Log($"Cached {facility} max at {KCTGameStates.BuildingMaxLevelCache[facility.ToString()]}"); } } }
public ReconRollout(Vessel vessel, RolloutReconType type, string id, string launchSite) { RRType = type; AssociatedID = id; LaunchPadID = launchSite; KCTDebug.Log("New recon_rollout at launchsite: " + LaunchPadID); Progress = 0; try { BP = MathParser.ParseReconditioningFormula(new BuildListVessel(vessel), true); } catch { KCTDebug.Log("Error while determining BP for recon_rollout"); } if (type == RolloutReconType.Rollback) { Progress = BP; } else if (type == RolloutReconType.Recovery) { double KSCDistance = (float)SpaceCenter.Instance.GreatCircleDistance(SpaceCenter.Instance.cb.GetRelSurfaceNVector(vessel.latitude, vessel.longitude)); double maxDist = SpaceCenter.Instance.cb.Radius * Math.PI; BP += BP * (KSCDistance / maxDist); } }
public void Upgrade() { KCTDebug.Log($"Upgrading {CommonName} to level {UpgradeLevel}"); if (IsLaunchpad) { KSC.LaunchPads[LaunchpadID].level = UpgradeLevel; KSC.LaunchPads[LaunchpadID].DestructionNode = new ConfigNode("DestructionState"); if (KCTGameStates.ActiveKSCName != KSC.KSCName || KCTGameStates.ActiveKSC.ActiveLaunchPadID != LaunchpadID) { UpgradeProcessed = true; return; } KSC.LaunchPads[LaunchpadID].Upgrade(UpgradeLevel); } KCTEvents.AllowedToUpgrade = true; foreach (UpgradeableFacility facility in GetFacilityReferences()) { facility.SetLevel(UpgradeLevel); } int newLvl = Utilities.GetBuildingUpgradeLevel(Id); UpgradeProcessed = newLvl == UpgradeLevel; KCTDebug.Log($"Upgrade processed: {UpgradeProcessed} Current: {newLvl} Desired: {UpgradeLevel}"); }
private static void UpdateBuildRates() { if (!_ratesUpdated) { if (HighLogic.LoadedScene == GameScenes.SPACECENTER) { if (ScenarioUpgradeableFacilities.GetFacilityLevelCount(SpaceCenterFacility.VehicleAssemblyBuilding) >= 0) { _ratesUpdated = true; KCTDebug.Log("Updating build rates"); foreach (KSCItem KSC in KCTGameStates.KSCs) { KSC?.RecalculateBuildRates(); KSC?.RecalculateUpgradedBuildRates(); } KCTDebug.Log("Rates updated"); foreach (SpaceCenterFacility facility in Enum.GetValues(typeof(SpaceCenterFacility))) { KCTGameStates.BuildingMaxLevelCache[facility.ToString()] = ScenarioUpgradeableFacilities.GetFacilityLevelCount(facility); KCTDebug.Log($"Cached {facility} max at {KCTGameStates.BuildingMaxLevelCache[facility.ToString()]}"); } } } else { _ratesUpdated = true; } } }
public override void OnSave(ConfigNode node) { #if KSP1_4 // 1.4 Addition if (KCT_Utilities.CurrentGameIsMission()) { return; } #endif // Boolean error = false; KCTDebug.Log("Writing to persistence."); base.OnSave(node); KCT_DataStorage kctVS = new KCT_DataStorage(); node.AddNode(kctVS.AsConfigNode()); foreach (KCT_KSC KSC in KCT_GameStates.KSCs) { if (KSC != null && KSC.KSCName != null && KSC.KSCName.Length > 0) { node.AddNode(KSC.AsConfigNode()); } } ConfigNode tech = new ConfigNode("TechList"); foreach (KCT_TechItem techItem in KCT_GameStates.TechList) { KCT_TechStorageItem techNode = new KCT_TechStorageItem(); techNode.FromTechItem(techItem); ConfigNode cnTemp = new ConfigNode("Tech"); cnTemp = ConfigNode.CreateConfigFromObject(techNode, cnTemp); ConfigNode protoNode = new ConfigNode("ProtoNode"); techItem.protoNode.Save(protoNode); cnTemp.AddNode(protoNode); tech.AddNode(cnTemp); } node.AddNode(tech); }
public void SetActiveFromSaveData() { string SavedFile = KSPUtil.ApplicationRootPath + "/saves/" + HighLogic.SaveFolder + "/KCT_Settings.cfg"; if (System.IO.File.Exists(SavedFile)) { KCT_Preset saved = new KCT_Preset(SavedFile); KCT_Preset source = FindPresetByShortName(saved.shortName); if (source != null) //Get settings from the original preset, if it exists { ActivePreset = source; KCTDebug.Log("Loading settings from preset, rather than save. Name: " + ActivePreset.name); } else { ActivePreset = saved; KCTDebug.Log("Loading saved settings."); } } else { KCT_Preset defaultSettings = FindPresetByShortName("default"); if (defaultSettings != null) { ActivePreset = defaultSettings; } else { ActivePreset = new KCT_Preset("UNINIT", "UNINIT", "NA", "NA"); } } }
public override void OnLoad(ConfigNode node) { base.OnLoad(node); LoadTree(); #if KSP1_4 // 1.4 Addition if (KCT_Utilities.CurrentGameIsMission()) { return; } #endif KCTDebug.Log("Reading from persistence."); KCT_GameStates.KSCs.Clear(); KCT_GameStates.ActiveKSC = null; //KCT_Utilities.SetActiveKSC("Stock"); KCT_GameStates.InitAndClearTechList(); KCT_GameStates.TechUpgradesTotal = 0; KCT_GameStates.SciPointsTotal = -1; KCT_DataStorage kctVS = new KCT_DataStorage(); ConfigNode CN = node.GetNode(kctVS.GetType().Name); if (CN != null) { ConfigNode.LoadObjectFromConfig(kctVS, CN); } foreach (ConfigNode ksc in node.GetNodes("KSC")) { string name = ksc.GetValue("KSCName"); KCT_KSC loaded_KSC = new KCT_KSC(name); loaded_KSC.FromConfigNode(ksc); if (loaded_KSC != null && loaded_KSC.KSCName != null && loaded_KSC.KSCName.Length > 0) { loaded_KSC.RDUpgrades[1] = KCT_GameStates.TechUpgradesTotal; if (KCT_GameStates.KSCs.Find(k => k.KSCName == loaded_KSC.KSCName) == null) { KCT_GameStates.KSCs.Add(loaded_KSC); } } } KCT_Utilities.SetActiveKSCToRSS(); ConfigNode tmp = node.GetNode("TechList"); if (tmp != null) { 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")); KCT_GameStates.TechList.Add(techItem); } } KCT_GUI.CheckToolbar(); KCT_GameStates.erroredDuringOnLoad.OnLoadFinish(); //KerbalConstructionTime.DelayedStart(); }
private void UpdateRFTanks() { var nodes = shipNode.GetNodes("PART"); for (int i = nodes.Count() - 1; i >= 0; i--) { ConfigNode cn = nodes[i]; //foreach (ConfigNode cn in shipNode.GetNodes("PART")) //{ var modules = cn.GetNodes("MODULE"); for (int im = modules.Count() - 1; im >= 0; im--) { ConfigNode module = modules[im]; //foreach (ConfigNode module in cn.GetNodes("MODULE")) //{ if (module.GetValue("name") == "ModuleFuelTanks") { if (module.HasValue("timestamp")) { KCTDebug.Log("Updating RF timestamp on a part"); module.SetValue("timestamp", Planetarium.GetUniversalTime().ToString()); } } } } }
public override void OnSave(ConfigNode node) { if (Utilities.CurrentGameIsMission()) { return; } KCTDebug.Log("Writing to persistence."); base.OnSave(node); var kctVS = new KCT_DataStorage(); node.AddNode(kctVS.AsConfigNode()); foreach (KSCItem KSC in KCTGameStates.KSCs.Where(x => x?.KSCName?.Length > 0)) { node.AddNode(KSC.AsConfigNode()); } var tech = new ConfigNode("TechList"); foreach (TechItem techItem in KCTGameStates.TechList) { var techNode = new KCT_TechStorageItem(); techNode.FromTechItem(techItem); var cnTemp = new ConfigNode("Tech"); cnTemp = ConfigNode.CreateConfigFromObject(techNode, cnTemp); var protoNode = new ConfigNode("ProtoNode"); techItem.ProtoNode.Save(protoNode); cnTemp.AddNode(protoNode); tech.AddNode(cnTemp); } node.AddNode(tech); KCT_GUI.GuiDataSaver.Save(); }
public void SetActive() { try { KCTDebug.Log("Switching to LaunchPad: " + name + " lvl: " + level + " destroyed? " + destroyed); KCT_GameStates.ActiveKSC.ActiveLaunchPadID = KCT_GameStates.ActiveKSC.LaunchPads.IndexOf(this); //set the level to this level if (KCT_Utilities.CurrentGameIsCareer()) { foreach (Upgradeables.UpgradeableFacility facility in GetUpgradeableFacilityReferences()) { KCT_Events.allowedToUpgrade = true; facility.SetLevel(level); } } //set the destroyed state to this destroyed state //might need to do this one frame later? // RefreshDesctructibleState(); KCT_GameStates.UpdateLaunchpadDestructionState = true; upgradeRepair = false; } catch (Exception e) { KCTDebug.Log("Error while calling SetActive: " + e.Message + e.StackTrace); } }
public void SetActiveFromSaveData() { if (File.Exists(SettingsFilePath)) { KCT_Preset saved = new KCT_Preset(SettingsFilePath); KCT_Preset source = FindPresetByShortName(saved.ShortName); if (source != null) //Get settings from the original preset, if it exists { ActivePreset = source; KCTDebug.Log("Loading settings from preset, rather than save. Name: " + ActivePreset.Name); } else { ActivePreset = saved; KCTDebug.Log("Loading saved settings."); } } else { KCT_Preset defaultSettings = FindPresetByShortName("RP1"); if (defaultSettings != null) { ActivePreset = defaultSettings; } else { ActivePreset = new KCT_Preset("UNINIT", "UNINIT", "NA", "NA"); } } }
public void Awake() { #if KSP1_4 // 1.4 Addition if (KCT_Utilities.CurrentGameIsMission()) { return; } #endif KCTDebug.Log("Awake called"); KCT_GameStates.erroredDuringOnLoad.OnLoadStart(); KCT_GameStates.PersistenceLoaded = false; instance = this; KCT_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)) { KCT_GameStates.firstStart = true; } if (KCT_PresetManager.Instance == null) { KCT_PresetManager.Instance = new KCT_PresetManager(); } KCT_PresetManager.Instance.SetActiveFromSaveData(); // Create events for other mods if (!KCT_Events.instance.createdEvents) { KCT_Events.instance.CreateEvents(); } //Add the toolbar button if (ToolbarManager.ToolbarAvailable && ToolbarManager.Instance != null && KCT_GameStates.settings.PreferBlizzyToolbar) { KCTDebug.Log("Adding Toolbar Button"); KCT_GameStates.kctToolbarButton = ToolbarManager.Instance.add("Kerbal_Construction_Time", "MainButton"); if (KCT_GameStates.kctToolbarButton != null) { if (KCT_PresetManager.PresetLoaded() && !KCT_PresetManager.Instance.ActivePreset.generalSettings.Enabled) { KCT_GameStates.kctToolbarButton.Visibility = new GameScenesVisibility(GameScenes.SPACECENTER); } else { KCT_GameStates.kctToolbarButton.Visibility = new GameScenesVisibility(new GameScenes[] { GameScenes.SPACECENTER, GameScenes.FLIGHT, GameScenes.TRACKSTATION, GameScenes.EDITOR }); } KCT_GameStates.kctToolbarButton.TexturePath = KCT_Utilities.GetButtonTexture(); KCT_GameStates.kctToolbarButton.ToolTip = "Kerbal Construction Time"; KCT_GameStates.kctToolbarButton.OnClick += ((e) => { KCT_GUI.ClickToggle(); }); } } KCTDebug.Log("Awake finished"); }
public void vesselRecoverEvent(ProtoVessel v, bool unknownAsOfNow) { KCTDebug.Log("VesselRecoverEvent"); if (!KCT_PresetManager.Instance.ActivePreset.generalSettings.Enabled) { return; } if (!v.vesselRef.isEVA) { // if (KCT_GameStates.settings.Debug && HighLogic.LoadedScene != GameScenes.TRACKSTATION && (v.wasControllable || v.protoPartSnapshots.Find(p => p.modules.Find(m => m.moduleName.ToLower() == "modulecommand") != null) != null)) if (KCT_GameStates.recoveredVessel != null && v.vesselName == KCT_GameStates.recoveredVessel.shipName) { //KCT_GameStates.recoveredVessel = new KCT_BuildListVessel(v); //rebuy the ship if ScrapYard isn't overriding funds if (!ScrapYardWrapper.OverrideFunds) { KCT_Utilities.SpendFunds(KCT_GameStates.recoveredVessel.cost, TransactionReasons.VesselRollout); //pay for the ship again } //pull all of the parts out of the inventory //This is a bit funky since we grab the part id from our part, grab the inventory part out, then try to reapply that ontop of our part if (ScrapYardWrapper.Available) { foreach (ConfigNode partNode in KCT_GameStates.recoveredVessel.ExtractedPartNodes) { string id = ScrapYardWrapper.GetPartID(partNode); ConfigNode inventoryVersion = ScrapYardWrapper.FindInventoryPart(id); if (inventoryVersion != null) { //apply it to our copy of the part ConfigNode ourTracker = partNode.GetNodes("MODULE").FirstOrDefault(n => string.Equals(n.GetValue("name"), "ModuleSYPartTracker", StringComparison.Ordinal)); if (ourTracker != null) { ourTracker.SetValue("TimesRecovered", inventoryVersion.GetValue("_timesRecovered")); ourTracker.SetValue("Inventoried", inventoryVersion.GetValue("_inventoried")); } } } //process the vessel in ScrapYard ScrapYardWrapper.ProcessVessel(KCT_GameStates.recoveredVessel.ExtractedPartNodes); //reset the BP KCT_GameStates.recoveredVessel.buildPoints = KCT_Utilities.GetBuildTime(KCT_GameStates.recoveredVessel.ExtractedPartNodes); } if (KCT_GameStates.recoveredVessel.type == KCT_BuildListVessel.ListType.VAB) { KCT_GameStates.ActiveKSC.VABWarehouse.Add(KCT_GameStates.recoveredVessel); } else { KCT_GameStates.ActiveKSC.SPHWarehouse.Add(KCT_GameStates.recoveredVessel); } KCT_GameStates.ActiveKSC.Recon_Rollout.Add(new KCT_Recon_Rollout(KCT_GameStates.recoveredVessel, KCT_Recon_Rollout.RolloutReconType.Recovery, KCT_GameStates.recoveredVessel.id.ToString())); KCT_GameStates.recoveredVessel = null; } } }
public void FacilityUpgradedEvent(Upgradeables.UpgradeableFacility facility, int lvl) { if (KCT_GUI.PrimarilyDisabled) { return; } if (!(allowedToUpgrade || KCT_GameStates.settings.InstantKSCUpgrades)) { KCT_UpgradingBuilding upgrading = new KCT_UpgradingBuilding(facility, lvl, lvl - 1, facility.id.Split('/').Last()); if (!upgrading.AlreadyInProgress()) { upgrading.Downgrade(); double cost = facility.GetUpgradeCost(); upgrading.SetBP(cost); upgrading.cost = cost; KCT_GameStates.ActiveKSC.KSCTech.Add(upgrading); ScreenMessages.PostScreenMessage("Facility upgrade requested!", 4.0f, ScreenMessageStyle.UPPER_CENTER); KCTDebug.Log("Facility " + facility.id + " upgrade requested to lvl " + lvl + " for " + cost + " funds, resulting in a BP of " + upgrading.BP); } else if (lvl != upgrading.currentLevel) { // KCT_UpgradingBuilding listBuilding = upgrading.KSC.KSCTech.Find(b => b.id == upgrading.id); listBuilding.Downgrade(); KCT_Utilities.AddFunds(listBuilding.cost, TransactionReasons.None); ScreenMessages.PostScreenMessage("Facility is already being upgraded!", 4.0f, ScreenMessageStyle.UPPER_CENTER); KCTDebug.Log("Facility " + facility.id + " tried to upgrade to lvl " + lvl + " but already in list!"); } } else { KCTDebug.Log("Facility " + facility.id + " upgraded to lvl " + lvl); allowedToUpgrade = false; foreach (KCT_KSC ksc in KCT_GameStates.KSCs) { ksc.RecalculateBuildRates(); ksc.RecalculateUpgradedBuildRates(); } foreach (KCT_TechItem tech in KCT_GameStates.TechList) { tech.UpdateBuildRate(); } } /* if (lvl <= lastLvl) * { * lastLvl = -1; * return; * } * facility.SetLevel(lvl - 1); * lastLvl = lvl; * double cost = facility.GetUpgradeCost(); * double BP = Math.Sqrt(cost) * 2000 * KCT_GameStates.timeSettings.OverallMultiplier;*/ // KCTDebug.Log(facility.GetNormLevel()); }
public void VesselRecoverEvent(ProtoVessel v, bool unknownAsOfNow) { KCTDebug.Log("VesselRecoverEvent"); if (!PresetManager.Instance.ActivePreset.GeneralSettings.Enabled) { return; } if (!KCTGameStates.IsSimulatedFlight && !v.vesselRef.isEVA) { if (KCTGameStates.RecoveredVessel != null && v.vesselName == KCTGameStates.RecoveredVessel.ShipName) { //rebuy the ship if ScrapYard isn't overriding funds if (!ScrapYardWrapper.OverrideFunds) { Utilities.SpendFunds(KCTGameStates.RecoveredVessel.Cost, TransactionReasons.VesselRollout); //pay for the ship again } //pull all of the parts out of the inventory //This is a bit funky since we grab the part id from our part, grab the inventory part out, then try to reapply that ontop of our part if (ScrapYardWrapper.Available) { foreach (ConfigNode partNode in KCTGameStates.RecoveredVessel.ExtractedPartNodes) { string id = ScrapYardWrapper.GetPartID(partNode); ConfigNode inventoryVersion = ScrapYardWrapper.FindInventoryPart(id); if (inventoryVersion != null) { //apply it to our copy of the part ConfigNode ourTracker = partNode.GetNodes("MODULE").FirstOrDefault(n => string.Equals(n.GetValue("name"), "ModuleSYPartTracker", StringComparison.Ordinal)); if (ourTracker != null) { ourTracker.SetValue("TimesRecovered", inventoryVersion.GetValue("_timesRecovered")); ourTracker.SetValue("Inventoried", inventoryVersion.GetValue("_inventoried")); } } } //process the vessel in ScrapYard ScrapYardWrapper.ProcessVessel(KCTGameStates.RecoveredVessel.ExtractedPartNodes); //reset the BP KCTGameStates.RecoveredVessel.BuildPoints = Utilities.GetBuildTime(KCTGameStates.RecoveredVessel.ExtractedPartNodes); KCTGameStates.RecoveredVessel.IntegrationPoints = MathParser.ParseIntegrationTimeFormula(KCTGameStates.RecoveredVessel); } if (KCTGameStates.RecoveredVessel.Type == BuildListVessel.ListType.VAB) { KCTGameStates.ActiveKSC.VABWarehouse.Add(KCTGameStates.RecoveredVessel); } else { KCTGameStates.ActiveKSC.SPHWarehouse.Add(KCTGameStates.RecoveredVessel); } KCTGameStates.ActiveKSC.Recon_Rollout.Add(new ReconRollout(KCTGameStates.RecoveredVessel, ReconRollout.RolloutReconType.Recovery, KCTGameStates.RecoveredVessel.Id.ToString())); KCTGameStates.RecoveredVessel = null; } } }
private void SYInventoryApplied() { KCTDebug.Log("Inventory was applied. Recalculating."); if (HighLogic.LoadedSceneIsEditor) { KerbalConstructionTime.Instance.IsEditorRecalcuationRequired = true; } }
public void FacilityDestroyed(DestructibleBuilding facility) { if (facility.id.Contains("LaunchPad")) { KCTDebug.Log("LaunchPad was damaged."); KCTGameStates.ActiveKSC.ActiveLPInstance.RefreshDestructionNode(); } }
public void OnLoadStart() { KCTDebug.Log("OnLoad Started"); OnLoadCalled = true; OnLoadFinished = false; timer = 0; AlertFired = false; }
public void LoadFromFile(string filePath) { KCTDebug.Log("Loading a preset from " + filePath); presetFileLocation = filePath; ConfigNode node = ConfigNode.Load(filePath); this.FromConfigNode(node.GetNode("KCT_Preset")); //.GetNode("KCT_Preset") }
internal T GetMember <T>(string name) { MemberInfo member = _menu.GetType().GetMember(name, BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.FlattenHierarchy)?.FirstOrDefault(); if (member == null) { KCTDebug.Log($"Member was null when trying to find '{name}'", true); return(default);