private void init() { if (initialized) { return; } initialized = true; rcsIndices = SSTUUtils.parseIntArray(rcsModuleIndex); engineIndices = SSTUUtils.parseIntArray(engineModuleIndex); ConfigNode node = SSTUConfigNodeUtils.parseConfigNode(configNodeData); ConfigNode[] fuelTypeNodes = node.GetNodes("FUELTYPE"); int len = fuelTypeNodes.Length; fuelTypes = FuelTypeISP.parse(fuelTypeNodes); fuelType = Array.Find(fuelTypes, m => m.fuelPreset.name == currentFuelType); if (fuelType == null && (fuelTypes != null && fuelTypes.Length > 0)) { SSTULog.error("ERROR: SSTUModularRCS - currentFuelType was null for value: " + currentFuelType); fuelType = fuelTypes[0]; currentFuelType = fuelType.fuelPreset.name; SSTULog.error("Assigned default fuel type of: " + currentFuelType + ". This is likely a config error that needs to be corrected."); } else if (fuelTypes == null || fuelTypes.Length < 1) { SSTULog.error("ERROR: SSTURCSFuelSelection - No fuel type definitions found."); } }
public static void updateEngineFuelType(FuelTypeISP fuelType, Part part, int engineModuleIndex) { if (engineModuleIndex < 0) { return; } ModuleEngines[] engines = part.GetComponents <ModuleEngines>(); int len = engines.Length; if (engineModuleIndex < len) { ModuleEngines engine = engines[engineModuleIndex]; engine.propellants.Clear(); ConfigNode pNode = fuelType.fuelPreset.getPropellantNode(ResourceFlowMode.ALL_VESSEL_BALANCE); if (fuelType.atmosphereCurve != null) { pNode.AddNode("atmosphereCurve", fuelType.atmosphereCurve.getNode("atmosphereCurve")); } engine.OnLoad(pNode); } else { SSTULog.error("Could not update fuel type - ModuleEngines could not be found for index: " + engineModuleIndex + " There are not enough modules present in the part: " + len); } }
public static FuelTypeISP[] parse(ConfigNode[] nodes) { int len = nodes.Length; FuelTypeISP[] isps = new FuelTypeISP[len]; for (int i = 0; i < len; i++) { isps[i] = new FuelTypeISP(nodes[i]); } return(isps); }
public static void updateContainerFuelType(FuelTypeISP fuelType, Part part, int containerIndex) { if (containerIndex < 0) { return; } SSTUVolumeContainer vc = part.GetComponent <SSTUVolumeContainer>(); if (vc == null) { SSTULog.error("Could not update fuel type - no SSTUVolumeContainer found in part"); return; } if (containerIndex < vc.numberOfContainers) { vc.setFuelPreset(containerIndex, fuelType.fuelPreset, false); vc.recalcVolume(); } else { SSTULog.error("Could not update fuel type - not enough containers in SSTUVolumeContainer for index: " + containerIndex + " only found: " + vc.numberOfContainers); } }