Beispiel #1
0
        public void DoAllParts()                                                                //This runs every time you click "extend all" or "retract all"
        {
            if (this.animationName == "")
            {
                return;
            }
            bool extended = true;                                                                                        //This is the check if we are extending or retracting all, default to retracting.
            AYA_ModuleAnimateGeneric callingPart = this.part.FindModuleImplementing <AYA_ModuleAnimateGeneric>();        //Variable for the part doing the work.

            if (callingPart.deployState == ModuleDeployablePart.DeployState.RETRACTED)                                   //If the calling part is retracted...
            {
                extended = false;                                                                                        //...then it's not extended. Duh!
            }
            foreach (Part eachPart in vessel.Parts)                                                                      //Cycle through each part on the vessel
            {
                AYA_ModuleAnimateGeneric thisPartAnimate = eachPart.FindModuleImplementing <AYA_ModuleAnimateGeneric>(); //If it's an antenna...
                if (thisPartAnimate != null && thisPartAnimate.animationName == this.animationName)                      //..and it has an animation (rules out ox-stats and the like)
                {
                    KSPActionParam param = new KSPActionParam(KSPActionGroup.Custom01, KSPActionType.Activate);
                    if (extended)                                                               //then if the calling part was extended...
                    {
                        //Retract it
                        //thisPartAnimate.ToggleAction(param);
                        thisPartAnimate.Toggle();
                        callingPart.deployState = ModuleDeployablePart.DeployState.RETRACTING;
                    }
                    else                                                                        //otherwise...
                    {
                        if (callingPart.deployState == ModuleDeployablePart.DeployState.RETRACTED)
                        {
                            //thisPartAnimate.ToggleAction(param);
                            thisPartAnimate.Toggle();
                            callingPart.deployState = ModuleDeployablePart.DeployState.EXTENDING;                                                     //Extend it
                        }
                    }
                }
            }
        }
Beispiel #2
0
        public IEnumerator GenericAnimationUpdatePAWMenu(Part p, string e, string animName)
        {
            AYA_ModuleAnimateGeneric thisAYA_MAG = null;
            var allsAYA_MAG = p.FindModulesImplementing <AYA_ModuleAnimateGeneric>();

            foreach (var m in allsAYA_MAG)
            {
                if (m.animationName == animName)
                {
                    thisAYA_MAG = m;
                    break;
                }
            }
            if (thisAYA_MAG == null)
            {
                yield return(null);
            }
            if (thisAYA_MAG.isOneShot)
            {
                thisAYA_MAG.UpdatePAWMenu();
                yield return(null);
            }
            while (thisAYA_MAG.EventStatus(e) == false)
            {
                yield return(new WaitForSeconds(0.25f));

                if (HighLogic.LoadedSceneIsEditor || p.vessel == FlightGlobals.ActiveVessel)
                {
                    //var thisPartCargoBay = p.FindModuleImplementing<AYA_CargoBay>();
                    thisAYA_MAG.UpdatePAWMenu();
                }
                else
                {
                    break;
                }
            }
        }