public virtual void ToggleInflation()
        {
            //If the module is inflatable, deployed, and has kerbals inside, then don't allow the module to be deflated.
            if (isInflatable && isDeployed && this.part.protoModuleCrew.Count() > 0)
            {
                ScreenMessages.PostScreenMessage(this.part.name + " has crew aboard. Vacate the module before deflating it.", 5.0f, ScreenMessageStyle.UPPER_CENTER);
                return;
            }

            //make sure we don't have parts attached
            if (isInflatable && isDeployed)
            {
                if (this.part.children.Count > 0)
                {
                    ScreenMessages.PostScreenMessage(this.part.name + " has parts attached to it. Please remove them before deflating.", 5.0f, ScreenMessageStyle.UPPER_CENTER);
                    return;
                }
            }

            //Play animation for current state
            animationStarted = true;
            PlayAnimation(isDeployed);

            //Toggle state
            isDeployed = !isDeployed;
            if (isDeployed)
            {
                this.part.CrewCapacity            = inflatedCrewCapacity;
                Events["ToggleInflation"].guiName = endEventGUIName;
            }
            else
            {
                this.part.CrewCapacity            = 0;
                Events["ToggleInflation"].guiName = startEventGUIName;

                //Turn off the lights if deflating the module.
                WBILight light = this.part.FindModuleImplementing <WBILight>();
                if (light != null)
                {
                    if (light.isDeployed)
                    {
                        light.TurnOffLights();
                    }
                }
            }

            Log("Animation toggled new gui name: " + Events["ToggleInflation"].guiName);
        }
        public void TurnAnimationOff()
        {
            //Turn on the docking lights if we have any
            if (dockingLight != null)
            {
                dockingLight.TurnOffLights();
                return;
            }

            //Legacy method of turning off docking lights.
            ModuleAnimateGeneric glowAnim = this.part.FindModuleImplementing <ModuleAnimateGeneric>();

            if (glowAnim == null)
            {
                return;
            }

            //Turn off the glow animation
            if (glowAnim.Events["Toggle"].guiName == glowAnim.endEventGUIName)
            {
                glowAnim.Toggle();
            }
        }
Exemplo n.º 3
0
        protected void drawCommandView()
        {
            commandModule = this.part.FindModuleImplementing <ModuleCommand>();
            switcher      = this.part.FindModuleImplementing <WBIResourceSwitcher>();
            lightModule   = this.part.FindModuleImplementing <WBILight>();

            GUILayout.BeginVertical();

            GUILayout.BeginScrollView(new Vector2(), new GUIStyle(GUI.skin.textArea), new GUILayoutOption[] { GUILayout.Height(480) });
            if (!HighLogic.LoadedSceneIsFlight)
            {
                GUILayout.Label("This configuration is working, but the contents can only be accessed in flight.");
                GUILayout.EndScrollView();
                GUILayout.EndVertical();
                return;
            }

            //Control From Here
            if (commandModule != null)
            {
                if (GUILayout.Button("Control From Here"))
                {
                    commandModule.MakeReference();
                }

                //Rename Vessel
                if (GUILayout.Button("Rename Base"))
                {
                    commandModule.RenameVessel();
                }
            }

            //Toggle Decals
            if (switcher != null)
            {
                if (!string.IsNullOrEmpty(switcher.logoPanelTransforms))
                {
                    if (GUILayout.Button("Toggle Decals"))
                    {
                        switcher.ToggleDecals();
                    }
                }

                //Dump Resources
                if (GUILayout.Button("Dump Resources"))
                {
                    switcher.DumpResources();
                }
            }

            //Toggle Lights
            if (lightModule != null)
            {
                if (lightModule.isDeployed)
                {
                    if (GUILayout.Button(lightModule.endEventGUIName))
                    {
                        lightModule.TurnOffLights();
                    }
                }

                else
                {
                    if (GUILayout.Button(lightModule.startEventGUIName))
                    {
                        lightModule.TurnOnLights();
                    }
                }
            }

            GUILayout.EndScrollView();
            GUILayout.EndVertical();
        }
        public virtual void ToggleInflation()
        {
            //If the module is inflatable, deployed, and has kerbals inside, then don't allow the module to be deflated.
            if (isInflatable && isDeployed && this.part.protoModuleCrew.Count() > 0)
            {
                ScreenMessages.PostScreenMessage(this.part.name + " has crew aboard. Vacate the module before deflating it.", 5.0f, ScreenMessageStyle.UPPER_CENTER);
                return;
            }

            //make sure we don't have parts radially attached
            if (isInflatable && isDeployed && !overridePartAttachRestriction)
            {
                if (this.part.children.Count > 0)
                {
                    foreach (Part childPart in this.part.children)
                    {
                        if (childPart.attachMode == AttachModes.SRF_ATTACH)
                        {
                            ScreenMessages.PostScreenMessage(this.part.name + " has parts attached to it. Please remove them before deflating.", 5.0f, ScreenMessageStyle.UPPER_CENTER);
                            return;
                        }
                    }
                }
            }

            //Play animation for current state
            animationStarted = true;
            PlayAnimation(isDeployed);

            //Toggle state
            isDeployed = !isDeployed;
            if (isDeployed)
            {
                this.part.CrewCapacity          = inflatedCrewCapacity;
                this.part.crewTransferAvailable = true;
                if (HighLogic.LoadedSceneIsFlight)
                {
                    this.part.SpawnIVA();
                }
                Events["ToggleInflation"].guiName = endEventGUIName;
            }
            else
            {
                this.part.CrewCapacity          = 0;
                this.part.crewTransferAvailable = false;
                if (HighLogic.LoadedSceneIsFlight)
                {
                    this.part.DespawnIVA();
                }
                Events["ToggleInflation"].guiName = startEventGUIName;

                //Turn off the lights if deflating the module.
                WBILight light = this.part.FindModuleImplementing <WBILight>();
                if (light != null)
                {
                    if (light.isDeployed)
                    {
                        light.TurnOffLights();
                    }
                }
            }

            //Setup colliders and inventories
            setupColliders();
            //setupInventories();

            Log("Animation toggled new gui name: " + Events["ToggleInflation"].guiName);
        }
        public virtual void ToggleInflation()
        {
            //If the module is inflatable, deployed, and has kerbals inside, then don't allow the module to be deflated.
            if (isInflatable && isDeployed && this.part.protoModuleCrew.Count() > 0)
            {
                ScreenMessages.PostScreenMessage(this.part.name + " has crew aboard. Vacate the module before deflating it.", 5.0f, ScreenMessageStyle.UPPER_CENTER);
                return;
            }

            //make sure we don't have parts radially attached
            if (isInflatable && isDeployed && !overridePartAttachRestriction)
            {
                if (this.part.children.Count > 0)
                {
                    foreach (Part childPart in this.part.children)
                    {
                        if (childPart.attachMode == AttachModes.SRF_ATTACH)
                        {
                            ScreenMessages.PostScreenMessage(this.part.name + " has parts attached to it. Please remove them before deflating.", 5.0f, ScreenMessageStyle.UPPER_CENTER);
                            return;
                        }
                    }
                }
            }

            //Play animation for current state
            isMoving = true;
            PlayAnimation(isDeployed);

            //Toggle state
            isDeployed = !isDeployed;
            if (isDeployed)
            {
                this.part.CrewCapacity          = inflatedCrewCapacity;
                this.part.crewTransferAvailable = true;
                if (HighLogic.LoadedSceneIsFlight)
                {
                    this.part.SpawnIVA();
                }
                Events["ToggleInflation"].guiName = endEventGUIName;

                if (inventory != null)
                {
                    inventory.packedVolumeLimit = packedVolumeLimit;
                }
            }
            else
            {
                this.part.CrewCapacity          = 0;
                this.part.crewTransferAvailable = false;
                if (HighLogic.LoadedSceneIsFlight)
                {
                    this.part.DespawnIVA();
                }
                Events["ToggleInflation"].guiName = startEventGUIName;

                //Turn off the lights if deflating the module.
                WBILight light = this.part.FindModuleImplementing <WBILight>();
                if (light != null)
                {
                    if (light.isDeployed)
                    {
                        light.TurnOffLights();
                    }
                }

                if (inventory != null)
                {
                    inventory.packedVolumeLimit = 0;
                }
            }

            //If this is a one-shot then hide the animation button.
            if (isOneShot && isDeployed && HighLogic.LoadedSceneIsEditor == false)
            {
                Events["ToggleInflation"].active = false;
            }

            Log("Animation toggled new gui name: " + Events["ToggleInflation"].guiName);
            MonoUtilities.RefreshContextWindows(this.part);
            GameEvents.onPartResourceListChange.Fire(this.part);
        }