void getInputs() { char[] semicolonSeparator = new char[] { ';' }; //Get the outputs if (string.IsNullOrEmpty(dischargedResources)) { return; } resourcesToDump = dischargedResources.Split(semicolonSeparator); //Get inputs if (!string.IsNullOrEmpty(landedResourcesRequired)) { WBIKFSUtils.Log("[" + this.ClassName + "] - Adding required resources for landed state"); landedResourceInputs = getInputs(landedResourcesRequired); } if (!string.IsNullOrEmpty(spashedResourcesRequired)) { WBIKFSUtils.Log("[" + this.ClassName + "] - Adding required resources for splashed state"); splashedResourceInputs = getInputs(spashedResourcesRequired); } if (!string.IsNullOrEmpty(atmosphereResourcesRequired)) { WBIKFSUtils.Log("[" + this.ClassName + "] - Adding required resources for atmosphere state"); atmoResourceInputs = getInputs(atmosphereResourcesRequired); } if (!string.IsNullOrEmpty(vacuumResourcesRequired)) { WBIKFSUtils.Log("[" + this.ClassName + "] - Adding required resources for vacuum state"); vaccResourceInputs = getInputs(vacuumResourcesRequired); } }
ResourceRatio[] getInputs(string inputResources) { char[] semicolonSeparator = new char[] { ';' }; char[] commaSeparator = new char[] { ',' }; string[] inputs; string[] parameters; List <ResourceRatio> inputResourceRatios = new List <ResourceRatio>(); ResourceRatio resourceRatio; float amount; inputs = inputResources.Split(semicolonSeparator); for (int index = 0; index < inputs.Length; index++) { parameters = inputs[index].Split(commaSeparator); if (parameters.Length != 2) { continue; } //index 0: resource name resourceRatio = new ResourceRatio(); resourceRatio.ResourceName = parameters[0]; //index 1: amount if (!float.TryParse(parameters[1], out amount)) { continue; } resourceRatio.Ratio = amount; inputResourceRatios.Add(resourceRatio); WBIKFSUtils.Log("[" + this.ClassName + "] - added input resource: " + resourceRatio.ResourceName + " amount: " + resourceRatio.Ratio); } return(inputResourceRatios.ToArray()); }