Ejemplo n.º 1
0
        //Game and editor shares this method
        public void MoveAndRotatePlayerOrCamera(MyGuiInput input)
        {
            // Don't move camera on screenshot
            if (MyGuiManager.GetScreenshot() != null)
                return;

            bool afterburner = false;

            float rollIndicator = input.GetRoll();
            Vector2 rotationIndicator = input.GetRotation();
            Vector3 moveIndicator = input.GetPositionDelta();

            if (MyVideoModeManager.IsHardwareCursorUsed() && MyMinerGame.Static.IsMouseVisible)
                rotationIndicator = Vector2.Zero;


            if (IsGameActive()) if (input.IsGameControlPressed(MyGameControlEnums.AFTERBURNER)) afterburner = true;

            ////////////////////////////////////////////////////////////////////////////////////////////////////////////
            //  Decide who is moving
            ////////////////////////////////////////////////////////////////////////////////////////////////////////////

            if (CameraAttachedTo == MyCameraAttachedToEnum.Spectator)
            {
                if (IsEditorActive())
                {
                    //DrawMouseCursor = false; 
                    if (MyConfig.EditorUseCameraCrosshair == false)
                    {
                        if (input.IsRightMousePressed() == false)
                        {
                            rotationIndicator = Vector2.Zero;
                            //Summary	0000835: Editor - camera / spectator - different rotation equations -- rotate even when button is not pressed
                            //rollIndicator = 0f;
                            DrawMouseCursor = true;
                        }
                        else
                        {
                            if (input.IsNewRightMousePressed() && MyVideoModeManager.IsHardwareCursorUsed())
                                rotationIndicator = Vector2.Zero;
                            DrawMouseCursor = false;
                            if (MyVideoModeManager.IsHardwareCursorUsed())
                                MyGuiInput.SetMouseToScreenCenter();
                        }
                    }
                    else
                    {
                        if (input.IsNewMiddleMousePressed() && MyVideoModeManager.IsHardwareCursorUsed())
                            rotationIndicator = Vector2.Zero;

                        if (MyEditorGizmo.IsRotationActive())
                        {
                            rotationIndicator = Vector2.Zero;
                            rollIndicator = 0f;
                            DrawMouseCursor = true;
                        }
                        else
                        {
                            DrawMouseCursor = false;
                            MyGuiInput.SetMouseToScreenCenter();
                        }
                    }
                }

                MySpectator.MoveAndRotate(moveIndicator, rotationIndicator, rollIndicator, (afterburner ? 1.0f : 0.35f) * (input.IsAnyCtrlKeyPressed() ? 0.3f : 1));
            }

            if (CameraAttachedTo == MyCameraAttachedToEnum.PlayerMinerShip_ThirdPersonDynamic)
            {
                MyThirdPersonSpectator.SetState(moveIndicator, rotationIndicator, rollIndicator);
                MyThirdPersonSpectator.QuickZoom = input.IsAnyAltKeyPressed();
            }

            // disable mouse rotation if we are in weapon select mode(cursor on)
            if ((m_selectAmmoMenu.IsEnabled && IsSelectAmmoVisible() || GetDrawMouseCursor()))
                rotationIndicator = Vector2.Zero;

            if (MySession.Static != null && MySession.Static.Player != null && !MySession.Static.Player.IsDead())
            {
                switch (CameraAttachedTo)
                {
                    case MyCameraAttachedToEnum.BotMinerShip:
                        if (ShipForSimpleTesting != null)
                            ShipForSimpleTesting.MoveAndRotate(moveIndicator, rotationIndicator, 0f, afterburner);
                        break;

                    case MyCameraAttachedToEnum.Drone:
                        ControlledDrone.MoveAndRotate(moveIndicator, rotationIndicator, rollIndicator, afterburner);
                        break;
                    case MyCameraAttachedToEnum.Camera:
                        {
                            ControlledCamera.HandleInput(rotationIndicator);
                        }
                        break;

                    case MyCameraAttachedToEnum.LargeWeapon:
                        {
                            ControlledLargeWeapon.MoveAndRotate(moveIndicator, rotationIndicator, rollIndicator, afterburner);
                        }
                        break;

                    case MyCameraAttachedToEnum.PlayerMinerShip_ThirdPersonDynamic:
                    case MyCameraAttachedToEnum.PlayerMinerShip_ThirdPersonStatic:
                    case MyCameraAttachedToEnum.PlayerMinerShip_ThirdPersonFollowing:
                    case MyCameraAttachedToEnum.PlayerMinerShip:
                        if (MySession.PlayerShip != null)
                            MySession.PlayerShip.MoveAndRotate(moveIndicator, rotationIndicator, rollIndicator, afterburner);
                        break;
                }
            }
            if (MyVideoModeManager.IsHardwareCursorUsed() && GetDrawMouseCursor() == false && !MyMinerGame.Static.IsMouseVisible)
                MyGuiInput.SetMouseToScreenCenter();
        }