public bool CanLaunchVessel(KCT_BuildListVessel vessel, out string reason) { if (vessel == null) { reason = "No vessel"; return(false); } double mass = vessel.GetTotalMass(); if (mass > MaxMass) { reason = $"mass ({mass:0.#}t) is higher than the allowed {MaxMass:0.#}"; return(false); } ShipTemplate template = new ShipTemplate(); template.LoadShip(vessel.shipNode); Vector3 dimensions = ShipConstruction.CalculateCraftSize(template); if (dimensions.x > MaxSize.x | dimensions.y > MaxSize.y | dimensions.z > MaxSize.z) { reason = $"size ({dimensions.x:0.#} x {dimensions.y:0.#} x {dimensions.z:0.#} m) is more than the allowed {MaxSize.x:0.#} x {MaxSize.y:0.#} x {MaxSize.z:0.#} m"; return(false); } reason = null; return(true); }
public List <string> MeetsFacilityRequirements(bool highestFacility = true) { List <string> failedReasons = new List <string>(); if (!Utilities.CurrentGameIsCareer()) { return(failedReasons); } ShipTemplate template = new ShipTemplate(); template.LoadShip(ShipNode); if (Type == ListType.VAB) { KCT_LaunchPad selectedPad = highestFacility ? KCTGameStates.ActiveKSC.GetHighestLevelLaunchPad() : KCTGameStates.ActiveKSC.ActiveLPInstance; float launchpadNormalizedLevel = 1f * selectedPad.level / KCTGameStates.BuildingMaxLevelCache["LaunchPad"]; double totalMass = GetTotalMass(); if (totalMass > GameVariables.Instance.GetCraftMassLimit(launchpadNormalizedLevel, true)) { failedReasons.Add($"Mass limit exceeded, currently at {totalMass:N} tons"); } if (ExtractedPartNodes.Count > GameVariables.Instance.GetPartCountLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.VehicleAssemblyBuilding), true)) { failedReasons.Add("Part Count limit exceeded"); } CraftWithinSizeLimits sizeCheck = new CraftWithinSizeLimits(template, SpaceCenterFacility.LaunchPad, GameVariables.Instance.GetCraftSizeLimit(launchpadNormalizedLevel, true)); if (!sizeCheck.Test()) { failedReasons.Add("Size limits exceeded"); } } else if (Type == ListType.SPH) { double totalMass = GetTotalMass(); if (totalMass > GameVariables.Instance.GetCraftMassLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.Runway), false)) { failedReasons.Add($"Mass limit exceeded, currently at {totalMass:N} tons"); } if (ExtractedPartNodes.Count > GameVariables.Instance.GetPartCountLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.SpaceplaneHangar), false)) { failedReasons.Add("Part Count limit exceeded"); } CraftWithinSizeLimits sizeCheck = new CraftWithinSizeLimits(template, SpaceCenterFacility.Runway, GameVariables.Instance.GetCraftSizeLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.Runway), false)); if (!sizeCheck.Test()) { failedReasons.Add("Size limits exceeded"); } } return(failedReasons); }
public Vector3 GetShipSize() { if (ShipSize.sqrMagnitude > 0) { return(ShipSize); } ShipTemplate template = new ShipTemplate(); template.LoadShip(ShipNode); ShipSize = template.GetShipSize(); return(ShipSize); }
internal static ShipTemplate LoadSubAssembly(string subassemblyName) { if (ShipConstruction.SubassemblyExists(subassemblyName)) { ConfigNode node = ConfigNode.Load(vehiclesPath + "/" + subassemblyName + ".craft"); ShipTemplate subassembly = new ShipTemplate(); subassembly.LoadShip(node); return(subassembly); } else { klvGUI.GUIUtilities.Log("Could not find subassembly file: " + subassemblyName); return(null); } }
public List <string> MeetsFacilityRequirements() { List <string> failedReasons = new List <string>(); if (!KCT_Utilities.CurrentGameIsCareer()) { return(failedReasons); } ShipTemplate template = new ShipTemplate(); template.LoadShip(shipNode); if (this.type == KCT_BuildListVessel.ListType.VAB) { if (this.GetTotalMass() > GameVariables.Instance.GetCraftMassLimit(KCT_GameStates.ActiveKSC.ActiveLPInstance.level / 2.0F)) { failedReasons.Add("Mass limit exceeded"); } if (this.ExtractedPartNodes.Count > GameVariables.Instance.GetPartCountLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.VehicleAssemblyBuilding))) { failedReasons.Add("Part Count limit exceeded"); } PreFlightTests.CraftWithinSizeLimits sizeCheck = new PreFlightTests.CraftWithinSizeLimits(template, SpaceCenterFacility.LaunchPad, GameVariables.Instance.GetCraftSizeLimit(KCT_GameStates.ActiveKSC.ActiveLPInstance.level / 2.0F)); if (!sizeCheck.Test()) { failedReasons.Add("Size limits exceeded"); } } else if (this.type == KCT_BuildListVessel.ListType.SPH) { if (this.GetTotalMass() > GameVariables.Instance.GetCraftMassLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.Runway))) { failedReasons.Add("Mass limit exceeded"); } if (this.ExtractedPartNodes.Count > GameVariables.Instance.GetPartCountLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.SpaceplaneHangar))) { failedReasons.Add("Part Count limit exceeded"); } PreFlightTests.CraftWithinSizeLimits sizeCheck = new PreFlightTests.CraftWithinSizeLimits(template, SpaceCenterFacility.Runway, GameVariables.Instance.GetCraftSizeLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.Runway))); if (!sizeCheck.Test()) { failedReasons.Add("Size limits exceeded"); } } return(failedReasons); }
protected void load_craft(string load_type, bool force = false) { if (CraftData.selected_craft != null) { CraftData craft = CraftData.selected_craft; if (craft.missing_parts && !load_type.Contains("ignore_missing") && (load_type == "load" || load_type == "merge" || load_type == "subload")) { CraftManager.main_ui.load_craft_with_missing_parts_dialog(craft, load_type); } else { if (load_type.Contains("ignore_missing")) { load_type = load_type.Replace("_ignore_missing", ""); } if (load_type == "load") { if (CraftData.loaded_craft_saved || force) { EditorLogic.LoadShipFromFile(craft.path); CraftManager.main_ui.hide(); } else { CraftManager.main_ui.load_craft_confirm_dialog(() => { load_craft(load_type, true); }); } } else if (load_type == "merge") { ShipConstruct ship = new ShipConstruct(); ship.LoadShip(ConfigNode.Load(craft.path)); EditorLogic.fetch.SpawnConstruct(ship); CraftManager.main_ui.hide(); } else if (load_type == "subload") { ShipTemplate subassembly = new ShipTemplate(); subassembly.LoadShip(ConfigNode.Load(craft.path)); EditorLogic.fetch.SpawnTemplate(subassembly); CraftManager.main_ui.hide(); } else if (load_type == "download") { download(true, false); } else if (load_type == "update") { download(true, true); } else if (load_type == "dl_load") { download(true, false, load_craft); } else if (load_type == "update_load") { download(true, true, load_craft); } else if (load_type == "dl_load_no_save") { if (CraftData.loaded_craft_saved || force) { download(false); CraftManager.main_ui.hide(); } else { CraftManager.main_ui.load_craft_confirm_dialog(() => { load_craft(load_type, true); }); } } else if (load_type == "upload") { craft.upload_data.post(); } } } }
public List<string> MeetsFacilityRequirements() { List<string> failedReasons = new List<string>(); if (!KCT_Utilities.CurrentGameIsCareer()) return failedReasons; ShipTemplate template = new ShipTemplate(); template.LoadShip(shipNode); if (this.type == KCT_BuildListVessel.ListType.VAB) { if (this.GetTotalMass() > GameVariables.Instance.GetCraftMassLimit(KCT_GameStates.ActiveKSC.ActiveLPInstance.level/2.0F, true)) { failedReasons.Add("Mass limit exceeded"); } if (this.ExtractedPartNodes.Count > GameVariables.Instance.GetPartCountLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.VehicleAssemblyBuilding), true)) { failedReasons.Add("Part Count limit exceeded"); } PreFlightTests.CraftWithinSizeLimits sizeCheck = new PreFlightTests.CraftWithinSizeLimits(template, SpaceCenterFacility.LaunchPad, GameVariables.Instance.GetCraftSizeLimit(KCT_GameStates.ActiveKSC.ActiveLPInstance.level/2.0F, true)); if (!sizeCheck.Test()) { failedReasons.Add("Size limits exceeded"); } } else if (this.type == KCT_BuildListVessel.ListType.SPH) { if (this.GetTotalMass() > GameVariables.Instance.GetCraftMassLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.Runway), false)) { failedReasons.Add("Mass limit exceeded"); } if (this.ExtractedPartNodes.Count > GameVariables.Instance.GetPartCountLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.SpaceplaneHangar), false)) { failedReasons.Add("Part Count limit exceeded"); } PreFlightTests.CraftWithinSizeLimits sizeCheck = new PreFlightTests.CraftWithinSizeLimits(template, SpaceCenterFacility.Runway, GameVariables.Instance.GetCraftSizeLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.Runway), false)); if (!sizeCheck.Test()) { failedReasons.Add("Size limits exceeded"); } } return failedReasons; }