public static double ParseBuildRateFormula(KCT_BuildListVessel.ListType type, int index, KCT_KSC KSC, bool UpgradedRates = false) { //N = num upgrades, I = rate index, L = VAB/SPH upgrade level, R = R&D level int level = 0, upgrades = 0; Dictionary <string, string> variables = new Dictionary <string, string>(); if (type == KCT_BuildListVessel.ListType.VAB) { level = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.VehicleAssemblyBuilding); if (KSC.VABUpgrades.Count > index) { upgrades = KSC.VABUpgrades[index]; } } else if (type == KCT_BuildListVessel.ListType.SPH) { level = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.SpaceplaneHangar); if (KSC.SPHUpgrades.Count > index) { upgrades = KSC.SPHUpgrades[index]; } } if (UpgradedRates) { upgrades++; } variables.Add("L", level.ToString()); variables.Add("N", upgrades.ToString()); variables.Add("I", index.ToString()); variables.Add("R", KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.ResearchAndDevelopment).ToString()); return(GetStandardFormulaValue("BuildRate", variables)); }
public static double GetBuildRate(int index, KCT_BuildListVessel.ListType type) { double ret = 0; if (type == KCT_BuildListVessel.ListType.VAB) { if (KCT_GameStates.VABUpgrades.Count - 1 >= index) { ret = KCT_GameStates.VABUpgrades[index] * (index + 1) * 0.05; if (index == 0) { ret += 0.1; } } } else if (type == KCT_BuildListVessel.ListType.SPH) { if (KCT_GameStates.SPHUpgrades.Count - 1 >= index) { ret = KCT_GameStates.SPHUpgrades[index] * (index + 1) * 0.05; if (index == 0) { ret += 0.1; } } } else if (type == KCT_BuildListVessel.ListType.TechNode) { ret = Math.Pow(2, KCT_GameStates.RDUpgrades[1] + 1) / 86400.0; } return(ret); }
//private ProtoVessel recovered; public KCT_BuildListVessel(ProtoVessel pvessel, ConfigNode vesselNode, KCT_BuildListVessel.ListType listType = ListType.None) //For recovered vessels { id = Guid.NewGuid(); shipName = pvessel.vesselName; shipNode = vesselNode; if (listType != ListType.None) { this.type = listType; } cost = KCT_Utilities.GetTotalVesselCost(shipNode); emptyCost = KCT_Utilities.GetTotalVesselCost(shipNode, false); TotalMass = 0; emptyMass = 0; HashSet <int> stages = new HashSet <int>(); //for (int i = vessel.protoVessel.protoPartSnapshots.Count - 1; i >= 0; i--) //{ // ProtoPartSnapshot p = vessel.protoVessel.protoPartSnapshots[i]; foreach (ProtoPartSnapshot p in pvessel.protoPartSnapshots) { stages.Add(p.inverseStageIndex); if (p.partPrefab != null && p.partPrefab.Modules.Contains <LaunchClamp>()) { continue; } TotalMass += p.mass; emptyMass += p.mass; //for (int i1 = p.resources.Count - 1; i1 >= 0; i1--) //{ // ProtoPartResourceSnapshot rsc = p.resources[i1]; foreach (ProtoPartResourceSnapshot rsc in p.resources) { PartResourceDefinition def = PartResourceLibrary.Instance.GetDefinition(rsc.resourceName); if (def != null) { TotalMass += def.density * (float)rsc.amount; } } } cannotEarnScience = true; numStages = stages.Count; // FIXME ignore stageable part count and cost - it'll be fixed when we put this back in the editor. buildPoints = KCT_Utilities.GetBuildTime(shipNode.GetNodes("PART").ToList()); flag = HighLogic.CurrentGame.flagURL; progress = buildPoints; DistanceFromKSC = 0; // (float)SpaceCenter.Instance.GreatCircleDistance(SpaceCenter.Instance.cb.GetRelSurfaceNVector(vessel.latitude, vessel.longitude)); rushBuildClicks = 0; }
public static double ParseBuildRateFormula(KCT_BuildListVessel.ListType type, int index, KCT_KSC KSC, bool UpgradedRates = false) { //N = num upgrades, I = rate index, L = VAB/SPH upgrade level, R = R&D level int level = 0, upgrades = 0, levelMax = 0; Dictionary <string, string> variables = new Dictionary <string, string>(); if (type == KCT_BuildListVessel.ListType.VAB) { level = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.VehicleAssemblyBuilding); levelMax = KCT_Utilities.BuildingUpgradeMaxLevel(SpaceCenterFacility.VehicleAssemblyBuilding); if (KSC.VABUpgrades.Count > index) { upgrades = KSC.VABUpgrades[index]; } } else if (type == KCT_BuildListVessel.ListType.SPH) { level = KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.SpaceplaneHangar); levelMax = KCT_Utilities.BuildingUpgradeMaxLevel(SpaceCenterFacility.SpaceplaneHangar); if (KSC.SPHUpgrades.Count > index) { upgrades = KSC.SPHUpgrades[index]; } } if (UpgradedRates) { upgrades++; } variables.Add("L", level.ToString()); variables.Add("LM", level.ToString()); variables.Add("N", upgrades.ToString()); variables.Add("I", index.ToString()); variables.Add("R", KCT_Utilities.BuildingUpgradeLevel(SpaceCenterFacility.ResearchAndDevelopment).ToString()); //int numNodes = RDController.Instance != null ? RDController.Instance.nodes.FindAll(n => n.IsResearched).Count : 0; int numNodes = 0; if (ResearchAndDevelopment.Instance != null) { numNodes = ResearchAndDevelopment.Instance.snapshot.GetData().GetNodes("Tech").Length; } variables.Add("S", numNodes.ToString()); AddCrewVariables(variables); return(GetStandardFormulaValue("BuildRate", variables)); }
private ConfigNode FromInFlightVessel(Vessel VesselToSave, KCT_BuildListVessel.ListType listType) { //This code is taken from InflightShipSave by Claw, using the CC-BY-NC-SA license. //This code thus is licensed under the same license, despite the GPLv3 license covering original KCT code //See https://github.com/ClawKSP/InflightShipSave string ShipName = VesselToSave.vesselName; // Debug.LogWarning("Saving: " + ShipName); ShipConstruct ConstructToSave = new ShipConstruct(ShipName, "", VesselToSave.parts[0]); Quaternion OriginalRotation = VesselToSave.vesselTransform.rotation; Vector3 OriginalPosition = VesselToSave.vesselTransform.position; if (listType == ListType.SPH) { VesselToSave.SetRotation(new Quaternion((float)Math.Sqrt(0.5), 0, 0, (float)Math.Sqrt(0.5))); } else { VesselToSave.SetRotation(new Quaternion(0, 0, 0, 1)); } Vector3 ShipSize = ShipConstruction.CalculateCraftSize(ConstructToSave); VesselToSave.SetPosition(new Vector3(0, Math.Min(ShipSize.y + 2, 30), 0)); //Try to limit the max height we put the ship at. 60 is good for the VA but I don't know about the SPH. Lets be conservative with 30 ConfigNode CN = new ConfigNode("ShipConstruct"); CN = ConstructToSave.SaveShip(); SanitizeShipNode(CN); // These are actually needed, do not comment them out VesselToSave.SetRotation(OriginalRotation); VesselToSave.SetPosition(OriginalPosition); //End of Claw's code. Thanks Claw! return(CN); }
public static double ParseBuildRateFormula(KCT_BuildListVessel.ListType type, int index, KCT_KSC KSC, bool UpgradedRates = false) { return(ParseBuildRateFormula(type, index, KSC, UpgradedRates ? 1 : 0)); }