Exemplo n.º 1
0
 void activateMarkers(bool value)
 {
     CoM.SetActive(value);
     DCoM.SetActive(value);
     ACoM.SetActive(value);
     if (value && (RCSBuildAid.Mode == PluginMode.Parachutes))
     {
         CoD.SetActive(true);
     }
     else
     {
         CoD.SetActive(false);
     }
 }
Exemplo n.º 2
0
        void Update()
        {
            bool disableShortcuts = EditorUtils.isInputFieldFocused();

            if (!disableShortcuts && PluginKeys.PLUGIN_TOGGLE.GetKeyDown())
            {
                SetActive(!Enabled);
            }

            if (Enabled)
            {
                bool b = (Mode == PluginMode.Parachutes);
                if (CoD.activeInHierarchy != b)
                {
                    CoD.SetActive(b);
                }
            }
            else if (CoD.activeInHierarchy)
            {
                CoD.SetActive(false);
            }

            if (Enabled)
            {
                updateModuleLists();
                addForces();
                //EditorUtils.RunOnAllParts (addDragVectors);

                /* find the bottommost stage with engines */
                int stage = 0;
                foreach (PartModule mod in engineList)
                {
                    if (mod.part.inverseStage > stage)
                    {
                        stage = mod.part.inverseStage;
                    }
                }
                LastStage = stage;

                /* Switching direction */
                if (!disableShortcuts && Input.anyKeyDown)
                {
                    if (ExtendedInput.GetKey(PluginKeys.TRANSLATE_UP))
                    {
                        switchDirection(Direction.up);
                    }
                    else if (ExtendedInput.GetKey(PluginKeys.TRANSLATE_DOWN))
                    {
                        switchDirection(Direction.down);
                    }
                    else if (ExtendedInput.GetKey(PluginKeys.TRANSLATE_FWD))
                    {
                        switchDirection(Direction.forward);
                    }
                    else if (ExtendedInput.GetKey(PluginKeys.TRANSLATE_BACK))
                    {
                        switchDirection(Direction.back);
                    }
                    else if (ExtendedInput.GetKey(PluginKeys.TRANSLATE_LEFT))
                    {
                        switchDirection(Direction.left);
                    }
                    else if (ExtendedInput.GetKey(PluginKeys.TRANSLATE_RIGHT))
                    {
                        switchDirection(Direction.right);
                    }
                }
            }
        }
Exemplo n.º 3
0
        void initMarkers()
        {
            /* get CoM */
            if (vesselOverlays.CoMmarker == null)
            {
                throw new Exception("CoM marker is null, this shouldn't happen.");
            }
            CoM = vesselOverlays.CoMmarker.gameObject;

            protoMarker = (GameObject)UnityEngine.Object.Instantiate(CoM);
            Destroy(protoMarker.GetComponent <EditorMarker_CoM> ()); /* we don't need this */
            protoMarker.name = "Marker Prototype";
            if (protoMarker.transform.childCount > 0)
            {
                /* Stock CoM doesn't have any attached objects, if there's some it means
                 * there's a plugin doing the same thing as us. We don't want extra
                 * objects */
                for (int i = 0; i < protoMarker.transform.childCount; i++)
                {
                    Destroy(protoMarker.transform.GetChild(i).gameObject);
                }
            }

            /* init DCoM */
            DCoM      = (GameObject)UnityEngine.Object.Instantiate(protoMarker);
            DCoM.name = "DCoM Marker";

            /* init ACoM */
            ACoM      = (GameObject)UnityEngine.Object.Instantiate(protoMarker);
            ACoM.name = "ACoM Marker";

            /* init CoD */
            CoD = (GameObject)UnityEngine.Object.Instantiate(protoMarker);

            referenceDict [MarkerType.CoM]  = CoM;
            referenceDict [MarkerType.DCoM] = DCoM;
            referenceDict [MarkerType.ACoM] = ACoM;

            /* CoM setup, replace stock component with our own */
            CoMMarker comMarker = CoM.AddComponent <CoMMarker> ();

            comMarker.posMarkerObject = vesselOverlays.CoMmarker.posMarkerObject;
            Destroy(vesselOverlays.CoMmarker);
            vesselOverlays.CoMmarker = comMarker;
            WetMass = comMarker;

            /* setup DCoM */
            DCoMMarker dcomMarker = DCoM.AddComponent <DCoMMarker> (); /* we do need this    */

            dcomMarker.posMarkerObject = DCoM;
            DryMass = dcomMarker;

            /* setup ACoM */
            var acomMarker = ACoM.AddComponent <AverageMarker> ();

            acomMarker.posMarkerObject = ACoM;
            acomMarker.CoM1            = comMarker;
            acomMarker.CoM2            = dcomMarker;

            /* setup CoD */
            var codMarker = CoD.AddComponent <CoDMarker> ();

            codMarker.posMarkerObject = CoD;
            CoD.SetActive(false);

            /* attach our method to the CoM toggle button */
            vesselOverlays.toggleCoMbtn.onClick.AddListener(delegate { comButtonClick(); });

            try {
                /* scaling for CoL and CoT markers */
                vesselOverlays.CoLmarker.gameObject.AddComponent <MarkerScaler> ();
                vesselOverlays.CoTmarker.gameObject.AddComponent <MarkerScaler> ();
            } catch (NullReferenceException) {
                Debug.LogWarning("CoL/CoT marker is null, this shouldn't happen.");
            }
        }
Exemplo n.º 4
0
 void onModeChange(PluginMode mode)
 {
     CoD.SetActive(mode == PluginMode.Parachutes);
 }
Exemplo n.º 5
0
        void setupMarker()
        {
            /* get CoM */
            if (vesselOverlays.CoMmarker == null)
            {
                gameObject.SetActive(false);
                throw new Exception("CoM marker is null, this shouldn't happen.");
            }
            CoM = vesselOverlays.CoMmarker.gameObject;

            /* init DCoM */
            DCoM = (GameObject)UnityEngine.Object.Instantiate(CoM);
            Destroy(DCoM.GetComponent <EditorMarker_CoM> ());           /* we don't need this */
            DCoM.name = "DCoM Marker";
            if (DCoM.transform.childCount > 0)
            {
                /* Stock CoM doesn't have any attached objects, if there's some it means
                 * there's a plugin doing the same thing as us. We don't want extra
                 * objects */
                for (int i = 0; i < DCoM.transform.childCount; i++)
                {
                    Destroy(DCoM.transform.GetChild(i).gameObject);
                }
            }

            /* init ACoM */
            ACoM      = (GameObject)UnityEngine.Object.Instantiate(DCoM);
            ACoM.name = "ACoM Marker";

            /* init CoD */
            CoD = (GameObject)UnityEngine.Object.Instantiate(DCoM);

            referenceDict[MarkerType.CoM]  = CoM;
            referenceDict[MarkerType.DCoM] = DCoM;
            referenceDict[MarkerType.ACoM] = ACoM;

            /* CoM setup, replace stock component with our own */
            CoMMarker comMarker = CoM.AddComponent <CoMMarker> ();

            comMarker.posMarkerObject = vesselOverlays.CoMmarker.posMarkerObject;
            Destroy(vesselOverlays.CoMmarker);
            vesselOverlays.CoMmarker = comMarker;

            /* setup DCoM */
            DCoMMarker dcomMarker = DCoM.AddComponent <DCoMMarker> (); /* we do need this    */

            dcomMarker.posMarkerObject = DCoM;

            /* setup ACoM */
            var acomMarker = ACoM.AddComponent <AverageMarker> ();

            acomMarker.posMarkerObject = ACoM;
            acomMarker.CoM1            = comMarker;
            acomMarker.CoM2            = dcomMarker;

            /* setup CoD */
            var codMarker = CoD.AddComponent <CoDMarker> ();

            codMarker.posMarkerObject = CoD;
            CoD.SetActive(false);

            var obj = new GameObject("Vessel Forces Object");

            obj.layer    = CoM.layer;
            vesselForces = obj.AddComponent <MarkerForces> ();
            SetReferenceMarker(ReferenceType);

            /* scaling for CoL and CoT markers */
            vesselOverlays.CoLmarker.gameObject.AddComponent <MarkerScaler> ();
            vesselOverlays.CoTmarker.gameObject.AddComponent <MarkerScaler> ();

            /* attach our method to the CoM toggle button */
            vesselOverlays.toggleCoMbtn.AddValueChangedDelegate(delegate { comButtonClick(); });
        }