protected void OnExperimentTransfered(WBIModuleScienceExperiment transferedExperiment) { PartResource resource = null; List <PartResource> doomedResources = new List <PartResource>(); string resourceName; string[] mapKeys; int index; PartResource doomed; int totalCount; //If the resource map isn't null, then go through all the resources //and if we have them, then reduce the max amount by the amount required by //the experiment. If the new max amount is <= 0 then remove the resource. if (transferedExperiment.resourceMap != null) { mapKeys = transferedExperiment.resourceMap.Keys.ToArray <string>(); for (index = 0; index < mapKeys.Length; index++) { resourceName = mapKeys[index]; if (this.part.Resources.Contains(resourceName)) { resource = this.part.Resources[resourceName]; resource.maxAmount -= transferedExperiment.resourceMap[resourceName].targetAmount; if (resource.maxAmount <= 0.001f) { doomedResources.Add(resource); } else if (resource.amount > resource.maxAmount) { resource.amount = resource.maxAmount; } } } //Remove any resources we don't need. totalCount = doomedResources.Count; for (index = 0; index < totalCount; index++) { doomed = doomedResources[index]; ResourceHelper.RemoveResource(doomed.resourceName, this.part); } //Dirty the GUI MonoUtilities.RefreshContextWindows(this.part); } //Setup the IVA props }