public void UpdateResources() { if (string.IsNullOrEmpty(fuelTankTransform) == false && switcher != null) { if (fuelTankTransform.Contains(bodyNames[bodyIndex])) { switcher.ReloadTemplate(); } else { switcher.RemoveAllResources(); } } }
public virtual void ToggleOption(int optionIndex) { currentOptionIndex = optionIndex; Events["ToggleOption"].guiName = kOptionLabel + optionNames[currentOptionIndex]; //Get the truss option WBIHexTrussOption trussOption = trussOptions[optionNames[currentOptionIndex]]; //Setup the mesh options setVisibleObjects(trussOption); //Setup the fuel tank if (omniStorage != null) { omniStorage.isEnabled = trussOption.isFuelTank; omniStorage.enabled = trussOption.isFuelTank; if (!trussOption.isFuelTank) { omniStorage.RemoveAllResources(); } } if (switcher != null) { if (trussOption.isFuelTank) { switcher.isEnabled = true; switcher.enabled = true; switcher.SetGUIVisible(true); switcher.ReloadTemplate(); if (resourceDistributor != null) { resourceDistributor.isEnabled = true; resourceDistributor.enabled = true; resourceDistributor.Events["SetupDistribution"].guiActive = true; resourceDistributor.Events["SetupDistribution"].guiActiveEditor = true; } } else { List <PartResource> doomedResources = new List <PartResource>(); foreach (PartResource resource in this.part.Resources) { doomedResources.Add(resource); } foreach (PartResource doomed in doomedResources) { this.part.Resources.Remove(doomed); } if (switcher.isEnabled) { switcher.SetGUIVisible(false); switcher.isEnabled = false; switcher.enabled = false; if (resourceDistributor != null) { resourceDistributor.isEnabled = false; resourceDistributor.enabled = false; resourceDistributor.Events["SetupDistribution"].guiActive = false; resourceDistributor.Events["SetupDistribution"].guiActiveEditor = false; } } } } MonoUtilities.RefreshContextWindows(this.part); }