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 KCT_Recon_Rollout(KCT_BuildListVessel vessel, RolloutReconType type, string id) { RRType = type; associatedID = id; //BP = vessel.GetTotalMass() * KCT_GameStates.timeSettings.ReconditioningEffect * KCT_GameStates.timeSettings.OverallMultiplier; //1 day per 50 tons (default) * overall multiplier BP = KCT_MathParsing.GetStandardFormulaValue("Reconditioning", new Dictionary<string, string>() {{"M", vessel.GetTotalMass().ToString()}, {"O", KCT_GameStates.timeSettings.OverallMultiplier.ToString()}, {"E", KCT_GameStates.timeSettings.ReconditioningEffect.ToString()}, {"X", KCT_GameStates.timeSettings.MaxReconditioning.ToString()}}); //if (BP > KCT_GameStates.timeSettings.MaxReconditioning) BP = KCT_GameStates.timeSettings.MaxReconditioning; progress = 0; if (type == RolloutReconType.Reconditioning) { BP *= (1 - KCT_GameStates.timeSettings.RolloutReconSplit); name = "LaunchPad Reconditioning"; } else if (type == RolloutReconType.Rollout) { BP *= KCT_GameStates.timeSettings.RolloutReconSplit; name = "Vessel Rollout"; } else if (type == RolloutReconType.Rollback) { BP *= KCT_GameStates.timeSettings.RolloutReconSplit; progress = BP; name = "Vessel Rollback"; } else if (type == RolloutReconType.Recovery) { BP *= KCT_GameStates.timeSettings.RolloutReconSplit; name = "Vessel Recovery"; double maxDist = SpaceCenter.Instance.cb.Radius * Math.PI; BP += BP * (vessel.DistanceFromKSC / maxDist); } }
public static double ParseReconditioningFormula(KCT_BuildListVessel vessel, bool isReconditioning) { Dictionary <string, string> variables = new Dictionary <string, string>(); double loadedMass, emptyMass, loadedCost, emptyCost; loadedCost = vessel.cost; emptyCost = vessel.emptyCost; loadedMass = vessel.GetTotalMass(); emptyMass = vessel.emptyMass; int EditorLevel = 0, LaunchSiteLvl = 0, EditorMax = 0, LaunchSiteMax = 0; int isVABVessel = 0; if (vessel.type == KCT_BuildListVessel.ListType.VAB) { EditorLevel = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.VehicleAssemblyBuilding); LaunchSiteLvl = KCT_GameStates.ActiveKSC.ActiveLPInstance.level;//KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.LaunchPad); EditorMax = KCT_Utilities.BuildingUpgradeMaxLevel(SpaceCenterFacility.VehicleAssemblyBuilding); LaunchSiteMax = KCT_Utilities.BuildingUpgradeMaxLevel(SpaceCenterFacility.LaunchPad); isVABVessel = 1; } else { EditorLevel = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.SpaceplaneHangar); LaunchSiteLvl = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.Runway); EditorMax = KCT_Utilities.BuildingUpgradeMaxLevel(SpaceCenterFacility.SpaceplaneHangar); LaunchSiteMax = KCT_Utilities.BuildingUpgradeMaxLevel(SpaceCenterFacility.Runway); } double BP = vessel.buildPoints; double OverallMult = KCT_PresetManager.Instance.ActivePreset.timeSettings.OverallMultiplier; double ReconEffect = KCT_PresetManager.Instance.ActivePreset.timeSettings.ReconditioningEffect; double MaxRecon = KCT_PresetManager.Instance.ActivePreset.timeSettings.MaxReconditioning; variables.Add("M", loadedMass.ToString()); variables.Add("m", emptyMass.ToString()); variables.Add("C", loadedCost.ToString()); variables.Add("c", emptyCost.ToString()); variables.Add("VAB", isVABVessel.ToString()); variables.Add("BP", BP.ToString()); variables.Add("L", LaunchSiteLvl.ToString()); variables.Add("LM", LaunchSiteMax.ToString()); variables.Add("EL", EditorLevel.ToString()); variables.Add("ELM", EditorMax.ToString()); variables.Add("O", OverallMult.ToString()); variables.Add("E", ReconEffect.ToString()); variables.Add("X", MaxRecon.ToString()); int isRecon = isReconditioning ? 1 : 0; variables.Add("RE", isRecon.ToString()); variables.Add("S", KCT_PresetManager.Instance.ActivePreset.timeSettings.RolloutReconSplit.ToString()); variables.Add("SN", vessel.numStages.ToString()); variables.Add("SP", vessel.numStageParts.ToString()); variables.Add("SC", vessel.stagePartCost.ToString()); AddCrewVariables(variables); return(GetStandardFormulaValue("Reconditioning", variables)); }
public static double ParseRolloutCostFormula(KCT_BuildListVessel vessel) { if (!KCT_PresetManager.Instance.ActivePreset.generalSettings.Enabled || !KCT_PresetManager.Instance.ActivePreset.generalSettings.ReconditioningTimes) { return(0); } double loadedMass, emptyMass, loadedCost, emptyCost; loadedCost = vessel.GetTotalCost(); emptyCost = vessel.emptyCost; loadedMass = vessel.GetTotalMass(); emptyMass = vessel.emptyMass; int EditorLevel = 0, LaunchSiteLvl = 0, EditorMax = 0, LaunchSiteMax = 0; int isVABVessel = 0; if (vessel.type == KCT_BuildListVessel.ListType.None) { vessel.FindTypeFromLists(); } if (vessel.type == KCT_BuildListVessel.ListType.VAB) { EditorLevel = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.VehicleAssemblyBuilding); LaunchSiteLvl = KCT_GameStates.ActiveKSC.ActiveLPInstance.level;//KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.LaunchPad); EditorMax = KCT_Utilities.BuildingUpgradeMaxLevel(SpaceCenterFacility.VehicleAssemblyBuilding); LaunchSiteMax = KCT_Utilities.BuildingUpgradeMaxLevel(SpaceCenterFacility.LaunchPad); isVABVessel = 1; } else if (vessel.type == KCT_BuildListVessel.ListType.SPH) { EditorLevel = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.SpaceplaneHangar); LaunchSiteLvl = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.Runway); EditorMax = KCT_Utilities.BuildingUpgradeMaxLevel(SpaceCenterFacility.SpaceplaneHangar); LaunchSiteMax = KCT_Utilities.BuildingUpgradeMaxLevel(SpaceCenterFacility.Runway); } double BP = vessel.buildPoints; Dictionary <string, string> variables = new Dictionary <string, string>(); variables.Add("M", loadedMass.ToString()); variables.Add("m", emptyMass.ToString()); variables.Add("C", loadedCost.ToString()); variables.Add("c", emptyCost.ToString()); variables.Add("VAB", isVABVessel.ToString()); variables.Add("BP", BP.ToString()); variables.Add("L", LaunchSiteLvl.ToString()); variables.Add("LM", LaunchSiteMax.ToString()); variables.Add("EL", EditorLevel.ToString()); variables.Add("ELM", EditorMax.ToString()); variables.Add("SN", vessel.numStages.ToString()); variables.Add("SP", vessel.numStageParts.ToString()); variables.Add("SC", vessel.stagePartCost.ToString()); AddCrewVariables(variables); return(GetStandardFormulaValue("RolloutCost", variables)); }
private static Dictionary <string, string> GetIntegrationRolloutVariables(KCT_BuildListVessel vessel) { double loadedMass, emptyMass, loadedCost, emptyCost; loadedCost = vessel.cost; emptyCost = vessel.emptyCost; loadedMass = vessel.GetTotalMass(); emptyMass = vessel.emptyMass; int EditorLevel = 0, LaunchSiteLvl = 0, EditorMax = 0, LaunchSiteMax = 0; int isVABVessel = 0; if (vessel.type == KCT_BuildListVessel.ListType.None) { vessel.FindTypeFromLists(); } if (vessel.type == KCT_BuildListVessel.ListType.VAB) { EditorLevel = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.VehicleAssemblyBuilding); LaunchSiteLvl = KCT_GameStates.ActiveKSC.ActiveLPInstance.level;//KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.LaunchPad); EditorMax = KCT_Utilities.BuildingUpgradeMaxLevel(SpaceCenterFacility.VehicleAssemblyBuilding); LaunchSiteMax = KCT_Utilities.BuildingUpgradeMaxLevel(SpaceCenterFacility.LaunchPad); isVABVessel = 1; } else if (vessel.type == KCT_BuildListVessel.ListType.SPH) { EditorLevel = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.SpaceplaneHangar); LaunchSiteLvl = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.Runway); EditorMax = KCT_Utilities.BuildingUpgradeMaxLevel(SpaceCenterFacility.SpaceplaneHangar); LaunchSiteMax = KCT_Utilities.BuildingUpgradeMaxLevel(SpaceCenterFacility.Runway); } double BP = vessel.buildPoints; double OverallMult = KCT_PresetManager.Instance.ActivePreset.timeSettings.OverallMultiplier; Dictionary <string, string> variables = new Dictionary <string, string>(); variables.Add("M", loadedMass.ToString()); variables.Add("m", emptyMass.ToString()); variables.Add("C", loadedCost.ToString()); variables.Add("c", emptyCost.ToString()); variables.Add("VAB", isVABVessel.ToString()); variables.Add("E", vessel.effectiveCost.ToString()); variables.Add("BP", BP.ToString()); variables.Add("L", LaunchSiteLvl.ToString()); variables.Add("LM", LaunchSiteMax.ToString()); variables.Add("EL", EditorLevel.ToString()); variables.Add("ELM", EditorMax.ToString()); variables.Add("O", OverallMult.ToString()); variables.Add("SN", vessel.numStages.ToString()); variables.Add("SP", vessel.numStageParts.ToString()); variables.Add("SC", vessel.stagePartCost.ToString()); AddCrewVariables(variables); return(variables); }
public static double ParseRolloutCostFormula(KCT_BuildListVessel vessel) { double loadedMass, emptyMass, loadedCost, emptyCost; loadedCost = vessel.GetTotalCost(); emptyCost = vessel.emptyCost; loadedMass = vessel.GetTotalMass(); emptyMass = vessel.emptyMass; int EditorLevel = 0, LaunchSiteLvl = 0; int isVABVessel = 0; if (vessel.type == KCT_BuildListVessel.ListType.None) { vessel.FindTypeFromLists(); } if (vessel.type == KCT_BuildListVessel.ListType.VAB) { EditorLevel = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.VehicleAssemblyBuilding); LaunchSiteLvl = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.LaunchPad); isVABVessel = 1; } else if (vessel.type == KCT_BuildListVessel.ListType.SPH) { EditorLevel = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.SpaceplaneHangar); LaunchSiteLvl = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.Runway); } double BP = vessel.buildPoints; Dictionary <string, string> variables = new Dictionary <string, string>(); variables.Add("M", loadedMass.ToString()); variables.Add("m", emptyMass.ToString()); variables.Add("C", loadedCost.ToString()); variables.Add("c", emptyCost.ToString()); variables.Add("VAB", isVABVessel.ToString()); variables.Add("BP", BP.ToString()); variables.Add("L", LaunchSiteLvl.ToString()); variables.Add("EL", EditorLevel.ToString()); return(GetStandardFormulaValue("RolloutCost", variables)); }
public KCT_Recon_Rollout(KCT_BuildListVessel vessel, RolloutReconType type, string id) { RRType = type; associatedID = id; //BP = vessel.GetTotalMass() * KCT_GameStates.timeSettings.ReconditioningEffect * KCT_GameStates.timeSettings.OverallMultiplier; //1 day per 50 tons (default) * overall multiplier BP = KCT_MathParsing.GetStandardFormulaValue("Reconditioning", new Dictionary <string, string>() { { "M", vessel.GetTotalMass().ToString() }, { "O", KCT_GameStates.timeSettings.OverallMultiplier.ToString() }, { "E", KCT_GameStates.timeSettings.ReconditioningEffect.ToString() }, { "X", KCT_GameStates.timeSettings.MaxReconditioning.ToString() } }); //if (BP > KCT_GameStates.timeSettings.MaxReconditioning) BP = KCT_GameStates.timeSettings.MaxReconditioning; progress = 0; if (type == RolloutReconType.Reconditioning) { BP *= (1 - KCT_GameStates.timeSettings.RolloutReconSplit); name = "LaunchPad Reconditioning"; } else if (type == RolloutReconType.Rollout) { BP *= KCT_GameStates.timeSettings.RolloutReconSplit; name = "Vessel Rollout"; } else if (type == RolloutReconType.Rollback) { BP *= KCT_GameStates.timeSettings.RolloutReconSplit; progress = BP; name = "Vessel Rollback"; } else if (type == RolloutReconType.Recovery) { BP *= KCT_GameStates.timeSettings.RolloutReconSplit; name = "Vessel Recovery"; double maxDist = SpaceCenter.Instance.cb.Radius * Math.PI; BP += BP * (vessel.DistanceFromKSC / maxDist); } }
public static double ParseRolloutCostFormula(KCT_BuildListVessel vessel) { if (!KCT_PresetManager.Instance.ActivePreset.generalSettings.Enabled || !KCT_PresetManager.Instance.ActivePreset.generalSettings.ReconditioningTimes) return 0; double loadedMass, emptyMass, loadedCost, emptyCost; loadedCost = vessel.GetTotalCost(); emptyCost = vessel.emptyCost; loadedMass = vessel.GetTotalMass(); emptyMass = vessel.emptyMass; int EditorLevel = 0, LaunchSiteLvl = 0; int isVABVessel = 0; if (vessel.type == KCT_BuildListVessel.ListType.None) vessel.FindTypeFromLists(); if (vessel.type == KCT_BuildListVessel.ListType.VAB) { EditorLevel = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.VehicleAssemblyBuilding); LaunchSiteLvl = KCT_GameStates.ActiveKSC.ActiveLPInstance.level;//KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.LaunchPad); isVABVessel = 1; } else if (vessel.type == KCT_BuildListVessel.ListType.SPH) { EditorLevel = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.SpaceplaneHangar); LaunchSiteLvl = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.Runway); } double BP = vessel.buildPoints; Dictionary<string, string> variables = new Dictionary<string, string>(); variables.Add("M", loadedMass.ToString()); variables.Add("m", emptyMass.ToString()); variables.Add("C", loadedCost.ToString()); variables.Add("c", emptyCost.ToString()); variables.Add("VAB", isVABVessel.ToString()); variables.Add("BP", BP.ToString()); variables.Add("L", LaunchSiteLvl.ToString()); variables.Add("EL", EditorLevel.ToString()); AddCrewVariables(variables); return GetStandardFormulaValue("RolloutCost", variables); }
public static double ParseReconditioningFormula(KCT_BuildListVessel vessel, bool isReconditioning) { // new Dictionary<string, string>() {{"M", vessel.GetTotalMass().ToString()}, {"O", KCT_PresetManager.Instance.ActivePreset.timeSettings.OverallMultiplier.ToString()}, // {"E", KCT_PresetManager.Instance.ActivePreset.timeSettings.ReconditioningEffect.ToString()}, {"X", KCT_PresetManager.Instance.ActivePreset.timeSettings.MaxReconditioning.ToString()}}); Dictionary<string, string> variables = new Dictionary<string, string>(); double loadedMass, emptyMass, loadedCost, emptyCost; loadedCost = vessel.GetTotalCost(); emptyCost = vessel.emptyCost; loadedMass = vessel.GetTotalMass(); emptyMass = vessel.emptyMass; int EditorLevel = 0, LaunchSiteLvl = 0; int isVABVessel = 0; if (vessel.type == KCT_BuildListVessel.ListType.VAB) { EditorLevel = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.VehicleAssemblyBuilding); LaunchSiteLvl = KCT_GameStates.ActiveKSC.ActiveLPInstance.level;//KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.LaunchPad); isVABVessel = 1; } else { EditorLevel = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.SpaceplaneHangar); LaunchSiteLvl = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.Runway); } double BP = vessel.buildPoints; double OverallMult = KCT_PresetManager.Instance.ActivePreset.timeSettings.OverallMultiplier; double ReconEffect = KCT_PresetManager.Instance.ActivePreset.timeSettings.ReconditioningEffect; double MaxRecon = KCT_PresetManager.Instance.ActivePreset.timeSettings.MaxReconditioning; variables.Add("M", loadedMass.ToString()); variables.Add("m", emptyMass.ToString()); variables.Add("C", loadedCost.ToString()); variables.Add("c", emptyCost.ToString()); variables.Add("VAB", isVABVessel.ToString()); variables.Add("BP", BP.ToString()); variables.Add("L", LaunchSiteLvl.ToString()); variables.Add("EL", EditorLevel.ToString()); variables.Add("O", OverallMult.ToString()); variables.Add("E", ReconEffect.ToString()); variables.Add("X", MaxRecon.ToString()); int isRecon = isReconditioning ? 1 : 0; variables.Add("RE", isRecon.ToString()); variables.Add("S", KCT_PresetManager.Instance.ActivePreset.timeSettings.RolloutReconSplit.ToString()); AddCrewVariables(variables); return GetStandardFormulaValue("Reconditioning", variables); }
public static KCT_BuildListVessel AddVesselToBuildList(KCT_BuildListVessel blv, Dictionary<String, int> inventory) { if (CurrentGameIsCareer()) { //Check upgrades //First, mass limit bool passed = true; string failedReason = ""; if (blv.type == KCT_BuildListVessel.ListType.VAB) { if (blv.GetTotalMass() > GameVariables.Instance.GetCraftMassLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.LaunchPad))) { passed = false; failedReason = "Mass limit exceeded!"; } if (blv.ExtractedPartNodes.Count > GameVariables.Instance.GetPartCountLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.VehicleAssemblyBuilding))) { passed = false; failedReason = "Part Count limit exceeded!"; } if (HighLogic.LoadedSceneIsEditor) { PreFlightTests.CraftWithinSizeLimits sizeCheck = new PreFlightTests.CraftWithinSizeLimits(EditorLogic.fetch.ship, SpaceCenterFacility.LaunchPad, GameVariables.Instance.GetCraftSizeLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.LaunchPad))); if (!sizeCheck.Test()) { passed = false; failedReason = "Size limits exceeded!"; } } } else if (blv.type == KCT_BuildListVessel.ListType.SPH) { if (blv.GetTotalMass() > GameVariables.Instance.GetCraftMassLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.Runway))) { passed = false; failedReason = "Mass limit exceeded!"; } if (blv.ExtractedPartNodes.Count > GameVariables.Instance.GetPartCountLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.SpaceplaneHangar))) { passed = false; failedReason = "Part Count limit exceeded!"; } if (HighLogic.LoadedSceneIsEditor) { PreFlightTests.CraftWithinSizeLimits sizeCheck = new PreFlightTests.CraftWithinSizeLimits(EditorLogic.fetch.ship, SpaceCenterFacility.Runway, GameVariables.Instance.GetCraftSizeLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.Runway))); if (!sizeCheck.Test()) { passed = false; failedReason = "Size limits exceeded!"; } } } if (!passed) { ScreenMessages.PostScreenMessage("Did not pass editor checks!", 4.0f, ScreenMessageStyle.UPPER_CENTER); ScreenMessages.PostScreenMessage(failedReason, 4.0f, ScreenMessageStyle.UPPER_CENTER); return null; } double totalCost = blv.GetTotalCost(); double prevFunds = Funding.Instance.Funds; //double newFunds = SpendFunds(totalCost, TransactionReasons.VesselRollout); if (totalCost > prevFunds) { KCTDebug.Log("Tried to add " + blv.shipName + " to build list but not enough funds."); KCTDebug.Log("Vessel cost: " + GetTotalVesselCost(blv.shipNode) + ", Current funds: " + prevFunds); var msg = new ScreenMessage("Not Enough Funds To Build!", 4.0f, ScreenMessageStyle.UPPER_CENTER); ScreenMessages.PostScreenMessage(msg, true); return null; } else { SpendFunds(totalCost, TransactionReasons.VesselRollout); } } string type = ""; if (blv.type == KCT_BuildListVessel.ListType.VAB) { KCT_GameStates.ActiveKSC.VABList.Add(blv); type = "VAB"; } else if (blv.type == KCT_BuildListVessel.ListType.SPH) { KCT_GameStates.ActiveKSC.SPHList.Add(blv); type = "SPH"; } if (inventory.Count > 0) { foreach (ConfigNode p in blv.ExtractedPartNodes) { // if (KCT_Utilities.RemovePartFromInventory(p, inventory)) { if (!KCT_Utilities.PartIsProcedural(p)) AddToDict(blv.InventoryParts, PartNameFromNode(p) + GetTweakScaleSize(p), KCT_Utilities.RemovePartFromInventory(p, inventory)); // blv.InventoryParts.Add(PartNameFromNode(p) + GetTweakScaleSize(p), 1); else AddToDict(blv.InventoryParts, PartNameFromNode(p), KCT_Utilities.RemovePartFromInventory(p, inventory)); // blv.InventoryParts.Add(PartNameFromNode(p), (int)(1000 * GetPartCostFromNode(p, false))); } } } KCTDebug.Log("Added " + blv.shipName + " to " + type + " build list at KSC "+KCT_GameStates.ActiveKSC.KSCName+". Cost: "+blv.cost); //KCTDebug.Log("Cost Breakdown (total, parts, fuel): " + blv.totalCost + ", " + blv.dryCost + ", " + blv.fuelCost); var message = new ScreenMessage("[KCT] Added " + blv.shipName + " to " + type + " build list.", 4.0f, ScreenMessageStyle.UPPER_CENTER); ScreenMessages.PostScreenMessage(message, true); return blv; }