Esempio n. 1
0
        private void EngageSmartASSOrbitalControl(MechJebModuleSmartASS.Target target)
        {
            MechJebCore masterMechJeb = this.vessel.GetMasterMechJeb();

            if (masterMechJeb != null)
            {
                MechJebModuleSmartASS masterSmartASS = masterMechJeb.GetComputerModule <MechJebModuleSmartASS>();

                if (masterSmartASS != null && !masterSmartASS.hidden)
                {
                    masterSmartASS.mode   = MechJebModuleSmartASS.Mode.ORBITAL;
                    masterSmartASS.target = target;

                    masterSmartASS.Engage();
                }
                else
                {
                    //Log.err(Localizer.Format("#MechJeb_LogError_msg1"));//"MechJeb couldn't find MechJebModuleSmartASS for orbital control via action group."
                    Log.err("couldn't find MechJebModuleSmartASS for orbital control via action group.");
                }
            }
            else
            {
                //Log.err(Localizer.Format("#MechJeb_LogError_msg0"));//"MechJeb couldn't find the master MechJeb module for the current vessel."
                Log.err("couldn't find the master MechJeb module for the current vessel.");
            }
        }
Esempio n. 2
0
        private void EngageSmartASSOrbitalControl(MechJebModuleSmartASS.Target target)
        {
            MechJebCore masterMechJeb = this.vessel.GetMasterMechJeb();

            if (masterMechJeb != null)
            {
                MechJebModuleSmartASS masterSmartASS = masterMechJeb.GetComputerModule <MechJebModuleSmartASS>();

                if (masterSmartASS != null)
                {
                    masterSmartASS.mode   = MechJebModuleSmartASS.Mode.ORBITAL;
                    masterSmartASS.target = target;

                    masterSmartASS.Engage();
                }
                else
                {
                    Debug.LogError("MechJeb couldn't find MechJebModuleSmartASS for orbital control via action group.");
                }
            }
            else
            {
                Debug.LogError("MechJeb couldn't find the master MechJeb module for the current vessel.");
            }
        }
Esempio n. 3
0
        public void EngageSmartASSControl(MechJebModuleSmartASS.Mode mode, MechJebModuleSmartASS.Target target, bool forceEnable)
        {
            MechJebCore masterMechJeb = this.vessel.GetMasterMechJeb();

            if (masterMechJeb != null)
            {
                MechJebModuleSmartASS masterSmartASS = masterMechJeb.GetComputerModule <MechJebModuleSmartASS>();

                if (masterSmartASS != null)
                {
                    if (forceEnable)
                    {
                        // Prevent that the presence of other attitude controllers disables SmartASS
                        masterSmartASS.autoDisableSmartASS = false;
                    }
                    masterSmartASS.mode   = mode;
                    masterSmartASS.target = target;

                    masterSmartASS.Engage();
                    masterSmartASS.enabled = true; // show GUI
                }
                else
                {
                    Debug.LogError("MechJeb couldn't find MechJebModuleSmartASS for control.");
                }
            }
            else
            {
                Debug.LogError("MechJeb couldn't find the master MechJeb module for the current vessel.");
            }
        }
 override public void postLoad(ConfigNode node)
 {
     foreach (MechJebModuleSmartASS.Target target in Enum.GetValues(typeof(MechJebModuleSmartASS.Target)))
     {
         if (TargetTexts[(int)target].CompareTo(this.targetName) == 0)
         {
             this.target = target;
             break;
         }
     }
 }
Esempio n. 5
0
        private void EngageSmartASSOrbitalControl(MechJebModuleSmartASS.Target target)
        {
            MechJebCore masterMechJeb = this.vessel.GetMasterMechJeb();

            if (masterMechJeb != null)
            {
                MechJebModuleSmartASS masterSmartASS = masterMechJeb.GetComputerModule <MechJebModuleSmartASS>();

                if (!masterSmartASS.hidden)
                {
                    EngageSmartASSControl(MechJebModuleSmartASS.Mode.ORBITAL, target, false);
                }
            }
        }
        private static bool ReturnTargetState(MechJebModuleSmartASS.Target action, Vessel ourVessel)
        {
            MechJebCore activeJeb = ourVessel.GetMasterMechJeb();

            if (activeJeb == null)
            {
                return(false);
            }
            MechJebModuleSmartASS activeSmartass = activeJeb.GetComputerModule <MechJebModuleSmartASS>();

            if (activeSmartass == null)
            {
                return(false);
            }
            return(action == activeSmartass.target);
        }
        // and these are the two functions that actually do the work.
        private static void EnactTargetAction(MechJebModuleSmartASS.Target action, Vessel ourVessel)
        {
            MechJebCore activeJeb = ourVessel.GetMasterMechJeb();

            if (activeJeb == null)
            {
                return;
            }
            MechJebModuleSmartASS activeSmartass = activeJeb.GetComputerModule <MechJebModuleSmartASS>();

            if (activeSmartass == null)
            {
                return;
            }
            activeSmartass.target = action;
            activeSmartass.Engage();
        }
 override public void activateAction()
 {
     base.activateAction();
     this.smartAss.mode         = Target2Mode[(int)target];
     this.smartAss.target       = target;
     this.smartAss.srfHdg       = this.srfHdg;
     this.smartAss.srfPit       = this.srfPit;
     this.smartAss.srfRol       = this.srfRol;
     this.smartAss.srfVelYaw    = this.srfVelYaw;
     this.smartAss.srfVelPit    = this.srfVelPit;
     this.smartAss.srfVelRol    = this.srfVelRol;
     this.smartAss.rol          = this.rol;
     this.smartAss.advReference = this.advReference;
     this.smartAss.advDirection = this.advDirection;
     this.smartAss.forceRol     = this.forceRol;
     this.smartAss.forcePitch   = this.forcePitch;
     this.smartAss.forceYaw     = this.forceYaw;
     this.smartAss.Engage();
 }
        override public void WindowGUI(int windowID)
        {
            base.preWindowGUI(windowID);
            base.WindowGUI(windowID);
            int modeSelectorIdx = TargetIsMode[(int)target]
                                ? targetModeSelectorIdxs[(int)target]
                                : modeModeSelectorIdxs[(int)Target2Mode[(int)target]];

            GUILayout.BeginHorizontal(GUILayout.Width(150));
            modeSelectorIdx = GuiUtils.ComboBox.Box(modeSelectorIdx, modeStrings.ToArray(), modeStrings);
            GUILayout.EndHorizontal();
            bool showForceRol = false;

            if (this.isTargetMode[modeSelectorIdx])
            {
                target       = this.targetModes[modeSelectorIdx];
                showForceRol = (target == MechJebModuleSmartASS.Target.NODE);
            }
            else
            {
                MechJebModuleSmartASS.Mode mode = this.modeModes[modeSelectorIdx];
                List <String> targetStrings     = this.targetStrings[(int)mode];
                if (targetStrings.Count == 1)
                {
                    target = this.targets[(int)mode][0];
                }
                else
                {
                    int targetSelectorIdx = (Target2Mode[(int)target] == mode) ? targetSelectorIdxs[(int)target] : 0;
                    GUILayout.BeginHorizontal(GUILayout.Width(160));
                    targetSelectorIdx = GuiUtils.ComboBox.Box(targetSelectorIdx, targetStrings.ToArray(), targetStrings);
                    GUILayout.EndHorizontal();
                    target = this.targets[(int)mode][targetSelectorIdx];
                }
                switch (mode)
                {
                case MechJebModuleSmartASS.Mode.ORBITAL:
                case MechJebModuleSmartASS.Mode.TARGET:
                    showForceRol = true;
                    break;

                case MechJebModuleSmartASS.Mode.ADVANCED:
                    GUILayout.BeginHorizontal(GUILayout.Width(220));
                    advReference = (AttitudeReference)GuiUtils.ComboBox.Box((int)advReference, ReferenceTexts, ReferenceTexts);
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal(GUILayout.Width(200));
                    advDirection = (Vector6.Direction)GuiUtils.ComboBox.Box((int)advDirection, DirectionTexts, DirectionTexts);
                    GUILayout.EndHorizontal();
                    showForceRol = true;
                    break;
                }
                switch (target)
                {
                case MechJebModuleSmartASS.Target.SURFACE:
                    GUILayout.Label("", GUI.skin.label, GUILayout.ExpandWidth(true));
                    forceYaw    = GUILayout.Toggle(forceYaw, "Heading: ", GUILayout.ExpandWidth(false));
                    srfHdg.text = GUILayout.TextField(srfHdg.text, GUILayout.ExpandWidth(false), GUILayout.Width(37));
                    GUILayout.Label("°", GUILayout.ExpandWidth(true));
                    forcePitch  = GUILayout.Toggle(forcePitch, "Pitch: ", GUILayout.ExpandWidth(false));
                    srfPit.text = GUILayout.TextField(srfPit.text, GUILayout.ExpandWidth(false), GUILayout.Width(37));
                    GUILayout.Label("°", GUILayout.ExpandWidth(true));
                    forceRol    = GUILayout.Toggle(forceRol, "Roll: ", GUILayout.ExpandWidth(false));
                    srfRol.text = GUILayout.TextField(srfRol.text, GUILayout.ExpandWidth(false), GUILayout.Width(37));
                    GUILayout.Label("°", GUILayout.ExpandWidth(false));
                    break;

                case MechJebModuleSmartASS.Target.SURFACE_PROGRADE:
                case MechJebModuleSmartASS.Target.SURFACE_RETROGRADE:
                    GUILayout.Label("", GUI.skin.label, GUILayout.ExpandWidth(true));
                    forcePitch     = GUILayout.Toggle(forcePitch, "Pitch: ", GUILayout.ExpandWidth(false));
                    srfVelPit.text = GUILayout.TextField(srfVelPit.text, GUILayout.ExpandWidth(false), GUILayout.Width(37));
                    GUILayout.Label("°", GUILayout.ExpandWidth(true));
                    forceRol       = GUILayout.Toggle(forceRol, "Roll: ", GUILayout.ExpandWidth(false));
                    srfVelRol.text = GUILayout.TextField(srfVelRol.text, GUILayout.ExpandWidth(false), GUILayout.Width(37));
                    GUILayout.Label("°", GUILayout.ExpandWidth(true));
                    forceYaw       = GUILayout.Toggle(forceYaw, "Yaw: ", GUILayout.ExpandWidth(false));
                    srfVelYaw.text = GUILayout.TextField(srfVelYaw.text, GUILayout.ExpandWidth(false), GUILayout.Width(37));
                    GUILayout.Label("°", GUILayout.ExpandWidth(false));
                    break;
                }
            }
            GUILayout.Label("", GUILayout.ExpandWidth(true));
            if (showForceRol)
            {
                forceRol = GUILayout.Toggle(forceRol, "Force Roll: ", GUILayout.ExpandWidth(false));
                rol.text = GUILayout.TextField(rol.text, GUILayout.Width(37));
                GUILayout.Label("°", GUILayout.ExpandWidth(false));
            }
            targetName = TargetTexts[(int)target];
            base.postWindowGUI(windowID);
        }