public void SetObjectResources() { //Can we afford to reconfigure the container? if (!confirmedReconfigure && canAffordReconfigure() && hasSufficientSkill()) { ScreenMessages.PostScreenMessage("Click again to confirm reconfiguration.", 5.0f, ScreenMessageStyle.UPPER_CENTER); confirmedReconfigure = true; return; } payForReconfigure(); // Get list of resources. List <ModuleSpaceObjectResource> resources = part.FindModulesImplementing <ModuleSpaceObjectResource>(); ModuleSpaceObjectResource resource; int count = resources.Count; // Clear any previews if (count > 0) { previewResources.Clear(); previewRatios.Clear(); part.Resources.Clear(); abundances.Clear(); } // Add the resources StringBuilder builder = new StringBuilder(); for (int index = 0; index < count; index++) { resource = resources[index]; if (resource.abundance > 0) { previewResources.Add(resource.resourceName, 0); previewRatios.Add(resource.resourceName, 1.0f); abundances.Add(resource.resourceName, resource.abundance); ResourceHelper.AddResource(resource.resourceName, 0, 0, part); builder.Append(resource.resourceName); } } abundanceResources = builder.ToString(); // Recalculate max amounts currentStorageCapacity = 0; adjustedVolume = currentStorageCapacity; inventoryAdjustedVolume = currentStorageCapacity; recalculateMaxAmounts(); reconfigureStorage(); // Hide this event Events["SetObjectResources"].guiActive = part.Resources.Count == 0; }