public static TechLimitHeightDiameter[] loadTechLimits(ConfigNode[] nodes) { int len = nodes.Length; TechLimitHeightDiameter[] techLimits = new TechLimitHeightDiameter[len]; for (int i = 0; i < len; i++) { techLimits[i] = new TechLimitHeightDiameter(nodes[i]); } return techLimits; }
public static void updateTechLimits(TechLimitHeightDiameter[] limits, out float maxHeight, out float maxDiameter) { maxHeight = float.PositiveInfinity; maxDiameter = float.PositiveInfinity; if (!SSTUUtils.isResearchGame()) { return; } if (HighLogic.CurrentGame == null) { return; } maxHeight = 0; maxDiameter = 0; foreach (TechLimitHeightDiameter limit in limits) { if (limit.isUnlocked()) { if (limit.maxHeight > maxHeight) { maxHeight = limit.maxHeight; } if (limit.maxDiameter > maxDiameter) { maxDiameter = limit.maxDiameter; } } } }
/// <summary> /// Loads all of the part definitions and values from the stashed config node data /// </summary> private void loadConfigData() { ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData); fuelTypes = FuelTypeData.parseFuelTypeData(node.GetNodes("FUELTYPE")); currentFuelTypeData = Array.Find(fuelTypes, l => l.name == currentFuelType); if (currentFuelTypeData == null) { MonoBehaviour.print("ERROR: Could not locate fuel type for: " + currentFuelType + ". reverting to default fuel type of: " + defaultFuelType); currentFuelType = defaultFuelType; currentFuelTypeData = Array.Find(fuelTypes, l => l.name == currentFuelType); initializedResources = false; } reserveFuelTypeData = FuelTypes.INSTANCE.getFuelTypeData(reserveFuelType); //mandatory nodes, -all- tank types must have these ConfigNode tankUpperNode = node.GetNode("TANKUPPER"); ConfigNode upperTopCapNode = node.GetNode("TANKUPPERTOPCAP"); ConfigNode upperBottomCapNode = node.GetNode("TANKUPPERBOTTOMCAP"); ConfigNode[] limitNodes = node.GetNodes("TECHLIMIT"); ConfigNode rcsNode = node.GetNode("RCS"); ConfigNode[] mountNodes = node.GetNodes("MOUNT"); upperModule = new SingleModelData(tankUpperNode); upperTopCapModule = new SingleModelData(upperTopCapNode); upperBottomCapModule = new SingleModelData(upperBottomCapNode); rcsModule = new SSTUCustomUpperStageRCS(rcsNode); //load mount configs int len = mountNodes.Length; mountModules = new MountModelData[len]; for (int i = 0; i < len; i++) { mountModules[i] = new MountModelData(mountNodes[i]); } currentMountModule = Array.Find(mountModules, l => l.name == currentMount); if (splitTank) { //fields that are only populated by split-tank type upper-stages ConfigNode tankLowerNode = node.GetNode("TANKLOWER"); ConfigNode lowerBottomCapNode = node.GetNode("TANKLOWERBOTTOMCAP"); ConfigNode[] intertankNodes = node.GetNodes("INTERTANK"); lowerModule = new SingleModelData(tankLowerNode); lowerBottomCapModule = new SingleModelData(lowerBottomCapNode); //load intertank configs len = intertankNodes.Length; intertankModules = new SingleModelData[len]; for (int i = 0; i < len; i++) { intertankModules[i] = new SingleModelData(intertankNodes[i]); } currentIntertankModule = Array.Find(intertankModules, l => l.name == currentIntertank); } len = limitNodes.Length; techLimits = new TechLimitHeightDiameter[len]; for (int i = 0; i < len; i++) { techLimits[i] = new TechLimitHeightDiameter(limitNodes[i]); } }
/// <summary> /// Restores SSTUCustomFuelTankPart instances from config node data, and populates the 'currentModule' instances with the currently selected module. /// </summary> private void loadConfigData() { ConfigNode node = SSTUNodeUtils.parseConfigNode(configNodeData); ConfigNode[] tankNodes = node.GetNodes("TANK"); ConfigNode[] mountNodes = node.GetNodes("CAP"); ConfigNode[] fuelNodes = node.GetNodes("FUELTYPE"); ConfigNode[] limitNodes = node.GetNodes("TECHLIMIT"); ConfigNode[] textureNodes = node.GetNodes("TEXTURESET"); int len = tankNodes.Length; mainTankModules = new SingleModelData[len]; for (int i = 0; i < len; i++) { mainTankModules[i] = new SingleModelData(tankNodes[i]); } len = mountNodes.Length; ConfigNode mountNode; List<CustomFuelTankMount> noses = new List<CustomFuelTankMount>(); List<CustomFuelTankMount> mounts = new List<CustomFuelTankMount>(); for (int i = 0; i < len; i++) { mountNode = mountNodes[i]; if (mountNode.GetBoolValue("useForNose", true)) { noses.Add(new CustomFuelTankMount(mountNode, true)); } if (mountNode.GetBoolValue("useForMount", true)) { mounts.Add(new CustomFuelTankMount(mountNode, false)); } } mountModules = mounts.ToArray(); noseModules = noses.ToArray(); len = fuelNodes.Length; fuelTypes = new FuelTypeData[len]; for (int i = 0; i < len; i++) { fuelTypes[i] = new FuelTypeData(fuelNodes[i]); } len = limitNodes.Length; techLimits = new TechLimitHeightDiameter[len]; for (int i = 0; i < len; i++) { techLimits[i] = new TechLimitHeightDiameter(limitNodes[i]); } len = textureNodes.Length; textureSets = new TextureSet[len]; for (int i = 0; i < len; i++) { textureSets[i] = TextureSets.INSTANCE.getTextureSet(textureNodes[i].GetStringValue("name")); } topNodeNames = SSTUUtils.parseCSV(topManagedNodeNames); bottomNodeNames = SSTUUtils.parseCSV(bottomManagedNodeNames); }