private void updateButtons()
 {
     //Change to AGX buttons if AGX installed
     if (AGXInterface.AGExtInstalled())
     {
         Fields["group"].guiActiveEditor        = false;
         Fields["group"].guiActive              = false;
         Fields["agxGroupType"].guiActiveEditor = true;
         Fields["agxGroupType"].guiActive       = true;
         //Fields["agxGroupNum"].guiActiveEditor = true;
         //Fields["agxGroupNum"].guiActive = true;
         if (agxGroupType == "1") //only show groups select slider when selecting action group
         {
             Fields["agxGroupNum"].guiActiveEditor = true;
             Fields["agxGroupNum"].guiActive       = true;
             //Fields["agxGroupNum"].guiName = "Group:";
         }
         else
         {
             Fields["agxGroupNum"].guiActiveEditor = false;
             Fields["agxGroupNum"].guiActive       = false;
             //Fields["agxGroupNum"].guiName = "N/A";
             //agxGroupNum = 1;
         }
     }
     else //AGX not installed, leave at default
     {
         Fields["group"].guiActiveEditor        = true;
         Fields["group"].guiActive              = true;
         Fields["agxGroupType"].guiActiveEditor = false;
         Fields["agxGroupType"].guiActive       = false;
         Fields["agxGroupNum"].guiActiveEditor  = false;
         Fields["agxGroupNum"].guiActive        = false;
     }
 }
Beispiel #2
0
        public override void OnUpdate()
        {
            //Check to see if the device has been rearmed, if so, deactivate the lights
            if (isArmed && illuminated)
            {
                lightsOff();
            }

            if (FlightGlobals.fetch.activeVessel.HoldPhysics || physicsCnt++ < PHYSICSWAIT)
            {
                fireNextupdate = false;
                return;
            }

            //In order for physics to take effect on jettisoned parts, the staging event has to be fired from OnUpdate

            if (fireNextupdate)
            {
                int groupToFire = 0; //AGX: need to send correct group
                if (AGXInterface.AGExtInstalled())
                {
                    groupToFire = int.Parse(agxGroupType);
                }
                else
                {
                    Log.Info("DPLD.OnUpdate Fire");
                    groupToFire = int.Parse(group);
                }
                Helper.fireEvent(this.part, groupToFire, (int)agxGroupNum);
                fireNextupdate = false;
            }
        }
Beispiel #3
0
        public override void OnUpdate()
        {
            if (!moduleIsEnabled)
            {
                return;
            }
            //In order for physics to take effect on jettisoned parts, the staging event has to be fired from OnUpdate
            if (fireNextupdate)
            {
                int groupToFire = 0; //AGX: need to send correct group
                if (AGXInterface.AGExtInstalled())
                {
                    groupToFire = int.Parse(agxGroupType);
                }
                else
                {
                    groupToFire = int.Parse(group);
                }
                Helper.fireEvent(this.part, groupToFire, (int)agxGroupNum);
                fireNextupdate = false;
                isArmed        = false;
                wasArmed       = false;
                maxTWR         = 0; // prevents triggering right away if rearmed
                lightsOn();
            }


            if (checkEngine)
            {
                CheckEngine(); // unreachable?
            }
            double twr = GetTWR();

            displayTWR = twr;

            if (isArmed)
            {
                if (maxTWR > 0 && twr >= 0 && twr <= (StagePercentageMass / 100) && twr < maxTWR)
                {
                    Log.Info("fireNextupdate maxTWR: " + maxTWR.ToString("F2") + ", twr: " + twr.ToString("F2"));
                    fireNextupdate = true;
                    //Helper.fireEvent(this.part, 0, (int)0);
                }
                else if (maxTWR > 0 && twr < 0) // will get here if engine flames out with triggerOnFlameout = false
                {
                    isArmed = false;
                }
                maxTWR = Math.Max(maxTWR, twr);
            }

            if (wasArmed != isArmed) // toggled or flamed out with triggerOnFlameout = false
            {
                wasArmed = isArmed;
                maxTWR   = 0;
            }
            if (isArmed && illuminated)
            {
                lightsOff();
            }
        }
Beispiel #4
0
        protected void updateButtons()
        {
            if (!moduleIsEnabled)
            {
                // Hide entire GUI
                foreach (BaseEvent e in Events)
                {
                    e.guiActive       = false;
                    e.guiActiveEditor = false;
                }
                foreach (BaseField f in Fields)
                {
                    f.guiActive       = false;
                    f.guiActiveEditor = false;
                }
                foreach (BaseAction a in Actions)
                {
                    a.active = false;
                }
                return;
            }

            //Change to AGX buttons if AGX installed
            if (AGXInterface.AGExtInstalled())
            {
                Fields["group"].guiActiveEditor        = false;
                Fields["group"].guiActive              = false;
                Fields["agxGroupType"].guiActiveEditor = true;
                Fields["agxGroupType"].guiActive       = true;
                //Fields["agxGroupNum"].guiActiveEditor = true;
                //Fields["agxGroupNum"].guiActive = true;
                if (agxGroupType == "1") //only show groups select slider when selecting action group
                {
                    Fields["agxGroupNum"].guiActiveEditor = true;
                    Fields["agxGroupNum"].guiActive       = true;
                    //Fields["agxGroupNum"].guiName = "Group:";
                }
                else
                {
                    Fields["agxGroupNum"].guiActiveEditor = false;
                    Fields["agxGroupNum"].guiActive       = false;
                    //Fields["agxGroupNum"].guiName = "N/A";
                    //agxGroupNum = 1;
                }
            }
            else //AGX not installed, leave at default
            {
                Fields["group"].guiActiveEditor        = true;
                Fields["group"].guiActive              = true;
                Fields["agxGroupType"].guiActiveEditor = false;
                Fields["agxGroupType"].guiActive       = false;
                Fields["agxGroupNum"].guiActiveEditor  = false;
                Fields["agxGroupNum"].guiActive        = false;
            }
        }
 public void transmit_GUI()
 {
     if (AGXInterface.AGExtInstalled())
     {
         transmitCommand(float.Parse(agxGroupType), agxGroupNum);
     }
     else
     {
         transmitCommand(float.Parse(group));
     }
 }
Beispiel #6
0
        private void fireAction()
        {
            int groupToFire = 0; //AGX: need to send correct group

            if (AGXInterface.AGExtInstalled())
            {
                groupToFire = int.Parse(agxGroupType);
            }
            else
            {
                groupToFire = int.Parse(group);
            }
            Helper.fireEvent(this.part, groupToFire, (int)agxGroupNum);
            fireNextupdate = false;
            lightsOn();
        }
Beispiel #7
0
 public static void fireEvent(Part p, int eventID, int AGXgroup) { //AGXgroup is only used if Action Groups Extended is installed, ignore it otherwiseDebug.Log("fire " + p.name + eventID + "||" + AGXgroup);
     if (p == null)
         return;
     if (eventID == 0) {
         MonoBehaviour.print("Fire Stage from part " + p);
         fireNextNonEmptyStage(p.vessel);
         return;
     }
     else if(AGXInterface.AGExtInstalled() && eventID == 1) 
     {
         AGXInterface.AGX2VslToggleGroup(p.vessel.rootPart.flightID, AGXgroup); //call to agx to activate group
     }
     else if (eventID > 0 && eventID <= maxEvent) {
         MonoBehaviour.print("Fire Event " + KM_dictAGNames[eventID] + " from part " + p);
         p.vessel.ActionGroups.ToggleGroup(KM_dictAG[eventID]);
     }
 }
Beispiel #8
0
        private void fireAction()
        {
            int groupToFire = 0; //AGX: need to send correct group

            if (AGXInterface.AGExtInstalled())
            {
                groupToFire = int.Parse(agxGroupType);
            }
            else
            {
                groupToFire = int.Parse(group);
            }
            Helper.fireEvent(this.part, groupToFire, (int)agxGroupNum);
            lightsOn();
            print("KM Stager: Target percentage hit");
            isArmed = false;
        }
Beispiel #9
0
        public override void OnUpdate()
        {
            if (FlightGlobals.fetch.activeVessel.HoldPhysics || physicsCnt++ < PHYSICSWAIT)
            {
                return;
            }
            //Check to see if the timer has been dragged in the staging list. If so, reset icon color
            if (this.part.inverseStage != previousStage && allowStage && !isArmed && this.part.inverseStage + 1 < StageManager.CurrentStage)
            {
                reset();
            }
            previousStage = this.part.inverseStage;

            //If the timer has been activated, start the countdown, activate the model's LED, and change the icon color
            if (triggerTime > 0 && isArmed)
            {
                remainingTime = triggerTime + (useSeconds ? triggerDelaySeconds : triggerDelayMinutes * 60) - Planetarium.GetUniversalTime();
                lightsOn(Utility.LightColor.GREEN);
                this.part.stackIcon.SetIconColor(XKCDColors.BrightYellow);

                //Once the timer hits 0 activate the stage/AG, disable the model's LED, and change the icon color
                if (remainingTime <= 0)
                {
                    Log.Info("Stage:" + Helper.KM_dictAGNames[int.Parse(group)]);
                    part.stackIcon.SetIconColor(XKCDColors.Red);
                    triggerTime   = 0;
                    remainingTime = 0;
                    //Disable timer until reset
                    isArmed        = false;
                    isCountingDown = false;
                    int groupToFire = 0; //AGX: need to send correct group
                    if (AGXInterface.AGExtInstalled())
                    {
                        groupToFire = int.Parse(agxGroupType);
                    }
                    else
                    {
                        groupToFire = int.Parse(group);
                    }
                    Helper.fireEvent(this.part, groupToFire, (int)agxGroupNum);
                    lightsOn();
                }
            }
        }
        public void transmitCommand(float groupID, float agxGroupNumB)   //agxGroupNum only used when AGX installed, ignore otherwise
        {
            foreach (var listener in Channel.radioListeners)
            {
                if (listener != null && listener.vessel != null)
                {
                    if (AGXInterface.AGExtInstalled()) //AGX Edited
                    {
                        listener.receiveCommand(this, (int)groupID, (int)channel, (int)agxGroupNumB);
                    }
                    else
                    {
                        listener.receiveCommand(this, (int)groupID, (int)channel, (int)agxGroupNumB);
                    }
                }
            }

            indicateSend();
        }
Beispiel #11
0
        public override void OnUpdate()
        {
            //Check to see if the timer has been dragged in the staging list. If so, reset icon color
            if (this.part.inverseStage != previousStage && allowStage && !isArmed && this.part.inverseStage + 1 < StageManager.CurrentStage)
            {
                reset();
            }
            previousStage = this.part.inverseStage;

            //If the timer has been activated, start the countdown, activate the model's LED, and change the icon color
            if (triggerTime > 0 && isArmed)
            {
                remainingTime = triggerTime + (useSeconds ? triggerDelaySeconds : triggerDelayMinutes * 60) - Planetarium.GetUniversalTime();
                Utility.switchEmissive(this, lightComponentOn, true);
                //Utility.switchLight(this.part, "light-go", true);
                Utility.playAnimationSetToPosition(this.part, "glow", 1);
                this.part.stackIcon.SetIconColor(XKCDColors.BrightYellow);

                //Once the timer hits 0 activate the stage/AG, disable the model's LED, and change the icon color
                if (remainingTime < 0)
                {
                    print("Stage:" + Helper.KM_dictAGNames[int.Parse(group)]);
                    int groupToFire = 0; //AGX: need to send correct group
                    if (AGXInterface.AGExtInstalled())
                    {
                        groupToFire = int.Parse(agxGroupType);
                    }
                    else
                    {
                        groupToFire = int.Parse(group);
                    }
                    Helper.fireEvent(this.part, groupToFire, (int)agxGroupNum);
                    this.part.stackIcon.SetIconColor(XKCDColors.Red);
                    triggerTime   = 0;
                    remainingTime = 0;
                    //Disable timer until reset
                    isArmed = false;
                }
            }
        }
Beispiel #12
0
 public override void OnUpdate()
 {
     //Check to see if the device has been rearmed, if so, deactivate the lights
     if (isArmed && illuminated)
     {
         lightsOff();
     }
     //In order for physics to take effect on jettisoned parts, the staging event has to be fired from OnUpdate
     if (fireNextupdate)
     {
         int groupToFire = 0; //AGX: need to send correct group
         if (AGXInterface.AGExtInstalled())
         {
             groupToFire = int.Parse(agxGroupType);
         }
         else
         {
             groupToFire = int.Parse(group);
         }
         Helper.fireEvent(this.part, groupToFire, (int)agxGroupNum);
         fireNextupdate = false;
     }
 }
Beispiel #13
0
 public override void OnUpdate()
 {
     //If this proximity sensor isn't registered, register it now
     if (ProxChannel.Listeners.Any(listener => listener.vessel.id == this.vessel.id && listener.channel == this.channel) == false)
     {
         registerListener();
     }
     //In order for physics to take effect on jettisoned parts, the staging event has to be fired from OnUpdate
     if (fireNextupdate && !justRegistered)
     {
         int groupToFire = 0; //AGX: need to send correct group
         if (AGXInterface.AGExtInstalled())
         {
             groupToFire = int.Parse(agxGroupType);
         }
         else
         {
             groupToFire = int.Parse(group);
         }
         Helper.fireEvent(this.part, groupToFire, (int)agxGroupNum);
         fireNextupdate = false;
     }
 }
Beispiel #14
0
        private void updateButtons()
        {
            if (useKilometer)
            {
                //Show meter button
                Events["useMeters"].guiActiveEditor = true;
                Events["useMeters"].guiActive       = true;
                //Hide meter scale
                Fields["meterHeight"].guiActiveEditor = false;
                Fields["meterHeight"].guiActive       = false;
                //Hide kilometer button
                Events["useKilometers"].guiActiveEditor = false;
                Events["useKilometers"].guiActive       = false;
                //Show kilometer scale
                Fields["kilometerHeight"].guiActiveEditor = true;
                Fields["kilometerHeight"].guiActive       = true;
                //Reset meter scale
                meterHeight = 0;
            }
            else
            {
                //Hide meter button
                Events["useMeters"].guiActiveEditor = false;
                Events["useMeters"].guiActive       = false;
                //Show meter scale
                Fields["meterHeight"].guiActiveEditor = true;
                Fields["meterHeight"].guiActive       = true;
                //Show kilometer button
                Events["useKilometers"].guiActiveEditor = true;
                Events["useKilometers"].guiActive       = true;
                //Hide kilometer scale
                Fields["kilometerHeight"].guiActiveEditor = false;
                Fields["kilometerHeight"].guiActive       = false;
                //Reset kilometer scale
                kilometerHeight = 0;
            }

            //Change to AGX buttons if AGX installed
            if (AGXInterface.AGExtInstalled())
            {
                Fields["group"].guiActiveEditor        = false;
                Fields["group"].guiActive              = false;
                Fields["agxGroupType"].guiActiveEditor = true;
                Fields["agxGroupType"].guiActive       = true;
                //Fields["agxGroupNum"].guiActiveEditor = true;
                //Fields["agxGroupNum"].guiActive = true;
                if (agxGroupType == "1") //only show groups select slider when selecting action group
                {
                    Fields["agxGroupNum"].guiActiveEditor = true;
                    Fields["agxGroupNum"].guiActive       = true;
                    //Fields["agxGroupNum"].guiName = "Group:";
                }
                else
                {
                    Fields["agxGroupNum"].guiActiveEditor = false;
                    Fields["agxGroupNum"].guiActive       = false;
                    //Fields["agxGroupNum"].guiName = "N/A";
                    //agxGroupNum = 1;
                }
            }
            else //AGX not installed, leave at default
            {
                Fields["group"].guiActiveEditor        = true;
                Fields["group"].guiActive              = true;
                Fields["agxGroupType"].guiActiveEditor = false;
                Fields["agxGroupType"].guiActive       = false;
                Fields["agxGroupNum"].guiActiveEditor  = false;
                Fields["agxGroupNum"].guiActive        = false;
            }
        }
Beispiel #15
0
        private void updateButtons()
        {
            if (useSeconds)
            {
                //Show minute button
                Events["setMinutes"].guiActiveEditor = true;
                Events["setMinutes"].guiActive       = true;
                //Hide minute scale
                Fields["triggerDelayMinutes"].guiActiveEditor = false;
                Fields["triggerDelayMinutes"].guiActive       = false;
                //Hide seconds button
                Events["setSeconds"].guiActiveEditor = false;
                Events["setSeconds"].guiActive       = false;
                //Show seconds scale
                Fields["triggerDelaySeconds"].guiActiveEditor = true;
                Fields["triggerDelaySeconds"].guiActive       = true;
                //Reset minute scale
                triggerDelayMinutes = 0f;
            }
            else
            {
                //Hide minute button
                Events["setMinutes"].guiActiveEditor = false;
                Events["setMinutes"].guiActive       = false;
                //Show minute scale
                Fields["triggerDelayMinutes"].guiActiveEditor = true;
                Fields["triggerDelayMinutes"].guiActive       = true;
                //Show seconds button
                Events["setSeconds"].guiActiveEditor = true;
                Events["setSeconds"].guiActive       = true;
                //Hide seconds scale
                Fields["triggerDelaySeconds"].guiActiveEditor = false;
                Fields["triggerDelaySeconds"].guiActive       = false;
                //Reset seconds scale
                triggerDelaySeconds = 0;
            }

            //Change to AGX buttons if AGX installed
            if (AGXInterface.AGExtInstalled())
            {
                Fields["group"].guiActiveEditor        = false;
                Fields["group"].guiActive              = false;
                Fields["agxGroupType"].guiActiveEditor = true;
                Fields["agxGroupType"].guiActive       = true;
                //Fields["agxGroupNum"].guiActiveEditor = true;
                //Fields["agxGroupNum"].guiActive = true;
                if (agxGroupType == "1") //only show groups select slider when selecting action group
                {
                    Fields["agxGroupNum"].guiActiveEditor = true;
                    Fields["agxGroupNum"].guiActive       = true;
                    //Fields["agxGroupNum"].guiName = "Group:";
                }
                else
                {
                    Fields["agxGroupNum"].guiActiveEditor = false;
                    Fields["agxGroupNum"].guiActive       = false;
                    //Fields["agxGroupNum"].guiName = "N/A";
                    //agxGroupNum = 1;
                }
            }
            else //AGX not installed, leave at default
            {
                Fields["group"].guiActiveEditor        = true;
                Fields["group"].guiActive              = true;
                Fields["agxGroupType"].guiActiveEditor = false;
                Fields["agxGroupType"].guiActive       = false;
                Fields["agxGroupNum"].guiActiveEditor  = false;
                Fields["agxGroupNum"].guiActive        = false;
            }
        }
Beispiel #16
0
        private void updateButtons()
        {
            if (forceSinglePart)
            {
                Events["setSinglePart"].active = false;
            }

            //Change to AGX buttons if AGX installed
            if (AGXInterface.AGExtInstalled())
            {
                Fields["group"].guiActiveEditor        = false;
                Fields["group"].guiActive              = false;
                Fields["agxGroupType"].guiActiveEditor = true;
                Fields["agxGroupType"].guiActive       = true;
                //Fields["agxGroupNum"].guiActiveEditor = true;
                //Fields["agxGroupNum"].guiActive = true;
                if (agxGroupType == "1") //only show groups select slider when selecting action group
                {
                    Fields["agxGroupNum"].guiActiveEditor = true;
                    Fields["agxGroupNum"].guiActive       = true;
                    //Fields["agxGroupNum"].guiName = "Group:";
                }
                else
                {
                    Fields["agxGroupNum"].guiActiveEditor = false;
                    Fields["agxGroupNum"].guiActive       = false;
                    //Fields["agxGroupNum"].guiName = "N/A";
                    //agxGroupNum = 1;
                }
            }
            else //AGX not installed, leave at default
            {
                Fields["group"].guiActiveEditor        = true;
                Fields["group"].guiActive              = true;
                Fields["agxGroupType"].guiActiveEditor = false;
                Fields["agxGroupType"].guiActive       = false;
                Fields["agxGroupNum"].guiActiveEditor  = false;
                Fields["agxGroupNum"].guiActive        = false;
            }

            //Hide auto reset button, since we don't need, we can reactivate in AG
            Fields["autoReset"].guiActive       = false;
            Fields["autoReset"].guiActiveEditor = false;

            if (decreasing)
            {
                Events["setDecreasing"].guiName = "Trigger when Decreasing";
            }
            else
            {
                Events["setDecreasing"].guiName = "Trigger when Increasing";
            }

            switch (singlePart)
            {
            case monitoredParts.single:
                Events["setSinglePart"].guiName = "Single Part";
                break;

            case monitoredParts.stage:
                Events["setSinglePart"].guiName = "Current Stage";
                break;

            case monitoredParts.vessel:
                Events["setSinglePart"].guiName = "Entire Ship";
                break;
            }
        }