Exemple #1
0
        static void selectNextReference()
        {
            bool[] array =
            {
                MarkerManager.IsMarkerVisible(MarkerType.CoM),
                MarkerManager.IsMarkerVisible(MarkerType.DCoM),
                MarkerManager.IsMarkerVisible(MarkerType.ACoM)
            };
            if (!array.Any(o => o))
            {
                return;
            }
            int  i     = (int)RCSBuildAid.ReferenceType;
            bool found = false;

            for (int j = 0; j < 3; j++)
            {
                i = LoopIndexSelect(0, 2, i);
                if (array [i])
                {
                    found = true;
                    break;
                }
            }
            if (found)
            {
                RCSBuildAid.SetReferenceMarker((MarkerType)i);
            }
        }
Exemple #2
0
        void onEditorPartEvent(ConstructionEventType evt, Part part)
        {
            //MonoBehaviour.print (evt.ToString ());
            OnPartChanged();
            switch (evt)
            {
            case ConstructionEventType.PartPicked:
                if (part == EditorLogic.RootPart)
                {
                    OnRootPartPicked();
                }
                break;

            case ConstructionEventType.PartDropped:
                if (part == EditorLogic.RootPart)
                {
                    OnRootPartDropped();
                }
                break;

            case ConstructionEventType.PartDeleted:
                if (part == EditorLogic.RootPart)
                {
                    RCSBuildAid.SetActive(false);
                }
                break;
            }
        }
Exemple #3
0
        void togglePlugin(ClickEvent evnt)
        {
            bool b = !RCSBuildAid.Enabled;

            RCSBuildAid.SetActive(b);
            setTexture(b);
        }
 protected override void onToggle()
 {
     if (!value)
     {
         RCSBuildAid.SetDirection(Direction.none);
     }
 }
Exemple #5
0
 protected override void content()
 {
     /* markers toggles */
     GUILayout.BeginVertical();
     {
         GUILayout.BeginHorizontal();
         {
             for (int i = 0; i < 3; i++)
             {
                 MarkerType marker        = (MarkerType)i;
                 bool       visibleBefore = RCSBuildAid.isMarkerVisible(marker);
                 bool       visibleAfter  = GUILayout.Toggle(visibleBefore, marker.ToString());
                 if (visibleBefore != visibleAfter)
                 {
                     RCSBuildAid.setMarkerVisibility(marker, visibleAfter);
                 }
             }
         }
         GUILayout.EndHorizontal();
         GUILayout.BeginHorizontal();
         {
             GUILayout.Label("Size", MainWindow.style.sizeLabel);
             Settings.marker_scale = GUILayout.HorizontalSlider(Settings.marker_scale, 0, 1);
         }
         GUILayout.EndHorizontal();
     }
     GUILayout.EndVertical();
 }
Exemple #6
0
        void Update()
        {
            Debug.Assert(module != null, "[RCSBA, RCSForce]: module is null");
            Debug.Assert(module.thrusterTransforms != null, "[RCSBA, RCSForce]: thrustTransforms is null");
            Debug.Assert(vectors != null, "[RCSBA, RCSForce]: Vectors weren't initialized");
            Debug.Assert(vectors.Length == thrustTransforms.Count,
                         "[RCSBA, RCSForce]: Number of vectors doesn't match the number of transforms");
            Profiler.BeginSample("[RCSBA] RCSForce Update");

            VectorGraphic vector;
            Transform     thrusterTransform;
            float         magnitude;
            Vector3       thrustDirection;

            Vector3 directionVector = getDirection();
            Vector3 rotationVector  = getRotation();

            try {
                /* calculate forces applied in the specified direction  */
                for (int t = 0; t < module.thrusterTransforms.Count; t++)
                {
                    vector            = vectors [t];
                    thrusterTransform = module.thrusterTransforms [t];
                    if (!module.rcsEnabled || (thrusterTransform.position == Vector3.zero))
                    {
                        vector.value   = Vector3.zero;
                        vector.enabled = false;
                        continue;
                    }
                    if (controlAttitude)
                    {
                        Vector3 lever = thrusterTransform.position - RCSBuildAid.ReferenceMarker.transform.position;
                        directionVector = Vector3.Cross(lever.normalized, rotationVector) * -1;
                    }
                    /* RCS usually use up as thrust direction */
                    thrustDirection = module.useZaxis ? thrusterTransform.forward : thrusterTransform.up;
                    magnitude       = Mathf.Max(Vector3.Dot(thrustDirection, directionVector), 0f);
                    if (module.fullThrust && (module.fullThrustMin <= magnitude))
                    {
                        magnitude = 1;
                    }
                    magnitude = Mathf.Clamp(magnitude, 0f, 1f) * getThrust();
                    Vector3 vectorThrust = thrustDirection * magnitude;

                    /* update VectorGraphic */
                    vector.value = vectorThrust;
                    /* show it if there's force */
                    if (enabled)
                    {
                        vector.enabled = (magnitude > 0f);
                    }
                }
            } catch (NullReferenceException e) {
                /* for catch an issue with a SSTU RCS */
                Debug.LogError(String.Format("[RCSBA, RCSForce]: {0}", e));
                RCSBuildAid.SetActive(false);
            }
            Profiler.EndSample();
        }
Exemple #7
0
 void nextModeButton(string modeName, int step)
 {
     if (GUILayout.Button(modeName, style.mainButton, GUILayout.Width(20)))
     {
         int i = getPluginModeIndex() + step;
         RCSBuildAid.SetMode(getEnabledPluginMode(i));
     }
 }
Exemple #8
0
        public Vector3 Torque(MarkerType reference)
        {
            Vector3    thrust, torque;
            GameObject marker = RCSBuildAid.GetMarker(reference);

            calcMarkerForces(marker.transform, out thrust, out torque);
            return(torque);
        }
        void Start()
        {
            initMarkers();  /* must be in Start because CoMmarker is null in Awake */
            RCSBuildAid.SetReferenceMarker(RCSBuildAid.ReferenceType);
            activateMarkers(RCSBuildAid.Enabled);

            Events.PluginToggled += onPluginToggled;
        }
Exemple #10
0
 public static void TranslationButton()
 {
     if (GUILayout.Button(translationMap [RCSBuildAid.Direction], MainWindow.style.smallButton))
     {
         int i = (int)RCSBuildAid.Direction;
         i = LoopIndexSelect(1, 6, i);
         RCSBuildAid.SetDirection((Direction)i);
     }
 }
Exemple #11
0
 public static void referenceButton()
 {
     if (GUILayout.Button(RCSBuildAid.referenceMarker.ToString(), MainWindow.style.smallButton))
     {
         selectNextReference();
     }
     else if (!RCSBuildAid.isMarkerVisible(RCSBuildAid.referenceMarker))
     {
         selectNextReference();
     }
 }
        protected override void content()
        {
            GUILayout.BeginHorizontal();
            {
                GUILayout.Label("Rotation", MainWindow.style.readoutName);
                MainWindow.RotationButton();
            }
            GUILayout.EndHorizontal();
            var includeRCS = GUILayout.Toggle(RCSBuildAid.IncludeRCS, "Include RCS");

            RCSBuildAid.SetIncludeRCS(includeRCS);
        }
        void Start()
        {
            initMarkers();  /* must be in Start because CoMmarker is null in Awake */
            RCSBuildAid.SetReferenceMarker(RCSBuildAid.ReferenceType);
            activateMarkers(RCSBuildAid.Enabled);

            Events.PluginToggled += onPluginToggled;
            Events.ModeChanged   += onModeChange;
            Events.PodDeleted    += onPodDeleted;
            Events.PodPicked     += onPodPicked;
            Events.EditorStart   += onEditorStart;
        }
Exemple #14
0
 public static void RotationButtonWithReset()
 {
     GUILayout.BeginHorizontal(); {
         if (GUILayout.Button(rotationMap [RCSBuildAid.Direction], MainWindow.style.smallButton))
         {
             int i = (int)RCSBuildAid.Direction;
             i = MainWindow.LoopIndexSelect(1, 6, i);
             RCSBuildAid.SetDirection((Direction)i);
         }
         if (GUILayout.Button("R", MainWindow.style.squareButton))
         {
             RCSBuildAid.SetDirection(Direction.none);
         }
     } GUILayout.EndHorizontal();
 }
Exemple #15
0
 void onEditorScreenChanged(EditorScreen screen)
 {
     /* the plugin isn't useful in all the editor screens */
     if (EditorScreen.Parts == screen)
     {
         setSoftActive(true);
         RCSBuildAid.SetActive(false);
     }
     else if (Settings.action_screen && (EditorScreen.Actions == screen))
     {
         setSoftActive(true);
         RCSBuildAid.SetActive(false);
     }
     else
     {
         setSoftActive(false);
     }
 }
Exemple #16
0
        static void selectNextReference()
        {
            bool[] array =
            {
                RCSBuildAid.isMarkerVisible(MarkerType.CoM),
                RCSBuildAid.isMarkerVisible(MarkerType.DCoM),
                RCSBuildAid.isMarkerVisible(MarkerType.ACoM)
            };
            if (!array.Any(o => o))
            {
                return;
            }
            int  i     = (int)RCSBuildAid.referenceMarker;
            bool found = false;

            for (int j = 0; j < 3; j++)
            {
                if (Event.current.button == 1)
                {
                    i -= 1;
                    if (i < 0)
                    {
                        i = 2;
                    }
                }
                else
                {
                    i += 1;
                    if (i > 2)
                    {
                        i = 0;
                    }
                }
                if (array [i])
                {
                    found = true;
                    break;
                }
            }
            if (found)
            {
                RCSBuildAid.SetReferenceMarker((MarkerType)i);
            }
        }
Exemple #17
0
        void drawModeSelectList()
        {
            GUILayout.BeginVertical(GUI.skin.box);
            {
                int r = Mathf.CeilToInt(plugin_mode_count / 2f);
                int i = 0;

                GUILayout.BeginHorizontal();
                {
                    while (i < plugin_mode_count)
                    {
                        GUILayout.BeginVertical();
                        {
                            for (int j = 0; (j < r) && (i < plugin_mode_count); j++)
                            {
                                PluginMode mode = getEnabledPluginMode(i);
                                if (GUILayout.Button(getModeButtonName(mode), style.clickLabel))
                                {
                                    modeSelect = false;
                                    RCSBuildAid.SetMode(mode);
                                }
                                i++;
                            }
                        }
                        GUILayout.EndVertical();
                    }
                }
                GUILayout.EndHorizontal();
                if (GUILayout.Button("None", style.clickLabelCenter))
                {
                    modeSelect = false;
                    RCSBuildAid.SetMode(PluginMode.none);
                }
            }
            GUILayout.EndVertical();
        }
 public RCSBuildAid()
 {
     instance = this;
 }
Exemple #19
0
 void onEditorRestart()
 {
     RCSBuildAid.SetActive(false);
 }
Exemple #20
0
 void onFalse()
 {
     RCSBuildAid.SetActive(false);
 }
Exemple #21
0
 void onTrue()
 {
     RCSBuildAid.SetActive(true);
 }