protected void checkForUpgrade() { if (HighLogic.CurrentGame.Mode == Game.Modes.SANDBOX) { return; } WBIConvertibleStorage storage = this.part.FindModuleImplementing <WBIConvertibleStorage>(); //If the player hasn't unlocked the upgradeTech node yet, then hide the resource switcher. if (ResearchAndDevelopment.GetTechnologyState(upgradeTech) == RDTech.State.Available) { storage.SetGUIVisible(true); } else { storage.SetGUIVisible(false); } }
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); }
public virtual void SetVisibleObjects() { List <int> visibleObjects = new List <int>(); string visibleObject = null; //Fuel tank GUI if (string.IsNullOrEmpty(fuelTankTransform) == false && switcher != null) { if (fuelTankTransform.Contains(bodyNames[bodyIndex])) { switcher.isEnabled = true; switcher.enabled = true; switcher.SetGUIVisible(true); if (resourceDistributor != null) { resourceDistributor.isEnabled = true; resourceDistributor.enabled = true; resourceDistributor.Events["SetupDistribution"].guiActive = true; resourceDistributor.Events["SetupDistribution"].guiActiveEditor = true; } } else { 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; } } } //Set visible end caps if (endCapNames != null) { visibleObject = endCapNames[endCapIndex]; visibleObjects.Add(meshIndexes[visibleObject]); } //Body type if (bodyNames != null) { visibleObject = bodyNames[bodyIndex]; if (meshIndexes.ContainsKey(visibleObject)) { visibleObjects.Add(meshIndexes[visibleObject]); } } //Center vestibule if (!string.IsNullOrEmpty(centerVestibuleName)) { if (centerVestibuleIsVisible) { visibleObjects.Add(meshIndexes[centerVestibuleName]); } } //Set racks switch (rackConfiguration) { case RackConfigurations.Two: visibleObject = rackNames[0]; visibleObjects.Add(meshIndexes[visibleObject]); visibleObject = rackNames[3]; visibleObjects.Add(meshIndexes[visibleObject]); break; case RackConfigurations.Three: visibleObject = rackNames[0]; visibleObjects.Add(meshIndexes[visibleObject]); visibleObject = rackNames[2]; visibleObjects.Add(meshIndexes[visibleObject]); visibleObject = rackNames[4]; visibleObjects.Add(meshIndexes[visibleObject]); break; case RackConfigurations.Six: visibleObject = rackNames[0]; visibleObjects.Add(meshIndexes[visibleObject]); visibleObject = rackNames[1]; visibleObjects.Add(meshIndexes[visibleObject]); visibleObject = rackNames[2]; visibleObjects.Add(meshIndexes[visibleObject]); visibleObject = rackNames[3]; visibleObjects.Add(meshIndexes[visibleObject]); visibleObject = rackNames[4]; visibleObjects.Add(meshIndexes[visibleObject]); visibleObject = rackNames[5]; visibleObjects.Add(meshIndexes[visibleObject]); break; default: break; } setObjects(visibleObjects); }