예제 #1
0
        void AlterEditorSpace(EditorLogic editor)
        {
            //maxheight gone in 0.21
            //editor.maxHeight = 2000;

            // Modify cameras/available interior space
            if (HighLogic.LoadedScene == GameScenes.EDITOR)
            {
                DebugMessage("Updating VAB dimensions and camera");

                VABCamera VABcam = Camera.main.GetComponent <VABCamera>();
                VABcam.maxHeight   = 2000;
                VABcam.maxDistance = 2000;

                GameObject interior = GameObject.Find(VABGameObjectName);
                interior.transform.localScale = new Vector3(2.2f, 1.8f, 1.8f);
                interior.transform.position   = new Vector3(59f, 51.5f, 12);
            }
            else if (HighLogic.LoadedScene == GameScenes.SPH)
            {
                DebugMessage("Updating SPH dimensions and camera");

                SPHCamera SPHcam = Camera.main.GetComponent <SPHCamera>();
                SPHcam.maxHeight    = 2000;
                SPHcam.maxDistance  = 2000;
                SPHcam.maxDisplaceX = 2000;
                SPHcam.maxDisplaceZ = 2000;

                GameObject interior = GameObject.Find(SPHGameObjectName);
                interior.transform.localScale = new Vector3(12, 6, 12);
                interior.transform.position   = new Vector3(-24.9f, -0.3f, 22.8f);
            }
        }
예제 #2
0
        void ResetCamera()
        {
            if (!GizmoActive())
            {
                //editor.editorCamera

                VABCamera VABcam = Camera.main.GetComponent <VABCamera> ();
                VABcam.camPitch = 0;
                VABcam.camHdg   = 0;
                //VABcam.transform.position.y = 9f;

                SPHCamera SPHcam = Camera.main.GetComponent <SPHCamera> ();
                SPHcam.camPitch = 0;
                SPHcam.camHdg   = 0;
                //SPHcam.transform.position.y = 9f;
            }
            return;
        }
예제 #3
0
        public void Update()
        {
            //Idea: change root part.

            //need to verify the EditorLogic state - do we need to fetch it every time?
            editor = EditorLogic.fetch;
            if (editor == null)
            {
                return;
            }

            if (ignoreHotKeys || editor.editorScreen != EditorLogic.EditorScreen.Parts)
            {
                return;
            }

            //may need to go away from this and do explicit editor.editorType calls
            inVAB = (editor.editorType == EditorLogic.EditorMode.VAB);

            //check for the various alt/mod etc keypresses
            altKeyPressed = Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt) || Input.GetKey(KeyCode.AltGr);
            //check for shift key
            shiftKeyPressed = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);

            //Space - when no part is selected, reset camera
            if (Input.GetKeyDown(KeyCode.Space) && !editor.PartSelected)
            {
                if (HighLogic.LoadedScene == GameScenes.EDITOR)
                {
                    VABCamera VABcam = Camera.main.GetComponent <VABCamera>();
                    VABcam.camPitch = 0;
                    VABcam.camHdg   = 0;
                    //VABcam.ResetCamera();
                }
                else if (HighLogic.LoadedScene == GameScenes.SPH)
                {
                    SPHCamera SPHcam = Camera.main.GetComponent <SPHCamera>();
                    SPHcam.camPitch = 0;
                    SPHcam.camHdg   = 0;
                    //SPHcam.ResetCamera();
                }
            }

            // Alt+M - Toggle VAB/SPH editor mode (while staying in the same hangar)
            if (Input.GetKeyDown(KeyCode.Tab))
            {
                if (editor.editorType == EditorLogic.EditorMode.SPH)
                {
                    editor.editorType     = EditorLogic.EditorMode.VAB;
                    editor.launchSiteName = launchSiteName_LaunchPad;
                    OSDMessage("VAB/Launchpad Mode", 1);
                }
                else
                {
                    editor.editorType     = EditorLogic.EditorMode.SPH;
                    editor.launchSiteName = launchSiteName_Runway;
                    editor.symmetryMode   = 1;
                    OSDMessage("SPH/Runway Mode", 1);
                }
                return;
            }

            // V - Vertical alignment toggle
            if (Input.GetKeyDown(KeyCode.V))
            {
                //DebugMessage ("Toggling vertical snap");
                GameSettings.VAB_ANGLE_SNAP_INCLUDE_VERTICAL ^= true;

                //if normal radial angle snap is currently off, vertical snap will have no effect unless it is re-enabled
                //automatically set aangle snap to minimum - some people thought vert snap was broken in this situation, the game doesn't appear to allow it
                if (GameSettings.VAB_USE_ANGLE_SNAP == false && GameSettings.VAB_ANGLE_SNAP_INCLUDE_VERTICAL == true)
                {
                    DebugMessage("Enabling angle snap to allow vertical snap to work");
                    //angle snap needs be > 0, otherwise log is spammed with DivideByZero errors
                    if (editor.srfAttachAngleSnap == 0)
                    {
                        editor.srfAttachAngleSnap = 1;
                    }
                    GameSettings.VAB_USE_ANGLE_SNAP = true;
                }
                OSDMessage("Vertical snap " + (GameSettings.VAB_ANGLE_SNAP_INCLUDE_VERTICAL ? "enabled" : "disabled"), 1);
                DebugMessage("Vertical snap " + (GameSettings.VAB_ANGLE_SNAP_INCLUDE_VERTICAL ? "enabled" : "disabled"));
                return;
            }

            // ALT+R : Toggle radial/surface attachment globally
            // When part is selected, also toggles surface attachment for that part, even if that part's cfg has it disabled.
            if (altKeyPressed && Input.GetKeyDown(KeyCode.R))
            {
                if (EditorLogic.SelectedPart)
                {
                    //Toggle surface attachment for selected part, set global surface attachment toggle to match
                    EditorLogic.SelectedPart.attachRules.srfAttach ^= true;
                    editor.allowSrfAttachment = EditorLogic.SelectedPart.attachRules.srfAttach;
                    DebugMessage("Toggling srfAttach for " + EditorLogic.SelectedPart.name);
                    OSDMessage(String.Format("Surface attachment {0}, and for {1}"
                                             , EditorLogic.SelectedPart.attachRules.srfAttach ? "enabled" : "disabled"
                                             , EditorLogic.SelectedPart.name
                                             ), 1);
                }
                else
                {
                    //just toggle global surface attachment, parts whose config do not allow it are unaffected
                    editor.allowSrfAttachment ^= true;
                    OSDMessage("Allow surface attachment is globally " + (editor.allowSrfAttachment ? "enabled" : "disabled"), 1);
                    DebugMessage("Allow surface attachment is globally " + (editor.allowSrfAttachment ? "enabled" : "disabled"));
                }
            }

            // ALT+Z : Toggle part clipping (From cheat options)
            if (altKeyPressed && Input.GetKeyDown(KeyCode.Z))
            {
                CheatOptions.AllowPartClipping ^= true;
                DebugMessage("AllowPartClipping " + (CheatOptions.AllowPartClipping ? "enabled" : "disabled"));
                OSDMessage("Part clipping " + (CheatOptions.AllowPartClipping ? "enabled" : "disabled"), 1);
                return;
            }

            // C, Shift+C : Increment/Decrement Angle snap
            if (Input.GetKeyDown(KeyCode.C))
            {
                if (!altKeyPressed)
                {
                    //GameSettings.VAB_USE_ANGLE_SNAP = false;
                    DebugMessage("Starting srfAttachAngleSnap = " + editor.srfAttachAngleSnap.ToString());

                    int currentAngleIndex = Array.IndexOf(angle, editor.srfAttachAngleSnap);

                    DebugMessage("currentAngleIndex: " + currentAngleIndex.ToString());

                    float newAngle;
                    if (shiftKeyPressed)
                    {
                        newAngle = angle [currentAngleIndex == 0 ? angle.Length - 1 : currentAngleIndex - 1];
                    }
                    else
                    {
                        DebugMessage("new AngleIndex: " + (currentAngleIndex == angle.Length - 1 ? 0 : currentAngleIndex + 1).ToString());
                        newAngle = angle [currentAngleIndex == angle.Length - 1 ? 0 : currentAngleIndex + 1];
                    }

                    DebugMessage("Setting srfAttachAngleSnap to " + newAngle.ToString());
                    editor.srfAttachAngleSnap = newAngle;
                }
                else
                {
                    DebugMessage("Resetting srfAttachAngleSnap to 0");
                    editor.srfAttachAngleSnap = 0;
                }

                if (editor.srfAttachAngleSnap == 0)
                {
                    GameSettings.VAB_USE_ANGLE_SNAP = false;
                    //Vertical snap doesn't work when angle snap is disabled.
                    //Resetting it here so that the toggle logic for vert snap maintains state
                    GameSettings.VAB_ANGLE_SNAP_INCLUDE_VERTICAL = false;
                    editor.angleSnapSprite.PlayAnim(0);
                }
                else
                {
                    GameSettings.VAB_USE_ANGLE_SNAP = true;
                }

                DebugMessage("Exiting srfAttachAngleSnap = " + editor.srfAttachAngleSnap.ToString());
                return;
            }

            // X, Shift+X : Increment/decrement symmetry mode
            if (inVAB && Input.GetKeyDown(KeyCode.X))
            {
                if (altKeyPressed || (_symmetryMode < 2 && shiftKeyPressed))
                {
                    //Alt+X or Symmetry is at 1(index 2) or lower
                    _symmetryMode = 0;
                }
                else if (_symmetryMode > maxSymmetryMode - 2 && !shiftKeyPressed)
                {
                    //Stop adding at max symmetry
                    _symmetryMode = maxSymmetryMode - 1;
                }
                else
                {
                    //inc/dec symmetry
                    _symmetryMode = _symmetryMode + (shiftKeyPressed ? -1 : 1);
                }

                DebugMessage("Setting symmetry to " + _symmetryMode.ToString());
                editor.symmetryMode = _symmetryMode;
            }
        }