Пример #1
0
 protected override void AddHudInfo()
 {
     if (!MyInput.Static.IsJoystickConnected())
     {
         m_grindingNotification.SetTextFormatArguments(MyInput.Static.GetGameControl(MyControlsSpace.PRIMARY_TOOL_ACTION));
     }
     else
     {
         m_grindingNotification.SetTextFormatArguments(MyControllerHelper.GetCodeForControl(MySpaceBindingCreator.CX_CHARACTER, MyControlsSpace.PRIMARY_TOOL_ACTION));
     }
     MyHud.Notifications.Add(m_grindingNotification);
 }
        MyActionDescription IMyUseObject.GetActionInfo(UseActionEnum actionEnum)
        {
            var key = MyInput.Static.GetGameControl(MyControlsSpace.USE).GetControlButtonName(MyGuiInputDeviceEnum.Keyboard);

            return(new MyActionDescription()
            {
                Text = MySpaceTexts.NotificationPickupObject,
                FormatParams = new object[] { MyInput.Static.GetGameControl(MyControlsSpace.USE), m_displayedText },
                IsTextControlHint = false,
                JoystickFormatParams = new object[] { MyControllerHelper.GetCodeForControl(MySpaceBindingCreator.CX_CHARACTER, MyControlsSpace.USE), m_displayedText },
            });
        }
Пример #3
0
 public override void HandleInput(bool receivedFocusInThisUpdate)
 {
     base.HandleInput(receivedFocusInThisUpdate);
     if (!receivedFocusInThisUpdate && MyGuiScreenGamePlay.Static != null && MyControllerHelper.IsControl(MySpaceBindingCreator.CX_GUI, MyControlsGUI.MAIN_MENU))
     {
         CloseScreen();
     }
     if (MyControllerHelper.IsControl(MySpaceBindingCreator.CX_GUI, MyControlsGUI.BUTTON_X))
     {
         ShowCurrentNews();
     }
 }
Пример #4
0
        public virtual void HandleInput(bool receivedFocusInThisUpdate)
        {
            //  Here we can make some one-time initialization hidden in update
            bool isThisFirstHandleInput = !m_firstUpdateServed;

            if (m_firstUpdateServed == false && FocusedControl == null) //m_keyboardControlIndex could be set from constructor
            {
                FocusedControl = GetFirstFocusableControl();

                //  Never again call this update-initialization (except if RecreateControls() is called, which resets this)
                m_firstUpdateServed = true;
            }

            if (!HandleControlsInput(receivedFocusInThisUpdate))
            {
                bool handled = false;
                //  If input wasn't completely handled or captured by some control, only then we can handle screen's input
                if ((MyInput.Static.IsKeyPress(MyKeys.LeftShift) && MyInput.Static.IsNewKeyPressed(MyKeys.Tab)) ||
                    MyInput.Static.IsNewKeyPressed(MyKeys.Up) ||
                    (MyInput.Static.IsNewKeyPressed(MyKeys.Left) && !(FocusedControl is MyGuiControlSlider)) ||
                    (MyControllerHelper.IsControl(MyControllerHelper.CX_GUI, MyControlsGUI.MOVE_UP) && m_defaultJoystickDpadUse))
                {
                    handled = HandleKeyboardActiveIndex(false);
                }
                else if (MyInput.Static.IsNewKeyPressed(MyKeys.Tab) ||
                         MyInput.Static.IsNewKeyPressed(MyKeys.Down) ||
                         (MyInput.Static.IsNewKeyPressed(MyKeys.Right) && !(FocusedControl is MyGuiControlSlider)) ||
                         (MyControllerHelper.IsControl(MyControllerHelper.CX_GUI, MyControlsGUI.MOVE_DOWN) && m_defaultJoystickDpadUse))
                {
                    handled = HandleKeyboardActiveIndex(true);
                }
                else if ((m_closeOnEsc == true) && ((MyInput.Static.IsNewKeyPressed(MyKeys.Escape) || MyControllerHelper.IsControl(MyControllerHelper.CX_GUI, MyControlsGUI.MAIN_MENU)) ||
                                                    (m_defaultJoystickCancelUse && MyControllerHelper.IsControl(MyControllerHelper.CX_GUI, MyControlsGUI.CANCEL))))
                {
                    Canceling();
                }

                if (!handled)
                {
                    HandleUnhandledInput(receivedFocusInThisUpdate);
                }
                else if (m_defaultJoystickDpadUse && FocusedControl != null)
                {
                    if (MyControllerHelper.IsControl(MyControllerHelper.CX_GUI, MyControlsGUI.MOVE_UP) ||
                        MyControllerHelper.IsControl(MyControllerHelper.CX_GUI, MyControlsGUI.MOVE_DOWN))
                    {
                        var coords = MyGuiManager.GetScreenCoordinateFromNormalizedCoordinate(FocusedControl.GetPositionAbsoluteCenter());
                        MyInput.Static.SetMousePosition((int)coords.X, (int)coords.Y);
                    }
                }
            }
        }
 private static void CreateForBuildMode()
 {
     MyControllerHelper.AddContext(CX_BUILD_MODE, CX_CHARACTER);
     MyControllerHelper.AddControl(CX_BUILD_MODE, MyControlsSpace.CUBE_COLOR_CHANGE, MyJoystickButtonsEnum.J01);
     MyControllerHelper.AddControl(CX_BUILD_MODE, MyControlsSpace.USE_SYMMETRY, MyJoystickButtonsEnum.J03);
     MyControllerHelper.AddControl(CX_BUILD_MODE, MyControlsSpace.SYMMETRY_SWITCH, MyJoystickButtonsEnum.J04);
     MyControllerHelper.AddControl(CX_BUILD_MODE, MyControlsSpace.CUBE_ROTATE_ROLL_POSITIVE, MyJoystickButtonsEnum.J05);
     MyControllerHelper.AddControl(CX_BUILD_MODE, MyControlsSpace.CUBE_ROTATE_ROLL_NEGATIVE, MyJoystickButtonsEnum.J06);
     MyControllerHelper.AddControl(CX_BUILD_MODE, MyControlsSpace.CUBE_ROTATE_VERTICAL_POSITIVE, MyJoystickAxesEnum.Xneg);
     MyControllerHelper.AddControl(CX_BUILD_MODE, MyControlsSpace.CUBE_ROTATE_VERTICAL_NEGATIVE, MyJoystickAxesEnum.Xpos);
     MyControllerHelper.AddControl(CX_BUILD_MODE, MyControlsSpace.CUBE_ROTATE_HORISONTAL_POSITIVE, MyJoystickAxesEnum.Yneg);
     MyControllerHelper.AddControl(CX_BUILD_MODE, MyControlsSpace.CUBE_ROTATE_HORISONTAL_NEGATIVE, MyJoystickAxesEnum.Ypos);
 }
Пример #6
0
 public override void HandleInput()
 {
     base.HandleInput();
     if ((MyScreenManager.GetScreenWithFocus() is MyGuiScreenGamePlay) && MyControllerHelper.IsControl(MySpaceBindingCreator.CX_CHARACTER, MyControlsSpace.PRIMARY_TOOL_ACTION, MyControlStateType.NEW_PRESSED, false))
     {
         if ((MySession.Static.ControlledEntity != null) && (this.BotToSpawn != null))
         {
             this.TrySpawnBot();
         }
         if ((MySession.Static.ControlledEntity != null) && (this.CommandDefinition != null))
         {
             this.UseCommand();
         }
     }
 }
Пример #7
0
        public override void HandleInput()
        {
            base.HandleInput();

            if (!(MyScreenManager.GetScreenWithFocus() is MyGuiScreenGamePlay))
                return;

            if (MyControllerHelper.IsControl(MySpaceBindingCreator.CX_CHARACTER, MyControlsSpace.PRIMARY_TOOL_ACTION))
            {
                if (MySession.Static.ControlledEntity != null && BotToSpawn != null)
                    TrySpawnBot();
                if (MySession.Static.ControlledEntity != null && CommandDefinition != null)
                    UseCommand();
            }
        }
Пример #8
0
 public override void HandleInput()
 {
     if ((this.m_isActive && (MyScreenManager.GetScreenWithFocus() is MyGuiScreenGamePlay)) && ((MyInput.Static.ENABLE_DEVELOPER_KEYS || !MySession.Static.SurvivalMode) || MySession.Static.IsUserAdmin(Sync.MyId)))
     {
         base.HandleInput();
         if (MyControllerHelper.IsControl(MySpaceBindingCreator.CX_CHARACTER, MyControlsSpace.PRIMARY_TOOL_ACTION, MyControlStateType.NEW_PRESSED, false))
         {
             this.m_startTime = MySandboxGame.TotalGamePlayTimeInMilliseconds;
         }
         if (MyControllerHelper.IsControl(MySpaceBindingCreator.CX_CHARACTER, MyControlsSpace.PRIMARY_TOOL_ACTION, MyControlStateType.NEW_RELEASED, false))
         {
             MyObjectBuilder_CubeGrid[] gridPrefab = MyPrefabManager.Static.GetGridPrefab(this.CurrentDefinition.PrefabToThrow);
             Vector3D zero    = Vector3D.Zero;
             Vector3D forward = Vector3D.Zero;
             if (USE_SPECTATOR_FOR_THROW)
             {
                 zero    = MySpectator.Static.Position;
                 forward = MySpectator.Static.Orientation.Forward;
             }
             else if ((MySession.Static.GetCameraControllerEnum() != MyCameraControllerEnum.ThirdPersonSpectator) && (MySession.Static.GetCameraControllerEnum() != MyCameraControllerEnum.Entity))
             {
                 zero    = MySector.MainCamera.Position;
                 forward = MySector.MainCamera.WorldMatrix.Forward;
             }
             else
             {
                 if (MySession.Static.ControlledEntity == null)
                 {
                     return;
                 }
                 zero    = MySession.Static.ControlledEntity.GetHeadMatrix(true, true, false, false).Translation;
                 forward = MySession.Static.ControlledEntity.GetHeadMatrix(true, true, false, false).Forward;
             }
             Vector3D vectord3 = zero + forward;
             Vector3D vectord4 = (forward * MathHelper.Clamp(((((float)(MySandboxGame.TotalGamePlayTimeInMilliseconds - this.m_startTime)) / 1000f) / this.CurrentDefinition.PushTime) * this.CurrentDefinition.MaxSpeed, this.CurrentDefinition.MinSpeed, this.CurrentDefinition.MaxSpeed)) + MySession.Static.ControlledEntity.Entity.Physics.LinearVelocity;
             float    num2     = 0f;
             if (this.CurrentDefinition.Mass != null)
             {
                 num2 = MyDestructionHelper.MassToHavok(this.CurrentDefinition.Mass.Value);
             }
             gridPrefab[0].EntityId = MyEntityIdentifier.AllocateId(MyEntityIdentifier.ID_OBJECT_TYPE.ENTITY, MyEntityIdentifier.ID_ALLOCATION_METHOD.RANDOM);
             EndpointId targetEndpoint = new EndpointId();
             Vector3D?  position       = null;
             MyMultiplayer.RaiseStaticEvent <MyObjectBuilder_CubeGrid, Vector3D, Vector3D, float, MyCueId>(s => new Action <MyObjectBuilder_CubeGrid, Vector3D, Vector3D, float, MyCueId>(MySessionComponentThrower.OnThrowMessageSuccess), gridPrefab[0], vectord3, vectord4, num2, this.CurrentDefinition.ThrowSound, targetEndpoint, position);
             this.m_startTime = 0;
         }
     }
 }
 private static void CreateForVoxelHands()
 {
     MyControllerHelper.AddContext(CX_VOXEL, CX_CHARACTER);
     MyControllerHelper.AddControl(CX_VOXEL, MyControlsSpace.VOXEL_PAINT, MyJoystickButtonsEnum.J01);
     MyControllerHelper.AddControl(CX_VOXEL, MyControlsSpace.SWITCH_LEFT, MyJoystickButtonsEnum.J03);
     MyControllerHelper.AddControl(CX_VOXEL, MyControlsSpace.VOXEL_HAND_SETTINGS, MyJoystickButtonsEnum.J04);
     MyControllerHelper.AddControl(CX_VOXEL, MyControlsSpace.CUBE_ROTATE_ROLL_POSITIVE, MyJoystickButtonsEnum.J05);
     MyControllerHelper.AddControl(CX_VOXEL, MyControlsSpace.CUBE_ROTATE_ROLL_NEGATIVE, MyJoystickButtonsEnum.J06);
     MyControllerHelper.NullControl(CX_VOXEL, MyControlsSpace.CROUCH);
     MyControllerHelper.NullControl(CX_VOXEL, MyControlsSpace.PRIMARY_BUILD_ACTION);
     MyControllerHelper.NullControl(CX_VOXEL, MyControlsSpace.SECONDARY_BUILD_ACTION);
     MyControllerHelper.AddControl(CX_VOXEL, MyControlsSpace.CUBE_ROTATE_VERTICAL_POSITIVE, MyJoystickAxesEnum.Xneg);
     MyControllerHelper.AddControl(CX_VOXEL, MyControlsSpace.CUBE_ROTATE_VERTICAL_NEGATIVE, MyJoystickAxesEnum.Xpos);
     MyControllerHelper.AddControl(CX_VOXEL, MyControlsSpace.CUBE_ROTATE_HORISONTAL_POSITIVE, MyJoystickAxesEnum.Yneg);
     MyControllerHelper.AddControl(CX_VOXEL, MyControlsSpace.CUBE_ROTATE_HORISONTAL_NEGATIVE, MyJoystickAxesEnum.Ypos);
 }
Пример #10
0
        public override void HandleInput()
        {
            base.HandleInput();

            if (!(MyScreenManager.GetScreenWithFocus() is MyGuiScreenGamePlay))
            {
                return;
            }

            if (MyControllerHelper.IsControl(MySpaceBindingCreator.CX_CHARACTER, MyControlsSpace.PRIMARY_TOOL_ACTION))
            {
                if (MySession.Static.ControlledEntity != null && AreaMarkerDefinition != null)
                {
                    PlaceAreaMarker();
                }
            }
        }
Пример #11
0
        private void FormatNotifications(bool forJoystick)
        {
            if (forJoystick)
            {
                var cx_base = MySpaceBindingCreator.CX_BASE;
                var cx_char = MySpaceBindingCreator.CX_CHARACTER;

                var controlMenuCode = MyControllerHelper.GetCodeForControl(cx_base, MyControlsSpace.CONTROL_MENU);
                var nextItemCode    = MyControllerHelper.GetCodeForControl(cx_char, MyControlsSpace.TOOLBAR_NEXT_ITEM);
                var prevItemCode    = MyControllerHelper.GetCodeForControl(cx_char, MyControlsSpace.TOOLBAR_PREV_ITEM);

                Remove(MyNotificationSingletons.HudHideHint);
                if (MyPerGameSettings.Game == GameEnum.ME_GAME)
                {
                    Remove(MyNotificationSingletons.GameplayOptions);
                }

                SetNotificationTextAndArgs(MyNotificationSingletons.HelpHint, MySpaceTexts.NotificationJoystickControlMenuFormat, controlMenuCode);
                SetNotificationTextAndArgs(MyNotificationSingletons.ScreenHint, MySpaceTexts.NotificationJoystickMenus);
                SetNotificationTextAndArgs(MyNotificationSingletons.SlotEquipHint, MySpaceTexts.NotificationJoystickSlotEquipFormat, prevItemCode, nextItemCode);
            }
            else
            {
                var hud            = MyInput.Static.GetGameControl(MyControlsSpace.TOGGLE_HUD);
                var slot1          = MyInput.Static.GetGameControl(MyControlsSpace.SLOT1);
                var slot2          = MyInput.Static.GetGameControl(MyControlsSpace.SLOT2);
                var slot3          = MyInput.Static.GetGameControl(MyControlsSpace.SLOT3);
                var buildScreen    = MyInput.Static.GetGameControl(MyControlsSpace.BUILD_SCREEN);
                var help           = MyInput.Static.GetGameControl(MyControlsSpace.HELP_SCREEN);
                var compoundToggle = MyInput.Static.GetGameControl(MyControlsSpace.SWITCH_COMPOUND);

                Add(MyNotificationSingletons.HudHideHint);
                if (MyPerGameSettings.Game == GameEnum.ME_GAME)
                {
                    Add(MyNotificationSingletons.GameplayOptions);
                    SetNotificationTextAndArgs(MyNotificationSingletons.GameplayOptions, MySpaceTexts.Notification_GameplayOptions, MyInput.Static.GetGameControl(MyControlsSpace.TERMINAL));
                }

                SetNotificationTextAndArgs(MyNotificationSingletons.HelpHint, MySpaceTexts.NotificationNeedShowHelpScreen, help);
                SetNotificationTextAndArgs(MyNotificationSingletons.ScreenHint, MySpaceTexts.NotificationScreenFormat, buildScreen);
                SetNotificationTextAndArgs(MyNotificationSingletons.HudHideHint, MySpaceTexts.NotificationHudHideFormat, hud);
                SetNotificationTextAndArgs(MyNotificationSingletons.SlotEquipHint, MySpaceTexts.NotificationSlotEquipFormat, slot1, slot2, slot3);
            }
        }
        private bool HandleLeftMouseButton(MyStringId context)
        {
            if (MyInput.Static.IsNewLeftMousePressed() || MyControllerHelper.IsControl(context, MyControlsSpace.COPY_PASTE_ACTION))
            {
                bool handled = false;
                if (m_clipboard.IsActive)
                {
                    if (m_clipboard.PasteGrid())
                    {
                        UpdatePasteNotification(MyCommonTexts.CubeBuilderPasteNotification);
                        handled = true;
                    }
                }

                if (m_floatingObjectClipboard.IsActive)
                {
                    if (m_floatingObjectClipboard.PasteFloatingObject())
                    {
                        UpdatePasteNotification(MyCommonTexts.CubeBuilderPasteNotification);
                        handled = true;
                    }
                }

                if (m_voxelClipboard.IsActive)
                {
                    if (m_voxelClipboard.PasteVoxelMap())
                    {
                        UpdatePasteNotification(MyCommonTexts.CubeBuilderPasteNotification);
                        handled = true;
                    }
                }

                if (handled)
                {
                    this.Deactivate();
                    return(true);
                }
            }

            return(false);
        }
        private static void CreateForCharacter()
        {
            MyControllerHelper.AddContext(CX_CHARACTER, CX_BASE);
            MyControllerHelper.AddControl(CX_CHARACTER, MyControlsSpace.FORWARD, MyJoystickAxesEnum.Yneg);
            MyControllerHelper.AddControl(CX_CHARACTER, MyControlsSpace.BACKWARD, MyJoystickAxesEnum.Ypos);
            MyControllerHelper.AddControl(CX_CHARACTER, MyControlsSpace.STRAFE_LEFT, MyJoystickAxesEnum.Xneg);
            MyControllerHelper.AddControl(CX_CHARACTER, MyControlsSpace.STRAFE_RIGHT, MyJoystickAxesEnum.Xpos);
#if !XB1
            MyControllerHelper.AddControl(CX_CHARACTER, MyControlsSpace.PRIMARY_TOOL_ACTION, MyJoystickAxesEnum.Zneg);
            MyControllerHelper.AddControl(CX_CHARACTER, MyControlsSpace.SECONDARY_TOOL_ACTION, MyJoystickAxesEnum.Zpos);
            MyControllerHelper.AddControl(CX_CHARACTER, MyControlsSpace.PRIMARY_BUILD_ACTION, MyJoystickAxesEnum.Zneg);   // MW:TODO shouldn't be this way I think
            MyControllerHelper.AddControl(CX_CHARACTER, MyControlsSpace.SECONDARY_BUILD_ACTION, MyJoystickAxesEnum.Zpos); // this too
            MyControllerHelper.AddControl(CX_CHARACTER, MyControlsSpace.COPY_PASTE_ACTION, MyJoystickAxesEnum.Zneg);      // this too
#else
            MyControllerHelper.AddControl(CX_CHARACTER, MyControlsSpace.PRIMARY_TOOL_ACTION, MyJoystickButtonsEnum.J12);
            MyControllerHelper.AddControl(CX_CHARACTER, MyControlsSpace.SECONDARY_TOOL_ACTION, MyJoystickButtonsEnum.J11);
            MyControllerHelper.AddControl(CX_CHARACTER, MyControlsSpace.PRIMARY_BUILD_ACTION, MyJoystickButtonsEnum.J12);   // MW:TODO shouldn't be this way I think
            MyControllerHelper.AddControl(CX_CHARACTER, MyControlsSpace.SECONDARY_BUILD_ACTION, MyJoystickButtonsEnum.J11); // this too
            MyControllerHelper.AddControl(CX_CHARACTER, MyControlsSpace.COPY_PASTE_ACTION, MyJoystickButtonsEnum.J12);      // this too
#endif
            MyControllerHelper.AddControl(CX_CHARACTER, MyControlsSpace.ROTATION_LEFT, MyJoystickAxesEnum.RotationXneg);
            MyControllerHelper.AddControl(CX_CHARACTER, MyControlsSpace.ROTATION_RIGHT, MyJoystickAxesEnum.RotationXpos);
            MyControllerHelper.AddControl(CX_CHARACTER, MyControlsSpace.ROTATION_UP, MyJoystickAxesEnum.RotationYneg);
            MyControllerHelper.AddControl(CX_CHARACTER, MyControlsSpace.ROTATION_DOWN, MyJoystickAxesEnum.RotationYpos);
            MyControllerHelper.AddControl(CX_CHARACTER, MyControlsSpace.JUMP, MyJoystickButtonsEnum.J01);
            //MyControllerHelper.AddControl(CX_CHARACTER, MyControlsSpace.SLOT0,                 MyJoystickButtonsEnum.J02);
            MyControllerHelper.AddControl(CX_CHARACTER, MyControlsSpace.CROUCH, MyJoystickButtonsEnum.J02);
            MyControllerHelper.AddControl(CX_CHARACTER, MyControlsSpace.USE, MyJoystickButtonsEnum.J03);
            MyControllerHelper.AddControl(CX_CHARACTER, MyControlsSpace.THRUSTS, MyJoystickButtonsEnum.J04);
            MyControllerHelper.AddControl(CX_CHARACTER, MyControlsSpace.ROLL_LEFT, MyJoystickButtonsEnum.J05);
            MyControllerHelper.AddControl(CX_CHARACTER, MyControlsSpace.ROLL_RIGHT, MyJoystickButtonsEnum.J06);
            MyControllerHelper.AddControl(CX_CHARACTER, MyControlsSpace.SPRINT, MyJoystickButtonsEnum.J08);
            //MyControllerHelper.AddControl(CX_CHARACTER, MyControlsSpace.CROUCH,                MyJoystickButtonsEnum.J09);
            MyControllerHelper.AddControl(CX_CHARACTER, MyControlsSpace.SPRINT, MyJoystickButtonsEnum.J09);
            //MyControllerHelper.AddControl(CX_CHARACTER, MyControlsSpace.BUILD_MODE,            MyJoystickButtonsEnum.J10);
            MyControllerHelper.AddControl(CX_CHARACTER, MyControlsSpace.CAMERA_MODE, MyJoystickButtonsEnum.J10);
            MyControllerHelper.AddControl(CX_CHARACTER, MyControlsSpace.TOOLBAR_UP, MyJoystickButtonsEnum.JDUp);
            MyControllerHelper.AddControl(CX_CHARACTER, MyControlsSpace.TOOLBAR_DOWN, MyJoystickButtonsEnum.JDDown);
            MyControllerHelper.AddControl(CX_CHARACTER, MyControlsSpace.TOOLBAR_NEXT_ITEM, MyJoystickButtonsEnum.JDRight);
            MyControllerHelper.AddControl(CX_CHARACTER, MyControlsSpace.TOOLBAR_PREV_ITEM, MyJoystickButtonsEnum.JDLeft);
        }
        public override MyGuiControlBase HandleInput()
        {
            var captureInput = base.HandleInput();

            if (captureInput != null)
            {
                return(captureInput);
            }

            bool isControl = MyInput.Static.IsNewLeftMouseReleased() || MyControllerHelper.IsControl(MyControllerHelper.CX_GUI, MyControlsGUI.ACCEPT, MyControlStateType.NEW_RELEASED);

            if (Enabled && IsMouseOver && isControl ||
                HasFocus && MyInput.Static.IsNewKeyPressed(MyKeys.Enter))
            {
                Value        = !Value;
                captureInput = this;
                MyGuiSoundManager.PlaySound(GuiSounds.MouseClick);
            }

            return(captureInput);
        }
Пример #15
0
        public override void HandleInput(bool receivedFocusInThisUpdate)
        {
            if (MyInput.Static.IsNewKeyPressed(MyKeys.Up) ||
                MyControllerHelper.IsControl(MyControllerHelper.CX_GUI, MyControlsGUI.MOVE_UP, MyControlStateType.NEW_PRESSED))
            {
                UpdateSelectedItem(true);
                UpdateScroll();
            }
            else if (MyInput.Static.IsNewKeyPressed(MyKeys.Down) ||
                     MyControllerHelper.IsControl(MyControllerHelper.CX_GUI, MyControlsGUI.MOVE_DOWN, MyControlStateType.NEW_PRESSED))
            {
                UpdateSelectedItem(false);
                UpdateScroll();
            }
            else if (MyInput.Static.IsNewKeyPressed(MyKeys.Escape) ||
                     MyControllerHelper.IsControl(MyControllerHelper.CX_GUI, MyControlsGUI.CANCEL, MyControlStateType.NEW_PRESSED) ||
                     MyControllerHelper.IsControl(MyControllerHelper.CX_GUI, MyControlsSpace.CONTROL_MENU, MyControlStateType.NEW_PRESSED))
            {
                Canceling();
            }

            if (m_selectedItem != -1)
            {
                if (MyInput.Static.IsNewKeyPressed(MyKeys.Right) ||
                    MyControllerHelper.IsControl(MyControllerHelper.CX_GUI, MyControlsGUI.MOVE_RIGHT, MyControlStateType.NEW_PRESSED))
                {
                    m_items[m_selectedItem].UpdateItem(ItemUpdateType.Next);
                }
                else if (MyInput.Static.IsNewKeyPressed(MyKeys.Left) ||
                         MyControllerHelper.IsControl(MyControllerHelper.CX_GUI, MyControlsGUI.MOVE_LEFT, MyControlStateType.NEW_PRESSED))
                {
                    m_items[m_selectedItem].UpdateItem(ItemUpdateType.Previous);
                }
                else if (MyInput.Static.IsNewKeyPressed(MyKeys.Enter) ||
                         MyControllerHelper.IsControl(MyControllerHelper.CX_GUI, MyControlsGUI.ACCEPT, MyControlStateType.NEW_PRESSED))
                {
                    m_items[m_selectedItem].UpdateItem(ItemUpdateType.Activate);
                }
            }
        }
Пример #16
0
 public override void HandleInput(bool receivedFocusInThisUpdate)
 {
     if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.HELP_SCREEN) || MyControllerHelper.IsControl(MySpaceBindingCreator.CX_GUI, MyControlsGUI.BUTTON_Y))
     {
         if (MyInput.Static.IsAnyShiftKeyPressed() && MyPerGameSettings.GUI.PerformanceWarningScreen != null)
         {
             MyGuiAudio.PlaySound(MyGuiSounds.HudMouseClick);
             MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.PerformanceWarningScreen));
         }
         else
         {
             MyGuiAudio.PlaySound(MyGuiSounds.HudMouseClick);
             MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.HelpScreen));
         }
     }
     if (MyControllerHelper.IsControl(MyControllerHelper.CX_BASE, MyControlsSpace.WARNING_SCREEN) && MyPerGameSettings.GUI.PerformanceWarningScreen != null)
     {
         MyGuiAudio.PlaySound(MyGuiSounds.HudMouseClick);
         MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.PerformanceWarningScreen));
     }
     base.HandleInput(receivedFocusInThisUpdate);
 }
Пример #17
0
        MyActionDescription IMyUseObject.GetActionInfo(UseActionEnum actionEnum)
        {
            MyActionDescription description;

            if (!MySandboxGame.Config.ControlsHints)
            {
                description = new MyActionDescription {
                    Text = MyCommonTexts.CustomText,
                    IsTextControlHint = false
                };
                description.FormatParams = new object[] { this.m_displayedText };
                return(description);
            }
            if (actionEnum == UseActionEnum.Manipulate)
            {
                MyInput.Static.GetGameControl(MyControlsSpace.USE).GetControlButtonName(MyGuiInputDeviceEnum.Keyboard);
                description = new MyActionDescription {
                    Text = MyCommonTexts.NotificationPickupObject
                };
                description.FormatParams         = new object[] { "[" + MyInput.Static.GetGameControl(MyControlsSpace.USE) + "]", this.m_displayedText };
                description.IsTextControlHint    = true;
                description.JoystickFormatParams = new object[] { "[" + MyControllerHelper.GetCodeForControl(MySpaceBindingCreator.CX_CHARACTER, MyControlsSpace.USE).ToString() + "]", this.m_displayedText };
                return(description);
            }
            if (actionEnum != UseActionEnum.PickUp)
            {
                return(new MyActionDescription());
            }
            MyInput.Static.GetGameControl(MyControlsSpace.PICK_UP).GetControlButtonName(MyGuiInputDeviceEnum.Keyboard);
            description = new MyActionDescription {
                Text = MyCommonTexts.NotificationPickupObject
            };
            description.FormatParams         = new object[] { "[" + MyInput.Static.GetGameControl(MyControlsSpace.PICK_UP) + "]", this.m_displayedText };
            description.IsTextControlHint    = true;
            description.JoystickFormatParams = new object[] { "[" + MyControllerHelper.GetCodeForControl(MySpaceBindingCreator.CX_CHARACTER, MyControlsSpace.PICK_UP).ToString() + "]", this.m_displayedText };
            return(description);
        }
        private bool HandleRotationInput(MyStringId context)
        {
            int frameDt = MySandboxGame.TotalGamePlayTimeInMilliseconds - m_lastInputHandleTime;

            m_lastInputHandleTime += frameDt;

            if (m_activated)
            {
                for (int i = 0; i < 6; ++i)
                {
                    bool standardRotation = MyControllerHelper.IsControl(context, m_rotationControls[i], MyControlStateType.PRESSED);
                    if (standardRotation)
                    {
                        bool newStandardPress = MyControllerHelper.IsControl(context, m_rotationControls[i], MyControlStateType.NEW_PRESSED);
                        bool newPress         = newStandardPress;

                        int axis      = -1;
                        int direction = m_rotationDirections[i];

                        //if (MyFakes.ENABLE_STANDARD_AXES_ROTATION)
                        //{
                        //    axis = GetStandardRotationAxisAndDirection(i, ref direction);
                        //}

                        if (MyFakes.ENABLE_STANDARD_AXES_ROTATION)
                        {
                            int[] axes = new int[] { 1, 1, 0, 0, 2, 2 };
                            if (m_rotationHints.RotationUpAxis != axes[i])
                            {
                                return(true);
                                //axis = m_rotationHints.RotationUpAxis;
                                //direction *= m_rotationHints.RotationUpDirection;
                            }
                        }
                        //else
                        //{
                        if (i < 2)
                        {
                            axis       = m_rotationHints.RotationUpAxis;
                            direction *= m_rotationHints.RotationUpDirection;
                        }
                        if (i >= 2 && i < 4)
                        {
                            axis       = m_rotationHints.RotationRightAxis;
                            direction *= m_rotationHints.RotationRightDirection;
                        }
                        if (i >= 4)
                        {
                            axis       = m_rotationHints.RotationForwardAxis;
                            direction *= m_rotationHints.RotationForwardDirection;
                        }
                        // }

                        if (axis != -1)
                        {
                            m_rotationHintRotating |= !newPress;
                            RotateAxis(axis, direction, newPress, frameDt);
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
 private static void CreateForBase()
 {
     MyControllerHelper.AddContext(CX_BASE);
     MyControllerHelper.AddControl(CX_BASE, MyControlsSpace.CONTROL_MENU, MyJoystickButtonsEnum.J07);
     MyControllerHelper.AddControl(CX_BASE, MyControlsGUI.MAIN_MENU, MyJoystickButtonsEnum.J08);
 }
Пример #20
0
        public override void HandleInput()
        {
            ProfilerShort.Begin("MyToolbarComponent.HandleInput");
            try
            {
                var context       = MySession.Static.ControlledEntity != null ? MySession.Static.ControlledEntity.ControlContext : MyStringId.NullOrEmpty;
                var focusedScreen = MyScreenManager.GetScreenWithFocus();
                if ((focusedScreen == MyGuiScreenGamePlay.Static ||
                     IsToolbarControlShown) &&
                    CurrentToolbar != null && !MyGuiScreenGamePlay.DisableInput)
                {
                    {
                        for (int i = 0; i < m_slotControls.Length; i++)
                        {
                            if (MyControllerHelper.IsControl(context, m_slotControls[i], MyControlStateType.NEW_PRESSED))
                            {
                                if (!MyInput.Static.IsAnyCtrlKeyPressed())
                                {
                                    if ((focusedScreen is MyGuiScreenScriptingTools || focusedScreen == MyGuiScreenGamePlay.Static ||
                                         (focusedScreen is MyGuiScreenCubeBuilder || focusedScreen is MyGuiScreenToolbarConfigBase) && ((MyGuiScreenToolbarConfigBase)focusedScreen).AllowToolbarKeys()) &&
                                        CurrentToolbar != null)
                                    {
                                        CurrentToolbar.ActivateItemAtSlot(i);
                                    }
                                }
                                else if (i < CurrentToolbar.PageCount)
                                {
                                    MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                                    CurrentToolbar.SwitchToPage(i);
                                }
                            }
                        }
                    }

                    if ((focusedScreen == MyGuiScreenGamePlay.Static ||
                         (focusedScreen is MyGuiScreenCubeBuilder || focusedScreen is MyGuiScreenToolbarConfigBase) && ((MyGuiScreenToolbarConfigBase)focusedScreen).AllowToolbarKeys()) &&
                        CurrentToolbar != null)
                    {
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.TOOLBAR_NEXT_ITEM, MyControlStateType.NEW_PRESSED))
                        {
                            CurrentToolbar.SelectNextSlot();
                        }
                        else if (MyControllerHelper.IsControl(context, MyControlsSpace.TOOLBAR_PREV_ITEM, MyControlStateType.NEW_PRESSED))
                        {
                            CurrentToolbar.SelectPreviousSlot();
                        }
                        if (MySpectator.Static.SpectatorCameraMovement != MySpectatorCameraMovementEnum.ConstantDelta)
                        {
                            if (MyControllerHelper.IsControl(context, MyControlsSpace.TOOLBAR_UP, MyControlStateType.NEW_PRESSED))
                            {
                                MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                                CurrentToolbar.PageUp();
                            }
                            if (MyControllerHelper.IsControl(context, MyControlsSpace.TOOLBAR_DOWN, MyControlStateType.NEW_PRESSED))
                            {
                                MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                                CurrentToolbar.PageDown();
                            }
                        }
                    }
                }
            }
            finally
            {
                ProfilerShort.End();
            }

            base.HandleInput();
        }
        public override void HandleInput()
        {
            if (!m_isActive)
            {
                return;
            }
            if (!(MyScreenManager.GetScreenWithFocus() is MyGuiScreenGamePlay))
            {
                return;
            }

            if (!
                (VRage.Input.MyInput.Static.ENABLE_DEVELOPER_KEYS || !MySession.Static.SurvivalMode || (MyMultiplayer.Static != null && MyMultiplayer.Static.IsAdmin(MySession.Static.LocalHumanPlayer.Id.SteamId)))
                )
            {
                return;
            }


            base.HandleInput();

            if (MyControllerHelper.IsControl(MySpaceBindingCreator.CX_CHARACTER, MyControlsSpace.PRIMARY_TOOL_ACTION, MyControlStateType.NEW_PRESSED))
            {
                m_startTime = MySandboxGame.TotalGamePlayTimeInMilliseconds;
            }

            if (MyControllerHelper.IsControl(MySpaceBindingCreator.CX_CHARACTER, MyControlsSpace.PRIMARY_TOOL_ACTION, MyControlStateType.NEW_RELEASED))
            {
                var gridBuilders = MyPrefabManager.Static.GetGridPrefab(CurrentDefinition.PrefabToThrow);

                Vector3D cameraPos = Vector3D.Zero;
                Vector3D cameraDir = Vector3D.Zero;

                if (USE_SPECTATOR_FOR_THROW)
                {
                    cameraPos = MySpectator.Static.Position;
                    cameraDir = MySpectator.Static.Orientation.Forward;
                }
                else
                {
                    if (MySession.Static.GetCameraControllerEnum() == MyCameraControllerEnum.ThirdPersonSpectator || MySession.Static.GetCameraControllerEnum() == MyCameraControllerEnum.Entity)
                    {
                        if (MySession.Static.ControlledEntity == null)
                        {
                            return;
                        }

                        cameraPos = MySession.Static.ControlledEntity.GetHeadMatrix(true, true).Translation;
                        cameraDir = MySession.Static.ControlledEntity.GetHeadMatrix(true, true).Forward;
                    }
                    else
                    {
                        cameraPos = MySector.MainCamera.Position;
                        cameraDir = MySector.MainCamera.WorldMatrix.Forward;
                    }
                }

                var position = cameraPos + cameraDir;

                float deltaSeconds = (MySandboxGame.TotalGamePlayTimeInMilliseconds - m_startTime) / 1000.0f;
                float velocity     = deltaSeconds / CurrentDefinition.PushTime * CurrentDefinition.MaxSpeed;
                velocity = MathHelper.Clamp(velocity, CurrentDefinition.MinSpeed, CurrentDefinition.MaxSpeed);
                var   linearVelocity = cameraDir * velocity + MySession.Static.ControlledEntity.Entity.Physics.LinearVelocity;
                float mass           = 0;
                if (CurrentDefinition.Mass.HasValue)
                {
                    mass = Sandbox.Engine.Physics.MyDestructionHelper.MassToHavok(CurrentDefinition.Mass.Value);
                }

                gridBuilders[0].EntityId = MyEntityIdentifier.AllocateId();
                MyMultiplayer.RaiseStaticEvent(s => MySessionComponentThrower.OnThrowMessageSuccess, gridBuilders[0], position, linearVelocity, mass, CurrentDefinition.ThrowSound);

                m_startTime = 0;
            }
        }
Пример #22
0
        public override MyActionDescription GetActionInfo(UseActionEnum actionEnum)
        {
            m_buttonPanel.Toolbar.UpdateItem(m_index);
            var slot = m_buttonPanel.Toolbar.GetItemAtIndex(m_index);

            switch (actionEnum)
            {
            case UseActionEnum.Manipulate:

                if (m_buttonDesc == null)
                {
                    m_buttonDesc = new MyGps();

                    m_buttonDesc.Description   = "";
                    m_buttonDesc.Coords        = ActivationMatrix.Translation;
                    m_buttonDesc.ShowOnHud     = true;
                    m_buttonDesc.DiscardAt     = null;
                    m_buttonDesc.AlwaysVisible = true;
                }

                MyHud.ButtonPanelMarkers.RegisterMarker(m_buttonDesc);

                SetButtonName(m_buttonPanel.GetCustomButtonName(m_index));

                if (slot != null)
                {
                    return(new MyActionDescription()
                    {
                        Text = MyCommonTexts.NotificationHintPressToUse,
                        FormatParams = new object[] { MyInput.Static.GetGameControl(MyControlsSpace.USE), slot.DisplayName },
                        IsTextControlHint = true,
                        JoystickFormatParams = new object[] { MyControllerHelper.GetCodeForControl(MySpaceBindingCreator.CX_CHARACTER, MyControlsSpace.USE), slot.DisplayName },
                    });
                }
                else
                {
                    return(new MyActionDescription()
                    {
                        Text = MySpaceTexts.Blank
                    });
                }

            case UseActionEnum.OpenTerminal:
                return(new MyActionDescription()
                {
                    Text = MySpaceTexts.NotificationHintPressToOpenButtonPanel,
                    FormatParams = new object[] { MyInput.Static.GetGameControl(MyControlsSpace.TERMINAL) },
                    IsTextControlHint = true,
                    JoystickText = MySpaceTexts.NotificationHintJoystickPressToOpenButtonPanel,
                });

            default:
                Debug.Fail("Invalid branch reached.");
                return(new MyActionDescription()
                {
                    Text = MySpaceTexts.NotificationHintPressToOpenButtonPanel,
                    FormatParams = new object[] { MyInput.Static.GetGameControl(MyControlsSpace.TERMINAL) },
                    IsTextControlHint = true
                });
            }
        }
Пример #23
0
        //  This method is called every update (but only if application has focus)
        public override void HandleUnhandledInput(bool receivedFocusInThisUpdate)
        {
            if (MyInput.Static.ENABLE_DEVELOPER_KEYS || (MySession.Static != null && MySession.Static.Settings.EnableSpectator) || (MyMultiplayer.Static != null && MySession.LocalHumanPlayer != null && MyMultiplayer.Static.IsAdmin(MySession.LocalHumanPlayer.Id.SteamId)))
            {
                //Set camera to player
                if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.SPECTATOR_NONE))
                {
                    if (MySession.ControlledEntity != null)
                    { //we already are controlling this object
                        if (MyFinalBuildConstants.IS_OFFICIAL)
                        {
                            SetCameraController();
                        }
                        else
                        {
                            var cameraController = MySession.GetCameraControllerEnum();
                            if (cameraController != MyCameraControllerEnum.Entity && cameraController != MyCameraControllerEnum.ThirdPersonSpectator)
                            {
                                SetCameraController();
                            }
                            else
                            {
                                var entities       = MyEntities.GetEntities().ToList();
                                int lastKnownIndex = entities.IndexOf(MySession.ControlledEntity.Entity);

                                var entitiesList = new List <MyEntity>();
                                if (lastKnownIndex + 1 < entities.Count)
                                {
                                    entitiesList.AddRange(entities.GetRange(lastKnownIndex + 1, entities.Count - lastKnownIndex - 1));
                                }

                                if (lastKnownIndex != -1)
                                {
                                    entitiesList.AddRange(entities.GetRange(0, lastKnownIndex + 1));
                                }

                                MyCharacter newControlledObject = null;

                                for (int i = 0; i < entitiesList.Count; i++)
                                {
                                    var character = entitiesList[i] as MyCharacter;
                                    if (character != null && !character.IsDead)
                                    {
                                        newControlledObject = character;
                                        break;
                                    }
                                }

                                if (MySession.LocalHumanPlayer != null && newControlledObject != null)
                                {
                                    MySession.LocalHumanPlayer.Controller.TakeControl(newControlledObject);
                                }
                            }

                            // We could have activated the cube builder in spectator, so deactivate it now
                            if (MyCubeBuilder.Static.IsActivated && !(MySession.ControlledEntity is MyCharacter))
                            {
                                MyCubeBuilder.Static.Deactivate();
                            }
                        }
                    }
                }

                //Set camera to following third person
                if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.SPECTATOR_DELTA))
                {
                    if (MySession.ControlledEntity != null)
                    {
                        MySession.SetCameraController(MyCameraControllerEnum.SpectatorDelta);
                    }
                }

                //Set camera to spectator
                if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.SPECTATOR_FREE))
                {
                    if (!MyFakes.ENABLE_BATTLE_SYSTEM || !MySession.Static.Battle || Sync.IsServer)
                    {
                        if (MySession.GetCameraControllerEnum() != MyCameraControllerEnum.Spectator)
                        {
                            MySession.SetCameraController(MyCameraControllerEnum.Spectator);
                        }
                        else if (MyInput.Static.IsAnyShiftKeyPressed())
                        {
                            MyFakes.ENABLE_DEVELOPER_SPECTATOR_CONTROLS = !MyFakes.ENABLE_DEVELOPER_SPECTATOR_CONTROLS;
                        }

                        if (MyInput.Static.IsAnyCtrlKeyPressed() && MySession.ControlledEntity != null)
                        {
                            MySpectator.Static.Position = (Vector3D)MySession.ControlledEntity.Entity.PositionComp.GetPosition() + MySpectator.Static.ThirdPersonCameraDelta;
                            MySpectator.Static.Target   = (Vector3D)MySession.ControlledEntity.Entity.PositionComp.GetPosition();
                        }
                    }
                }

                //Set camera to static spectator, non movable
                if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.SPECTATOR_STATIC))
                {
                    if (MySession.ControlledEntity != null)
                    {
                        MySession.SetCameraController(MyCameraControllerEnum.SpectatorFixed);

                        if (MyInput.Static.IsAnyCtrlKeyPressed())
                        {
                            MySpectator.Static.Position = (Vector3D)MySession.ControlledEntity.Entity.PositionComp.GetPosition() + MySpectator.Static.ThirdPersonCameraDelta;
                            MySpectator.Static.Target   = (Vector3D)MySession.ControlledEntity.Entity.PositionComp.GetPosition();
                        }
                    }
                }

                //Open console
                if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.CONSOLE) && MyInput.Static.IsAnyAltKeyPressed())
                {
                    MyGuiScreenConsole.Show();
                }
            }

            if (MyDefinitionErrors.ShouldShowModErrors)
            {
                MyDefinitionErrors.ShouldShowModErrors = false;
                MyGuiSandbox.ShowModErrors();
            }

            // Switch view - cockpit on/off, third person
            if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.CAMERA_MODE) && CanSwitchCamera)
            {
                MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                SwitchCamera();
            }

            if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.HELP_SCREEN))
            {
                if (MyInput.Static.IsAnyCtrlKeyPressed())
                {
                    switch (MySandboxGame.Config.DebugComponentsInfo)
                    {
                    case MyDebugComponent.MyDebugComponentInfoState.NoInfo:
                        MySandboxGame.Config.DebugComponentsInfo = MyDebugComponent.MyDebugComponentInfoState.EnabledInfo;
                        break;

                    case MyDebugComponent.MyDebugComponentInfoState.EnabledInfo:
                        MySandboxGame.Config.DebugComponentsInfo = MyDebugComponent.MyDebugComponentInfoState.FullInfo;
                        break;

                    case MyDebugComponent.MyDebugComponentInfoState.FullInfo:
                        MySandboxGame.Config.DebugComponentsInfo = MyDebugComponent.MyDebugComponentInfoState.NoInfo;
                        break;
                    }

                    MySandboxGame.Config.Save();
                }
                else
                if (MyGuiScreenGamePlay.ActiveGameplayScreen == null)
                {
                    MyGuiAudio.PlaySound(MyGuiSounds.HudMouseClick);
                    MyGuiSandbox.AddScreen(MyGuiScreenGamePlay.ActiveGameplayScreen = MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.HelpScreen));
                }
            }

            if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.TOGGLE_HUD))
            {
                MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                MyHud.MinimalHud = !MyHud.MinimalHud;
            }

            if (MyPerGameSettings.SimplePlayerNames && MyInput.Static.IsNewGameControlPressed(MyControlsSpace.BROADCASTING))
            {
                MyHud.LocationMarkers.Visible = !MyHud.LocationMarkers.Visible;
            }

            var controlledObject        = MySession.ControlledEntity;
            var currentCameraController = MySession.Static.CameraController;

            if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.MISSION_SETTINGS) && MyGuiScreenGamePlay.ActiveGameplayScreen == null &&
                MyPerGameSettings.Game == Sandbox.Game.GameEnum.SE_GAME &&
                MyFakes.ENABLE_MISSION_TRIGGERS &&
                MySession.Static.Settings.ScenarioEditMode)
            {
                MyGuiSandbox.AddScreen(new Sandbox.Game.Screens.MyGuiScreenMissionTriggers());
            }

            MyStringId context = controlledObject != null ? controlledObject.ControlContext : MySpaceBindingCreator.CX_BASE;

            bool handledByUseObject = false;

            if (MySession.ControlledEntity is VRage.Game.Entity.UseObject.IMyUseObject)
            {
                handledByUseObject = (MySession.ControlledEntity as VRage.Game.Entity.UseObject.IMyUseObject).HandleInput();
            }

            if (controlledObject != null && !handledByUseObject)
            {
                if (!MySandboxGame.IsPaused)
                {
                    if (context == MySpaceBindingCreator.CX_BUILD_MODE || context == MySpaceBindingCreator.CX_CHARACTER || context == MySpaceBindingCreator.CX_SPACESHIP)
                    {
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.PRIMARY_TOOL_ACTION, MyControlStateType.NEW_PRESSED))
                        {
                            if (MyToolbarComponent.CurrentToolbar.ShouldActivateSlot)
                            {
                                MyToolbarComponent.CurrentToolbar.ActivateStagedSelectedItem();
                            }
                            else
                            {
                                controlledObject.BeginShoot(MyShootActionEnum.PrimaryAction);
                            }
                        }

                        if (MyControllerHelper.IsControl(context, MyControlsSpace.PRIMARY_TOOL_ACTION, MyControlStateType.NEW_RELEASED))
                        {
                            controlledObject.EndShoot(MyShootActionEnum.PrimaryAction);
                        }
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.SECONDARY_TOOL_ACTION, MyControlStateType.NEW_PRESSED))
                        {
                            controlledObject.BeginShoot(MyShootActionEnum.SecondaryAction);
                        }
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.SECONDARY_TOOL_ACTION, MyControlStateType.NEW_RELEASED))
                        {
                            controlledObject.EndShoot(MyShootActionEnum.SecondaryAction);
                        }
                    }

                    if (context == MySpaceBindingCreator.CX_CHARACTER || context == MySpaceBindingCreator.CX_SPACESHIP)
                    {
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.USE, MyControlStateType.NEW_PRESSED))
                        {
                            // Key press
                            if (currentCameraController != null)
                            {
                                if (!currentCameraController.HandleUse())
                                {
                                    controlledObject.Use();
                                }
                            }
                            else
                            {
                                controlledObject.Use();
                            }
                        }
                        else if (MyControllerHelper.IsControl(context, MyControlsSpace.USE, MyControlStateType.PRESSED))
                        {
                            // Key not pressed this frame, holding from previous
                            controlledObject.UseContinues();
                        }
                        else if (MyControllerHelper.IsControl(context, MyControlsSpace.USE, MyControlStateType.NEW_RELEASED))
                        {
                            controlledObject.UseFinished();
                        }

                        //Temp fix until spectators are implemented as entities
                        //Prevents controlled object from getting input while spectator mode is enabled
                        if (!(MySession.Static.CameraController is MySpectatorCameraController && MySpectatorCameraController.Static.SpectatorCameraMovement == MySpectatorCameraMovementEnum.UserControlled))
                        {
                            if (MyControllerHelper.IsControl(context, MyControlsSpace.CROUCH, MyControlStateType.NEW_PRESSED))
                            {
                                controlledObject.Crouch();
                            }
                            if (MyControllerHelper.IsControl(context, MyControlsSpace.CROUCH, MyControlStateType.PRESSED))
                            {
                                controlledObject.Down();
                            }
                            if (MyControllerHelper.IsControl(context, MyControlsSpace.SPRINT, MyControlStateType.PRESSED))
                            {
                                controlledObject.Sprint();
                            }
                            if (MyControllerHelper.IsControl(context, MyControlsSpace.JUMP, MyControlStateType.NEW_PRESSED))
                            {
                                controlledObject.Jump();
                            }
                            if (MyControllerHelper.IsControl(context, MyControlsSpace.JUMP, MyControlStateType.PRESSED))
                            {
                                controlledObject.Up();
                            }
                            if (MyControllerHelper.IsControl(context, MyControlsSpace.SWITCH_WALK, MyControlStateType.NEW_PRESSED))
                            {
                                controlledObject.SwitchWalk();
                            }
                            if (MyControllerHelper.IsControl(context, MyControlsSpace.BROADCASTING, MyControlStateType.NEW_PRESSED))
                            {
                                controlledObject.SwitchBroadcasting();
                            }
                            if (MyControllerHelper.IsControl(context, MyControlsSpace.HELMET, MyControlStateType.NEW_PRESSED))
                            {
                                controlledObject.SwitchHelmet();
                            }
                        }

                        if (MyControllerHelper.IsControl(context, MyControlsSpace.DAMPING, MyControlStateType.NEW_PRESSED))
                        {
                            MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                            controlledObject.SwitchDamping();
                        }
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.THRUSTS, MyControlStateType.NEW_PRESSED))
                        {
                            MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                            controlledObject.SwitchThrusts();
                        }
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.HEADLIGHTS, MyControlStateType.NEW_PRESSED))
                        {
                            MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                            controlledObject.SwitchLights();
                        }
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.TOGGLE_REACTORS, MyControlStateType.NEW_PRESSED))
                        {
                            MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                            controlledObject.SwitchReactors();
                        }
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.LANDING_GEAR, MyControlStateType.NEW_PRESSED))
                        {
                            MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                            controlledObject.SwitchLeadingGears();
                        }
                        if (MyControllerHelper.IsControl(context, MyControlsSpace.SUICIDE, MyControlStateType.NEW_PRESSED))
                        {
                            controlledObject.Die();
                        }
                        if ((controlledObject as MyCockpit) != null && MyControllerHelper.IsControl(context, MyControlsSpace.CUBE_COLOR_CHANGE, MyControlStateType.NEW_PRESSED))
                        {
                            (controlledObject as MyCockpit).SwitchWeaponMode();
                        }
                    }
                }
                if (MyControllerHelper.IsControl(context, MyControlsSpace.TERMINAL, MyControlStateType.NEW_PRESSED) && MyGuiScreenGamePlay.ActiveGameplayScreen == null)
                {
                    MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                    controlledObject.ShowTerminal();
                }

                if (MyControllerHelper.IsControl(context, MyControlsSpace.INVENTORY, MyControlStateType.NEW_PRESSED) && MyGuiScreenGamePlay.ActiveGameplayScreen == null)
                {
                    MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                    controlledObject.ShowInventory();
                }

                if (MyControllerHelper.IsControl(context, MyControlsSpace.CONTROL_MENU, MyControlStateType.NEW_PRESSED) && MyGuiScreenGamePlay.ActiveGameplayScreen == null)
                {
                    MyGuiAudio.PlaySound(MyGuiSounds.HudClick);
                    m_controlMenu.OpenControlMenu(controlledObject);
                }

                if (!MyCompilationSymbols.RenderProfiling && MyControllerHelper.IsControl(context, MyControlsSpace.CHAT_SCREEN, MyControlStateType.NEW_PRESSED))
                {
                    if (MyGuiScreenChat.Static == null)
                    {
                        Vector2 chatPos = new Vector2(0.01f, 0.84f);
                        chatPos = MyGuiScreenHudBase.ConvertHudToNormalizedGuiPosition(ref chatPos);
                        MyGuiScreenChat chatScreen = new MyGuiScreenChat(chatPos);
                        MyGuiSandbox.AddScreen(chatScreen);
                    }
                }

                if (MyPerGameSettings.VoiceChatEnabled)
                {
                    if (MyControllerHelper.IsControl(context, MyControlsSpace.VOICE_CHAT, MyControlStateType.NEW_PRESSED))
                    {
                        MyVoiceChatSessionComponent.Static.StartRecording();
                    }
                    //else if (MyControllerHelper.IsControl(context, MyControlsSpace.VOICE_CHAT, MyControlStateType.NEW_RELEASED))
                    // TODO: If other key was pressed during VOIP, NEW_RELEASED will return false even if this key was pressed, is this correct? We don't store key states?
                    else if (MyVoiceChatSessionComponent.Static.IsRecording && !MyControllerHelper.IsControl(context, MyControlsSpace.VOICE_CHAT, MyControlStateType.PRESSED))
                    {
                        MyVoiceChatSessionComponent.Static.StopRecording();
                    }
                }
            }

            MoveAndRotatePlayerOrCamera();

            // Quick save or quick load.
            if (MyInput.Static.IsNewKeyPressed(MyKeys.F5))
            {
                if (!MySession.Static.IsScenario)
                {
                    MyGuiAudio.PlaySound(MyGuiSounds.HudMouseClick);
                    var currentSession = MySession.Static.CurrentPath;

                    if (MyInput.Static.IsAnyShiftKeyPressed())
                    {
                        if (MySession.Static.ClientCanSave || Sync.IsServer)
                        {
                            if (!MyAsyncSaving.InProgress)
                            {
                                var messageBox = MyGuiSandbox.CreateMessageBox(
                                    buttonType : MyMessageBoxButtonsType.YES_NO,
                                    messageText : MyTexts.Get(MySpaceTexts.MessageBoxTextAreYouSureYouWantToQuickSave),
                                    messageCaption : MyTexts.Get(MySpaceTexts.MessageBoxCaptionPleaseConfirm),
                                    callback : delegate(MyGuiScreenMessageBox.ResultEnum callbackReturn)
                                {
                                    if (callbackReturn == MyGuiScreenMessageBox.ResultEnum.YES)
                                    {
                                        MyAsyncSaving.Start(() => MySector.ResetEyeAdaptation = true);    //black screen after save
                                    }
                                });
                                messageBox.SkipTransition      = true;
                                messageBox.CloseBeforeCallback = true;
                                MyGuiSandbox.AddScreen(messageBox);
                            }
                        }
                        else
                        {
                            MyHud.Notifications.Add(MyNotificationSingletons.ClientCannotSave);
                        }
                    }
                    else if (Sync.IsServer)
                    {
                        ShowLoadMessageBox(currentSession);
                    }
                    else
                    {
                        // Is multiplayer client, reconnect
                        ShowReconnectMessageBox();
                    }
                }
            }

            //  Launch main menu
            if (MyInput.Static.IsNewKeyPressed(MyKeys.Escape) ||
                MyControllerHelper.IsControl(context, MyControlsGUI.MAIN_MENU, MyControlStateType.NEW_PRESSED))
            {
                MyGuiAudio.PlaySound(MyGuiSounds.HudMouseClick);

                //Allow changing video options from game in DX version
                MyGuiScreenMainMenu.AddMainMenu();
            }

            if (MyInput.Static.IsNewKeyPressed(MyKeys.F3))
            {
                if (Sync.MultiplayerActive)
                {
                    MyGuiAudio.PlaySound(MyGuiSounds.HudMouseClick);
                    MyGuiSandbox.AddScreen(new MyGuiScreenPlayers());
                }
                else
                {
                    MyHud.Notifications.Add(MyNotificationSingletons.MultiplayerDisabled);
                }
            }

            if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.BUILD_SCREEN) && MyGuiScreenGamePlay.ActiveGameplayScreen == null)
            {
                if (MyGuiScreenCubeBuilder.Static == null && (MySession.ControlledEntity is MyShipController || MySession.ControlledEntity is MyCharacter))
                {
                    int offset = 0;
                    if (MyInput.Static.IsAnyShiftKeyPressed())
                    {
                        offset += 6;
                    }
                    if (MyInput.Static.IsAnyCtrlKeyPressed())
                    {
                        offset += 12;
                    }
                    MyGuiAudio.PlaySound(MyGuiSounds.HudMouseClick);
                    MyGuiSandbox.AddScreen(
                        MyGuiScreenGamePlay.ActiveGameplayScreen = MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.ToolbarConfigScreen,
                                                                                             offset,
                                                                                             MySession.ControlledEntity as MyShipController)
                        );
                }
            }

            if (MyInput.Static.IsNewGameControlPressed(MyControlsSpace.PAUSE_GAME))
            {
                MySandboxGame.UserPauseToggle();
            }

            if (MySession.Static != null)
            {
                if (MyInput.Static.IsNewKeyPressed(MyKeys.F10))
                {
                    if (MyPerGameSettings.GUI.VoxelMapEditingScreen != null && MySession.Static.CreativeMode && MyInput.Static.IsAnyShiftKeyPressed())
                    { // Shift+F10
                        MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.VoxelMapEditingScreen));
                    }
                    else
                    { // F10
                        if (MyFakes.ENABLE_BATTLE_SYSTEM && MySession.Static.Battle)
                        {
                            if (MyPerGameSettings.GUI.BattleBlueprintScreen != null)
                            {
                                MyGuiSandbox.AddScreen(MyGuiSandbox.CreateScreen(MyPerGameSettings.GUI.BattleBlueprintScreen));
                            }
                            else
                            {
                                Debug.Fail("No battle blueprint screen");
                            }
                        }
                        else
                        {
                            MyGuiSandbox.AddScreen(new MyGuiBlueprintScreen(MyCubeBuilder.Static.Clipboard));
                        }
                    }
                }
            }

            // F11, mod debug
            if (MyInput.Static.IsNewKeyPressed(MyKeys.F11) && !MyInput.Static.IsAnyShiftKeyPressed() && !MyInput.Static.IsAnyCtrlKeyPressed())
            {
                MyDX9Gui.SwitchModDebugScreen();
            }
        }
Пример #24
0
    private void DrawPerformanceWarning(int xPosition, int yPosition, MyGuiDrawAlignEnum alignment, string texturepath, float length, float width)
    {
        if (!Controls.Contains(m_warningLabel))
        {
            Controls.Add(m_warningLabel);
        }
        if (m_warningNotifications.Count != 0)
        {
            Vector2 position = MyGuiManager.ComputeFullscreenGuiCoordinate(alignment, xPosition, yPosition);
            position -= new Vector2(length / 1.5f, 0f);

            MyGuiManager.DrawSpriteBatch(Path.GetFullPath(Path.Combine(MyFileSystem.UserDataPath, texturepath)), position, new Vector2(length / 1.5f, width / 1.5f), Color.White, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);
            StringBuilder stringBuilder = new StringBuilder();
            if (MyInput.Static.IsJoystickLastUsed)
            {
                stringBuilder.AppendFormat(MyCommonTexts.PerformanceWarningCombinationGamepad, MyControllerHelper.GetCodeForControl(MyControllerHelper.CX_BASE, MyControlsSpace.WARNING_SCREEN));
            }
            else
            {
                stringBuilder.AppendFormat(MyCommonTexts.PerformanceWarningCombination, MyGuiSandbox.GetKeyName(MyControlsSpace.HELP_SCREEN));
            }
            MyGuiManager.DrawString("White", MyTexts.GetString(m_warningNotifications[0]), position + new Vector2(0.09f, -0.011f), 0.7f, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
            MyGuiManager.DrawString("White", stringBuilder.ToString(), position + new Vector2(0.09f, 0.018f), 0.6f, null, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER);
            stringBuilder.Clear();
            MyGuiManager.DrawString("White", stringBuilder.AppendFormat("({0})", m_warningNotifications.Count).ToString(), position + new Vector2(0.177f, -0.023f), 0.55f, null, MyGuiDrawAlignEnum.HORISONTAL_RIGHT_AND_VERTICAL_CENTER);
            m_warningNotifications.RemoveAt(0);
        }
    }
        public bool HandleGameInput()
        {
            m_rotationHintRotating = false;

            var context = (m_activated && MySession.Static.ControlledEntity is MyCharacter) ? MySession.Static.ControlledEntity.ControlContext : MyStringId.NullOrEmpty;

            // When spectator active, building is instant
            if (MySession.Static.IsCopyPastingEnabled || MySession.Static.CreativeMode || (SpectatorIsBuilding && MyFinalBuildConstants.IS_OFFICIAL == false))
            {
                if (MySession.Static.IsCopyPastingEnabled && !(MySession.Static.ControlledEntity is MyShipController))
                {
                    if (this.HandleCopyInput())
                    {
                        return(true);
                    }

                    if (this.HandleCutInput())
                    {
                        return(true);
                    }

                    if (this.HandlePasteInput())
                    {
                        return(true);
                    }

                    if (HandleMouseScrollInput(context))
                    {
                        return(true);
                    }
                }

                if (this.HandleEscape())
                {
                    return(true);
                }

                if (this.HandleLeftMouseButton(context))
                {
                    return(true);
                }
            }

            if (this.HandleBlueprintInput())
            {
                return(true);
            }

            if (m_clipboard != null && m_clipboard.IsActive && (MyControllerHelper.IsControl(context, MyControlsSpace.FREE_ROTATION) ||
                                                                MyControllerHelper.IsControl(context, MyControlsSpace.SWITCH_BUILDING_MODE)))
            {
                m_clipboard.EnableStationRotation = !m_clipboard.EnableStationRotation;
                m_floatingObjectClipboard.EnableStationRotation = !m_floatingObjectClipboard.EnableStationRotation;

                //if (m_clipboard.EnableStationRotation)
                //    ShowStationRotationNotification();
                //else
                //    HideStationRotationNotification();
            }

            if (HandleRotationInput(context))
            {
                return(true);
            }

            return(false);
        }
        public void CalculateRotationHints(MatrixD drawMatrix, BoundingBoxD worldBox, bool draw, bool fixedAxes = false, bool hideForwardAndUpArrows = false)
        {
            drawMatrix.Translation = Vector3D.Zero;
            MatrixD drawInverse = MatrixD.Invert(drawMatrix);

            drawInverse *= drawMatrix.GetOrientation();
            drawInverse *= MySector.MainCamera.ViewMatrixAtZero;

            MatrixD camWorld = MatrixD.Invert(drawInverse);

            m_viewProjection.ViewAtZero             = MatrixD.CreateLookAt(Vector3D.Zero, camWorld.Forward, camWorld.Up);
            m_viewProjection.ViewAtZero.Translation = new Vector3D(0, 0, -6);
            m_viewProjection.View              = drawInverse;
            m_viewProjection.View.Translation += new Vector3D(0, 0, -10);
            m_viewProjection.CameraPosition    = camWorld.Translation;

            Vector2 screenSize = MyGuiManager.GetScreenSizeFromNormalizedSize(Vector2.One);
            float   previewRatio = 2.5f;
            int     hintsWidth = (int)(screenSize.X / previewRatio), hintsHeight = (int)(screenSize.Y / previewRatio), hintsXOffset = 0, hintsYOffset = 0;

            m_viewProjection.Viewport = new MyViewport(
                (int)MySector.MainCamera.Viewport.Width - hintsWidth - hintsXOffset,
                hintsYOffset,
                hintsWidth,
                hintsHeight);

            m_viewProjection.DepthRead  = false;
            m_viewProjection.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, (float)hintsHeight / hintsWidth, 0.1f, 10);



            worldBox = new BoundingBoxD(-new Vector3(MyDefinitionManager.Static.GetCubeSize(MyCubeSize.Large) * 0.5f), new Vector3(MyDefinitionManager.Static.GetCubeSize(MyCubeSize.Large)) * 0.5f);


            //m_rotationHintsViewProjection.Projection = MySector.MainCamera.ProjectionMatrix;



            int projectionId = 0;

            VRageRender.MyRenderProxy.AddBillboardViewProjection(projectionId, m_viewProjection);

            //MySimpleObjectDraw.DrawTransparentBox(ref drawMatrix,
            //                ref worldBox, ref Vector4.One, MySimpleObjectRasterizer.Wireframe, 1, 0.04f, null, null, false, 0);
            if (draw)
            {
                var white = Color.White;
                MySimpleObjectDraw.DrawTransparentBox(ref drawMatrix,
                                                      ref worldBox, ref white, MySimpleObjectRasterizer.Solid, 1, 0.04f, "SquareFullColor", null, false, projectionId, 100);
            }

            MyOrientedBoundingBoxD rotateHintsBox = new MyOrientedBoundingBoxD(Vector3D.Transform(worldBox.Center, drawMatrix), worldBox.HalfExtents, Quaternion.CreateFromRotationMatrix(drawMatrix));

            //VRageRender.MyRenderProxy.DebugDrawOBB(rotateHintsBox, Vector3.One, 1, false, false);


            rotateHintsBox.GetCorners(m_cubeVertices, 0);

            //for (int vi = 0; vi < 8; vi++)
            //{
            //    VRageRender.MyRenderProxy.DebugDrawText3D(m_cubeVertices[vi], vi.ToString(), Color.White, 0.7f, false);
            //}

            //for (int vi = 0; vi < 4; vi++)
            //{
            //    VRageRender.MyRenderProxy.DebugDrawText3D((m_cubeVertices[MyOrientedBoundingBox.StartXVertices[vi]] + m_cubeVertices[MyOrientedBoundingBox.EndXVertices[vi]]) * 0.5f, vi.ToString(), Color.Red, 0.7f, false);
            //    VRageRender.MyRenderProxy.DebugDrawText3D((m_cubeVertices[MyOrientedBoundingBox.StartYVertices[vi]] + m_cubeVertices[MyOrientedBoundingBox.EndYVertices[vi]]) * 0.5f, vi.ToString(), Color.Green, 0.7f, false);
            //    VRageRender.MyRenderProxy.DebugDrawText3D((m_cubeVertices[MyOrientedBoundingBox.StartZVertices[vi]] + m_cubeVertices[MyOrientedBoundingBox.EndZVertices[vi]]) * 0.5f, vi.ToString(), Color.Blue, 0.7f, false);
            //}

            int closestXAxis, closestXAxis2;

            GetClosestCubeEdge(m_cubeVertices, MyOrientedBoundingBox.StartXVertices, MyOrientedBoundingBox.EndXVertices, out closestXAxis, out closestXAxis2);
            Vector3D startXVertex  = m_cubeVertices[MyOrientedBoundingBox.StartXVertices[closestXAxis]];
            Vector3D endXVertex    = m_cubeVertices[MyOrientedBoundingBox.EndXVertices[closestXAxis]];
            Vector3D startXVertex2 = m_cubeVertices[MyOrientedBoundingBox.StartXVertices[closestXAxis2]];
            Vector3D endXVertex2   = m_cubeVertices[MyOrientedBoundingBox.EndXVertices[closestXAxis2]];

            int closestYAxis, closestYAxis2;

            GetClosestCubeEdge(m_cubeVertices, MyOrientedBoundingBox.StartYVertices, MyOrientedBoundingBox.EndYVertices, out closestYAxis, out closestYAxis2);
            Vector3D startYVertex  = m_cubeVertices[MyOrientedBoundingBox.StartYVertices[closestYAxis]];
            Vector3D endYVertex    = m_cubeVertices[MyOrientedBoundingBox.EndYVertices[closestYAxis]];
            Vector3D startYVertex2 = m_cubeVertices[MyOrientedBoundingBox.StartYVertices[closestYAxis2]];
            Vector3D endYVertex2   = m_cubeVertices[MyOrientedBoundingBox.EndYVertices[closestYAxis2]];

            int closestZAxis, closestZAxis2;

            GetClosestCubeEdge(m_cubeVertices, MyOrientedBoundingBox.StartZVertices, MyOrientedBoundingBox.EndZVertices, out closestZAxis, out closestZAxis2);
            Vector3D startZVertex  = m_cubeVertices[MyOrientedBoundingBox.StartZVertices[closestZAxis]];
            Vector3D endZVertex    = m_cubeVertices[MyOrientedBoundingBox.EndZVertices[closestZAxis]];
            Vector3D startZVertex2 = m_cubeVertices[MyOrientedBoundingBox.StartZVertices[closestZAxis2]];
            Vector3D endZVertex2   = m_cubeVertices[MyOrientedBoundingBox.EndZVertices[closestZAxis2]];

            m_cubeEdges.Clear();
            m_cubeEdges.Add(new BoxEdge()
            {
                Axis = 0, Edge = new LineD(startXVertex, endXVertex)
            });
            m_cubeEdges.Add(new BoxEdge()
            {
                Axis = 1, Edge = new LineD(startYVertex, endYVertex)
            });
            m_cubeEdges.Add(new BoxEdge()
            {
                Axis = 2, Edge = new LineD(startZVertex, endZVertex)
            });

            if (!fixedAxes)
            {
                int rotDirection;

                RotationRightAxis      = GetBestAxis(m_cubeEdges, MySector.MainCamera.WorldMatrix.Right, out rotDirection);
                RotationRightDirection = rotDirection;

                RotationUpAxis      = GetBestAxis(m_cubeEdges, MySector.MainCamera.WorldMatrix.Up, out rotDirection);
                RotationUpDirection = rotDirection;

                RotationForwardAxis      = GetBestAxis(m_cubeEdges, MySector.MainCamera.WorldMatrix.Forward, out rotDirection);
                RotationForwardDirection = rotDirection;
            }

            string rightControlName1 = MyInput.Static.GetGameControl(MyControlsSpace.CUBE_ROTATE_HORISONTAL_POSITIVE).GetControlButtonName(MyGuiInputDeviceEnum.Keyboard).ToString();
            string rightControlName2 = MyInput.Static.GetGameControl(MyControlsSpace.CUBE_ROTATE_HORISONTAL_NEGATIVE).GetControlButtonName(MyGuiInputDeviceEnum.Keyboard).ToString();
            string upControlName1    = MyInput.Static.GetGameControl(MyControlsSpace.CUBE_ROTATE_VERTICAL_POSITIVE).GetControlButtonName(MyGuiInputDeviceEnum.Keyboard).ToString();
            string upControlName2    = MyInput.Static.GetGameControl(MyControlsSpace.CUBE_ROTATE_VERTICAL_NEGATIVE).GetControlButtonName(MyGuiInputDeviceEnum.Keyboard).ToString();
            string forwControlName1  = MyInput.Static.GetGameControl(MyControlsSpace.CUBE_ROTATE_ROLL_POSITIVE).GetControlButtonName(MyGuiInputDeviceEnum.Keyboard).ToString();
            string forwControlName2  = MyInput.Static.GetGameControl(MyControlsSpace.CUBE_ROTATE_ROLL_NEGATIVE).GetControlButtonName(MyGuiInputDeviceEnum.Keyboard).ToString();

            if (MyInput.Static.IsJoystickConnected())
            {
                rightControlName1 = MyControllerHelper.GetCodeForControl(MySpaceBindingCreator.CX_BUILD_MODE, MyControlsSpace.CUBE_ROTATE_HORISONTAL_POSITIVE).ToString();
                rightControlName2 = MyControllerHelper.GetCodeForControl(MySpaceBindingCreator.CX_BUILD_MODE, MyControlsSpace.CUBE_ROTATE_HORISONTAL_NEGATIVE).ToString();
                upControlName1    = MyControllerHelper.GetCodeForControl(MySpaceBindingCreator.CX_BUILD_MODE, MyControlsSpace.CUBE_ROTATE_VERTICAL_POSITIVE).ToString();
                upControlName2    = MyControllerHelper.GetCodeForControl(MySpaceBindingCreator.CX_BUILD_MODE, MyControlsSpace.CUBE_ROTATE_VERTICAL_NEGATIVE).ToString();
                forwControlName1  = MyControllerHelper.GetCodeForControl(MySpaceBindingCreator.CX_BUILD_MODE, MyControlsSpace.CUBE_ROTATE_ROLL_POSITIVE).ToString();
                forwControlName2  = MyControllerHelper.GetCodeForControl(MySpaceBindingCreator.CX_BUILD_MODE, MyControlsSpace.CUBE_ROTATE_ROLL_NEGATIVE).ToString();
            }

            Vector3D rightStart = Vector3D.Zero;
            Vector3D rightEnd = Vector3D.Zero;
            Vector3D upStart = Vector3D.Zero;
            Vector3D upEnd = Vector3D.Zero;
            Vector3D forwStart = Vector3D.Zero;
            Vector3D forwEnd = Vector3D.Zero;
            Vector3D rightStart2 = Vector3D.Zero;
            Vector3D rightEnd2 = Vector3D.Zero;
            Vector3D upStart2 = Vector3D.Zero;
            Vector3D upEnd2 = Vector3D.Zero;
            Vector3D forwStart2 = Vector3D.Zero;
            Vector3D forwEnd2 = Vector3D.Zero;
            int      rightAxis = -1, upAxis = -1, forwAxis = -1;
            int      closestRightEdge = -1, closestUpEdge = -1, closestForwEdge = -1;
            int      closestRightEdge2 = -1, closestUpEdge2 = -1, closestForwEdge2 = -1;

            if (RotationRightAxis == 0)
            {
                rightStart        = startXVertex;
                rightEnd          = endXVertex;
                rightStart2       = startXVertex2;
                rightEnd2         = endXVertex2;
                rightAxis         = 0;
                closestRightEdge  = closestXAxis;
                closestRightEdge2 = closestXAxis2;
            }
            else
            if (RotationRightAxis == 1)
            {
                rightStart        = startYVertex;
                rightEnd          = endYVertex;
                rightStart2       = startYVertex2;
                rightEnd2         = endYVertex2;
                rightAxis         = 1;
                closestRightEdge  = closestYAxis;
                closestRightEdge2 = closestYAxis2;
            }
            else
            if (RotationRightAxis == 2)
            {
                rightStart        = startZVertex;
                rightEnd          = endZVertex;
                rightStart2       = startZVertex2;
                rightEnd2         = endZVertex2;
                rightAxis         = 2;
                closestRightEdge  = closestZAxis;
                closestRightEdge2 = closestZAxis2;
            }
            else
            {
                System.Diagnostics.Debug.Assert(false, "Not defined axis");
            }

            if (RotationUpAxis == 0)
            {
                upStart        = startXVertex;
                upEnd          = endXVertex;
                upStart2       = startXVertex2;
                upEnd2         = endXVertex2;
                upAxis         = 0;
                closestUpEdge  = closestXAxis;
                closestUpEdge2 = closestXAxis2;
            }
            else
            if (RotationUpAxis == 1)
            {
                upStart        = startYVertex;
                upEnd          = endYVertex;
                upStart2       = startYVertex2;
                upEnd2         = endYVertex2;
                upAxis         = 1;
                closestUpEdge  = closestYAxis;
                closestUpEdge2 = closestYAxis2;
            }
            else
            if (RotationUpAxis == 2)
            {
                upStart        = startZVertex;
                upEnd          = endZVertex;
                upStart2       = startZVertex2;
                upEnd2         = endZVertex2;
                upAxis         = 2;
                closestUpEdge  = closestZAxis;
                closestUpEdge2 = closestZAxis2;
            }

            if (RotationForwardAxis == 0)
            {
                forwStart        = startXVertex;
                forwEnd          = endXVertex;
                forwStart2       = startXVertex2;
                forwEnd2         = endXVertex2;
                forwAxis         = 0;
                closestForwEdge  = closestXAxis;
                closestForwEdge2 = closestXAxis2;
            }
            else
            if (RotationForwardAxis == 1)
            {
                forwStart        = startYVertex;
                forwEnd          = endYVertex;
                forwStart2       = startYVertex2;
                forwEnd2         = endYVertex2;
                forwAxis         = 1;
                closestForwEdge  = closestYAxis;
                closestForwEdge2 = closestYAxis2;
            }
            else
            if (RotationForwardAxis == 2)
            {
                forwStart        = startZVertex;
                forwEnd          = endZVertex;
                forwStart2       = startZVertex2;
                forwEnd2         = endZVertex2;
                forwAxis         = 2;
                closestForwEdge  = closestZAxis;
                closestForwEdge2 = closestZAxis2;
            }

            float textScale = 0.7f;

            //Closest axis
            //VRageRender.MyRenderProxy.DebugDrawLine3D(rightStart, rightEnd, Color.Red, Color.Red, false);
            //VRageRender.MyRenderProxy.DebugDrawLine3D(upStart, upEnd, Color.Green, Color.Green, false);
            //VRageRender.MyRenderProxy.DebugDrawLine3D(forwStart, forwEnd, Color.Blue, Color.Blue, false);


            if (draw)
            {
                //if all axis are visible, all are shown on edges
                //if 1 axis is not visible, other 2 must be shown on faces
                //if 2 are not visible, they are shown on faces and the one is shown on face center
                //Vector3 camVector = Vector3.Normalize(rotateHintsBox.Center - MySector.MainCamera.Position);
                Vector3D camVector      = MySector.MainCamera.ForwardVector;
                Vector3D rightDirection = Vector3.Normalize(rightEnd - rightStart);
                Vector3D upDirection    = Vector3.Normalize(upEnd - upStart);
                Vector3D forwDirection  = Vector3.Normalize(forwEnd - forwStart);
                float    dotRight       = Math.Abs(Vector3.Dot(camVector, rightDirection));
                float    dotUp          = Math.Abs(Vector3.Dot(camVector, upDirection));
                float    dotForw        = Math.Abs(Vector3.Dot(camVector, forwDirection));

                bool drawRightOnFace = false, drawUpOnFace = false, drawForwOnFace = false;
                bool drawRightOnFaceCenter = false, drawUpOnFaceCenter = false, drawForwOnFaceCenter = false;

                float dotAngle = 0.4f;

                if (dotRight < dotAngle)
                {
                    if (dotUp < dotAngle)
                    {
                        drawForwOnFaceCenter = true;
                        drawRightOnFace      = true;
                        drawUpOnFace         = true;

                        System.Diagnostics.Debug.Assert(dotForw >= dotAngle);
                    }
                    else if (dotForw < dotAngle)
                    {
                        drawUpOnFaceCenter = true;
                        drawRightOnFace    = true;
                        drawForwOnFace     = true;

                        System.Diagnostics.Debug.Assert(dotUp >= dotAngle);
                    }
                    else
                    {
                        drawUpOnFace   = true;
                        drawForwOnFace = true;
                    }
                }
                else
                if (dotUp < dotAngle)
                {
                    if (dotRight < dotAngle)
                    {
                        drawForwOnFaceCenter = true;
                        drawRightOnFace      = true;
                        drawUpOnFace         = true;

                        System.Diagnostics.Debug.Assert(dotForw >= dotAngle);
                    }
                    else if (dotForw < dotAngle)
                    {
                        drawRightOnFaceCenter = true;
                        drawUpOnFace          = true;
                        drawForwOnFace        = true;

                        System.Diagnostics.Debug.Assert(dotRight >= dotAngle);
                    }
                    else
                    {
                        drawRightOnFace = true;
                        drawForwOnFace  = true;
                    }
                }
                else
                if (dotForw < dotAngle)
                {
                    if (dotRight < dotAngle)
                    {
                        drawUpOnFaceCenter = true;
                        drawRightOnFace    = true;
                        drawForwOnFace     = true;

                        System.Diagnostics.Debug.Assert(dotUp >= dotAngle);
                    }
                    else if (dotUp < dotAngle)
                    {
                        drawUpOnFaceCenter = true;
                        drawRightOnFace    = true;
                        drawForwOnFace     = true;

                        System.Diagnostics.Debug.Assert(dotRight >= dotAngle);
                    }
                    else
                    {
                        drawUpOnFace    = true;
                        drawRightOnFace = true;
                    }
                }

                //Draw according to cube visual appearance

                if (!(hideForwardAndUpArrows && RotationRightAxis != 1))
                {
                    if (drawRightOnFaceCenter)
                    {
                        //                VRageRender.MyRenderProxy.DebugDrawSphere((forwStart + forwEnd + forwStart2 + forwEnd2) * 0.25f, 0.2f, Vector3.Right, 1.0f, false, false);
                        Vector3D faceCenter = (forwStart + forwEnd + forwStart2 + forwEnd2) * 0.25f;

                        MyTransparentGeometry.AddBillboardOriented(
                            "ArrowLeftGreen",
                            Vector4.One,
                            faceCenter - RotationForwardDirection * forwDirection * 0.2f - RotationRightDirection * rightDirection * 0.01f,
                            -RotationForwardDirection * forwDirection,
                            -RotationUpDirection * upDirection,
                            0.2f,
                            110, false, projectionId);

                        MyTransparentGeometry.AddBillboardOriented(
                            "ArrowRightGreen",
                            Vector4.One,
                            faceCenter + RotationForwardDirection * forwDirection * 0.2f - RotationRightDirection * rightDirection * 0.01f,
                            RotationForwardDirection * forwDirection,
                            RotationUpDirection * upDirection,
                            0.2f,
                            110, false, projectionId);

                        VRageRender.MyRenderProxy.DebugDrawText3D(faceCenter - RotationForwardDirection * forwDirection * 0.2f - RotationRightDirection * rightDirection * 0.01f, rightControlName2, Color.White, textScale, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, projectionId);
                        VRageRender.MyRenderProxy.DebugDrawText3D(faceCenter + RotationForwardDirection * forwDirection * 0.2f - RotationRightDirection * rightDirection * 0.01f, rightControlName1, Color.White, textScale, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, projectionId);
                    }
                    else
                    if (drawRightOnFace)
                    {
                        //VRageRender.MyRenderProxy.DebugDrawLine3D(rightStart2, rightEnd2, Color.Red, Color.Red, false);

                        Vector3 normalRightBack, normalRightForw;
                        MyOrientedBoundingBox.GetNormalBetweenEdges(rightAxis, closestRightEdge, closestRightEdge2, out normalRightForw);
                        Vector3D rightCenter          = (rightStart + rightEnd) * 0.5f;
                        Vector3D rightNormalForwWorld = Vector3D.TransformNormal(normalRightForw, drawMatrix);

                        MyOrientedBoundingBox.GetNormalBetweenEdges(rightAxis, closestRightEdge2, closestRightEdge, out normalRightBack);
                        Vector3D rightCenter2         = (rightStart2 + rightEnd2) * 0.5f;
                        Vector3D rightNormalBackWorld = Vector3D.TransformNormal(normalRightBack, drawMatrix);

                        //VRageRender.MyRenderProxy.DebugDrawLine3D(rightCenter, rightCenter + rightNormalForwWorld, Color.Red, Color.Red, false);
                        //VRageRender.MyRenderProxy.DebugDrawLine3D(rightCenter2, rightCenter2 + rightNormalBackWorld, Color.Red, Color.Red, false);

                        int  normalEdge = -1;
                        bool opposite   = false;
                        if (closestRightEdge == 0 && closestRightEdge2 == 3)
                        {
                            normalEdge = closestRightEdge + 1;
                        }
                        else
                        if ((closestRightEdge < closestRightEdge2) || (closestRightEdge == 3 && closestRightEdge2 == 0))
                        {
                            normalEdge = closestRightEdge - 1;
                            opposite   = true;
                        }
                        else
                        {
                            normalEdge = closestRightEdge + 1;
                        }

                        if (RotationRightDirection < 0)
                        {
                            opposite = !opposite;
                        }

                        Vector3 rightOffset;
                        MyOrientedBoundingBox.GetNormalBetweenEdges(rightAxis, closestRightEdge, normalEdge, out rightOffset);
                        Vector3D rightOffsetWorld = Vector3D.TransformNormal(rightOffset, drawMatrix);

                        //VRageRender.MyRenderProxy.DebugDrawText3D(rightCenter + rightNormalForwWorld * 0.6f - rightOffsetWorld * 0.01f, opposite ? rightControlName2 : rightControlName1, Color.White, textScale, false);
                        //VRageRender.MyRenderProxy.DebugDrawText3D(rightCenter2 + rightNormalBackWorld * 0.6f - rightOffsetWorld * 0.01f, opposite ? rightControlName1 : rightControlName2, Color.White, textScale, false);

                        MyTransparentGeometry.AddBillboardOriented(
                            "ArrowGreen",
                            Vector4.One,
                            rightCenter + rightNormalForwWorld * 0.4f - rightOffsetWorld * 0.01f,
                            rightNormalBackWorld,
                            rightDirection,
                            0.5f,
                            110, false, projectionId);

                        MyTransparentGeometry.AddBillboardOriented(
                            "ArrowGreen",
                            Vector4.One,
                            rightCenter2 + rightNormalBackWorld * 0.4f - rightOffsetWorld * 0.01f,
                            rightNormalForwWorld,
                            rightDirection,
                            0.5f,
                            110, false, projectionId);

                        VRageRender.MyRenderProxy.DebugDrawText3D(rightCenter + rightNormalForwWorld * 0.3f - rightOffsetWorld * 0.01f, opposite ? rightControlName1 : rightControlName2, Color.White, textScale, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, projectionId);
                        VRageRender.MyRenderProxy.DebugDrawText3D(rightCenter2 + rightNormalBackWorld * 0.3f - rightOffsetWorld * 0.01f, opposite ? rightControlName2 : rightControlName1, Color.White, textScale, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, projectionId);
                    }
                    else     //draw on edge
                    {
                        Vector3 normalRightBack, normalRightForw;
                        MyOrientedBoundingBox.GetNormalBetweenEdges(rightAxis, closestRightEdge, closestRightEdge + 1, out normalRightForw);
                        MyOrientedBoundingBox.GetNormalBetweenEdges(rightAxis, closestRightEdge, closestRightEdge - 1, out normalRightBack);
                        Vector3D rightCenter          = (rightStart + rightEnd) * 0.5f;
                        Vector3D rightNormalForwWorld = Vector3D.TransformNormal(normalRightForw, drawMatrix);
                        Vector3D rightNormalBackWorld = Vector3D.TransformNormal(normalRightBack, drawMatrix);
                        //VRageRender.MyRenderProxy.DebugDrawLine3D(rightCenter, rightCenter + rightNormalForwWorld, Color.Red, Color.Red, false);
                        //VRageRender.MyRenderProxy.DebugDrawLine3D(rightCenter, rightCenter + rightNormalBackWorld, Color.Red, Color.Red, false);

                        MyTransparentGeometry.AddBillboardOriented(
                            "ArrowGreen",
                            Vector4.One,
                            rightCenter + rightNormalForwWorld * 0.3f - rightNormalBackWorld * 0.01f,
                            rightNormalForwWorld,
                            rightDirection,
                            0.5f,
                            110, false, projectionId);

                        MyTransparentGeometry.AddBillboardOriented(
                            "ArrowGreen",
                            Vector4.One,
                            rightCenter + rightNormalBackWorld * 0.3f - rightNormalForwWorld * 0.01f,
                            rightNormalBackWorld,
                            rightDirection,
                            0.5f,
                            110, false, projectionId);

                        VRageRender.MyRenderProxy.DebugDrawText3D(rightCenter + rightNormalForwWorld * 0.3f - rightNormalBackWorld * 0.01f, RotationRightDirection < 0 ? rightControlName1 : rightControlName2, Color.White, textScale, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, projectionId);
                        VRageRender.MyRenderProxy.DebugDrawText3D(rightCenter + rightNormalBackWorld * 0.3f - rightNormalForwWorld * 0.01f, RotationRightDirection < 0 ? rightControlName2 : rightControlName1, Color.White, textScale, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, projectionId);
                    }
                }

                if (!(hideForwardAndUpArrows && RotationUpAxis != 1))
                {
                    if (drawUpOnFaceCenter)
                    {
                        //VRageRender.MyRenderProxy.DebugDrawSphere((forwStart + forwEnd + forwStart2 + forwEnd2) * 0.25f, 0.2f, Vector3.Up, 1.0f, false, false);

                        Vector3D faceCenter = (forwStart + forwEnd + forwStart2 + forwEnd2) * 0.25f;

                        MyTransparentGeometry.AddBillboardOriented(
                            "ArrowLeftRed",
                            Vector4.One,
                            faceCenter - RotationRightDirection * rightDirection * 0.2f - RotationUpDirection * upDirection * 0.01f,
                            -RotationRightDirection * rightDirection,
                            -RotationForwardDirection * forwDirection,
                            0.2f,
                            110, false, projectionId);

                        MyTransparentGeometry.AddBillboardOriented(
                            "ArrowRightRed",
                            Vector4.One,
                            faceCenter + RotationRightDirection * rightDirection * 0.2f - RotationUpDirection * upDirection * 0.01f,
                            RotationRightDirection * rightDirection,
                            RotationForwardDirection * forwDirection,
                            0.2f,
                            110, false, projectionId);

                        VRageRender.MyRenderProxy.DebugDrawText3D(faceCenter - RotationRightDirection * rightDirection * 0.2f - RotationUpDirection * upDirection * 0.01f, upControlName1, Color.White, textScale, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, projectionId);
                        VRageRender.MyRenderProxy.DebugDrawText3D(faceCenter + RotationRightDirection * rightDirection * 0.2f - RotationUpDirection * upDirection * 0.01f, upControlName2, Color.White, textScale, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, projectionId);
                    }
                    else
                    if (drawUpOnFace)
                    {
                        //VRageRender.MyRenderProxy.DebugDrawLine3D(upStart2, upEnd2, Color.Green, Color.Green, false);

                        Vector3 normalUpBack, normalUpForw;
                        MyOrientedBoundingBox.GetNormalBetweenEdges(upAxis, closestUpEdge, closestUpEdge2, out normalUpForw);
                        Vector3D upCenter          = (upStart + upEnd) * 0.5f;
                        Vector3  upNormalForwWorld = Vector3.TransformNormal(normalUpForw, drawMatrix);

                        MyOrientedBoundingBox.GetNormalBetweenEdges(upAxis, closestUpEdge2, closestUpEdge, out normalUpBack);
                        Vector3D upCenter2         = (upStart2 + upEnd2) * 0.5f;
                        Vector3  upNormalBackWorld = Vector3.TransformNormal(normalUpBack, drawMatrix);

                        //VRageRender.MyRenderProxy.DebugDrawLine3D(upCenter, upCenter + upNormalForwWorld, Color.Green, Color.Green, false);
                        //VRageRender.MyRenderProxy.DebugDrawLine3D(upCenter2, upCenter2 + upNormalBackWorld, Color.Green, Color.Green, false);

                        int  normalEdge = -1;
                        bool opposite   = false;
                        if (closestUpEdge == 0 && closestUpEdge2 == 3)
                        {
                            normalEdge = closestUpEdge + 1;
                        }
                        else
                        if ((closestUpEdge < closestUpEdge2) || (closestUpEdge == 3 && closestUpEdge2 == 0))
                        {
                            normalEdge = closestUpEdge - 1;
                            opposite   = true;
                        }
                        else
                        {
                            normalEdge = closestUpEdge + 1;
                        }

                        if (RotationUpDirection < 0)
                        {
                            opposite = !opposite;
                        }

                        Vector3 upOffset;
                        MyOrientedBoundingBox.GetNormalBetweenEdges(upAxis, closestUpEdge, normalEdge, out upOffset);
                        Vector3 upOffsetWorld = Vector3.TransformNormal(upOffset, drawMatrix);

                        //VRageRender.MyRenderProxy.DebugDrawText3D(upCenter + upNormalForwWorld * 0.6f - upOffsetWorld * 0.01f, opposite ? upControlName1 : upControlName2, Color.White, textScale, false);
                        //VRageRender.MyRenderProxy.DebugDrawText3D(upCenter2 + upNormalBackWorld * 0.6f - upOffsetWorld * 0.01f, opposite ? upControlName2 : upControlName1, Color.White, textScale, false);

                        MyTransparentGeometry.AddBillboardOriented(
                            "ArrowRed",
                            Vector4.One,
                            upCenter + upNormalForwWorld * 0.4f - upOffsetWorld * 0.01f,
                            upNormalBackWorld,
                            upDirection,
                            0.5f,
                            110, false, projectionId);

                        MyTransparentGeometry.AddBillboardOriented(
                            "ArrowRed",
                            Vector4.One,
                            upCenter2 + upNormalBackWorld * 0.4f - upOffsetWorld * 0.01f,
                            upNormalForwWorld,
                            upDirection,
                            0.5f,
                            110, false, projectionId);

                        VRageRender.MyRenderProxy.DebugDrawText3D(upCenter + upNormalForwWorld * 0.3f - upOffsetWorld * 0.01f, opposite ? upControlName2 : upControlName1, Color.White, textScale, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, projectionId);
                        VRageRender.MyRenderProxy.DebugDrawText3D(upCenter2 + upNormalBackWorld * 0.3f - upOffsetWorld * 0.01f, opposite ? upControlName1 : upControlName2, Color.White, textScale, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, projectionId);
                    }
                    else     //draw on edge
                    {
                        Vector3 normalUpBack, normalUpForw;
                        MyOrientedBoundingBox.GetNormalBetweenEdges(upAxis, closestUpEdge, closestUpEdge + 1, out normalUpForw);
                        MyOrientedBoundingBox.GetNormalBetweenEdges(upAxis, closestUpEdge, closestUpEdge - 1, out normalUpBack);
                        Vector3D upCenter          = (upStart + upEnd) * 0.5f;
                        Vector3  upNormalForwWorld = Vector3.TransformNormal(normalUpForw, drawMatrix);
                        Vector3  upNormalBackWorld = Vector3.TransformNormal(normalUpBack, drawMatrix);
                        //VRageRender.MyRenderProxy.DebugDrawLine3D(upCenter, upCenter + upNormalForwWorld, Color.Green, Color.Green, false);
                        //VRageRender.MyRenderProxy.DebugDrawLine3D(upCenter, upCenter + upNormalBackWorld, Color.Green, Color.Green, false);

                        MyTransparentGeometry.AddBillboardOriented(
                            "ArrowRed",
                            Vector4.One,
                            upCenter + upNormalForwWorld * 0.3f - upNormalBackWorld * 0.01f,
                            upNormalForwWorld,
                            upDirection,
                            0.5f,
                            110, false, projectionId);

                        MyTransparentGeometry.AddBillboardOriented(
                            "ArrowRed",
                            Vector4.One,
                            upCenter + upNormalBackWorld * 0.3f - upNormalForwWorld * 0.01f,
                            upNormalBackWorld,
                            upDirection,
                            0.5f,
                            110, false, projectionId);

                        VRageRender.MyRenderProxy.DebugDrawText3D(upCenter + upNormalForwWorld * 0.6f - upNormalBackWorld * 0.01f, RotationUpDirection > 0 ? upControlName1 : upControlName2, Color.White, textScale, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, projectionId);
                        VRageRender.MyRenderProxy.DebugDrawText3D(upCenter + upNormalBackWorld * 0.6f - upNormalForwWorld * 0.01f, RotationUpDirection > 0 ? upControlName2 : upControlName1, Color.White, textScale, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, projectionId);
                    }
                }

                if (!(hideForwardAndUpArrows && RotationForwardAxis != 1))
                {
                    if (drawForwOnFaceCenter)
                    {
                        //VRageRender.MyRenderProxy.DebugDrawSphere((rightStart + rightEnd + rightStart2 + rightEnd2) * 0.25f, 0.2f, Vector3.Backward, 1.0f, false, false);

                        Vector3D faceCenter = (rightStart + rightEnd + rightStart2 + rightEnd2) * 0.25f;

                        MyTransparentGeometry.AddBillboardOriented(
                            "ArrowLeftBlue",
                            Vector4.One,
                            faceCenter + RotationUpDirection * upDirection * 0.2f - RotationForwardDirection * forwDirection * 0.01f,
                            RotationUpDirection * upDirection,
                            -RotationRightDirection * rightDirection,
                            0.2f,
                            110, false, projectionId);

                        MyTransparentGeometry.AddBillboardOriented(
                            "ArrowRightBlue",
                            Vector4.One,
                            faceCenter - RotationUpDirection * upDirection * 0.2f - RotationForwardDirection * forwDirection * 0.01f,
                            -RotationUpDirection * upDirection,
                            RotationRightDirection * rightDirection,
                            0.2f,
                            110, false, projectionId);

                        VRageRender.MyRenderProxy.DebugDrawText3D(faceCenter + RotationUpDirection * upDirection * 0.2f - RotationForwardDirection * forwDirection * 0.01f, forwControlName1, Color.White, textScale, false, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, projectionId);
                        VRageRender.MyRenderProxy.DebugDrawText3D(faceCenter - RotationUpDirection * upDirection * 0.2f - RotationForwardDirection * forwDirection * 0.01f, forwControlName2, Color.White, textScale, false, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, projectionId);
                    }
                    else
                    if (drawForwOnFace)
                    {
                        //VRageRender.MyRenderProxy.DebugDrawLine3D(forwStart2, forwEnd2, Color.Blue, Color.Blue, false);

                        Vector3 normalForwBack, normalForwForw;
                        MyOrientedBoundingBox.GetNormalBetweenEdges(forwAxis, closestForwEdge, closestForwEdge2, out normalForwForw);
                        Vector3D forwCenter          = (forwStart + forwEnd) * 0.5f;
                        Vector3  forwNormalForwWorld = Vector3.TransformNormal(normalForwForw, drawMatrix);

                        MyOrientedBoundingBox.GetNormalBetweenEdges(forwAxis, closestForwEdge2, closestForwEdge, out normalForwBack);
                        Vector3D forwCenter2         = (forwStart2 + forwEnd2) * 0.5f;
                        Vector3  forwNormalBackWorld = Vector3.TransformNormal(normalForwBack, drawMatrix);

                        //VRageRender.MyRenderProxy.DebugDrawLine3D(forwCenter, forwCenter + forwNormalForwWorld, Color.Blue, Color.Blue, false);
                        //VRageRender.MyRenderProxy.DebugDrawLine3D(forwCenter2, forwCenter2 + forwNormalBackWorld, Color.Blue, Color.Blue, false);

                        int  normalEdge = -1;
                        bool opposite   = false;
                        if (closestForwEdge == 0 && closestForwEdge2 == 3)
                        {
                            normalEdge = closestForwEdge + 1;
                        }
                        else
                        if ((closestForwEdge < closestForwEdge2) || (closestForwEdge == 3 && closestForwEdge2 == 0))
                        {
                            normalEdge = closestForwEdge - 1;
                            opposite   = true;
                        }
                        else
                        {
                            normalEdge = closestForwEdge + 1;
                        }

                        if (RotationForwardDirection < 0)
                        {
                            opposite = !opposite;
                        }

                        Vector3 forwOffset;
                        MyOrientedBoundingBox.GetNormalBetweenEdges(forwAxis, closestForwEdge, normalEdge, out forwOffset);
                        Vector3 forwOffsetWorld = Vector3.TransformNormal(forwOffset, drawMatrix);

                        //VRageRender.MyRenderProxy.DebugDrawText3D(forwCenter + forwNormalForwWorld * 0.6f - forwOffsetWorld * 0.01f, opposite ? forwControlName2 : forwControlName1, Color.White, textScale, false);
                        //VRageRender.MyRenderProxy.DebugDrawText3D(forwCenter2 + forwNormalBackWorld * 0.6f - forwOffsetWorld * 0.01f, opposite ? forwControlName1 : forwControlName2, Color.White, textScale, false);

                        MyTransparentGeometry.AddBillboardOriented(
                            "ArrowBlue",
                            Vector4.One,
                            forwCenter + forwNormalForwWorld * 0.4f - forwOffsetWorld * 0.01f,
                            forwNormalBackWorld,
                            forwDirection,
                            0.5f,
                            110, false, projectionId);

                        MyTransparentGeometry.AddBillboardOriented(
                            "ArrowBlue",
                            Vector4.One,
                            forwCenter2 + forwNormalBackWorld * 0.4f - forwOffsetWorld * 0.01f,
                            forwNormalForwWorld,
                            forwDirection,
                            0.5f,
                            110, false, projectionId);

                        VRageRender.MyRenderProxy.DebugDrawText3D(forwCenter + forwNormalForwWorld * 0.3f - forwOffsetWorld * 0.01f, opposite ? forwControlName1 : forwControlName2, Color.White, textScale, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, projectionId);
                        VRageRender.MyRenderProxy.DebugDrawText3D(forwCenter2 + forwNormalBackWorld * 0.3f - forwOffsetWorld * 0.01f, opposite ? forwControlName2 : forwControlName1, Color.White, textScale, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, projectionId);
                    }
                    else     //draw on edge
                    {
                        Vector3 normalForwBack, normalForwForw;
                        MyOrientedBoundingBox.GetNormalBetweenEdges(forwAxis, closestForwEdge, closestForwEdge + 1, out normalForwForw);
                        MyOrientedBoundingBox.GetNormalBetweenEdges(forwAxis, closestForwEdge, closestForwEdge - 1, out normalForwBack);
                        Vector3D forwCenter          = (forwStart + forwEnd) * 0.5f;
                        Vector3  forwNormalForwWorld = Vector3.TransformNormal(normalForwForw, drawMatrix);
                        Vector3  forwNormalBackWorld = Vector3.TransformNormal(normalForwBack, drawMatrix);
                        //VRageRender.MyRenderProxy.DebugDrawLine3D(forwCenter, forwCenter + forwNormalForwWorld, Color.Blue, Color.Blue, false);
                        //VRageRender.MyRenderProxy.DebugDrawLine3D(forwCenter, forwCenter + forwNormalBackWorld, Color.Blue, Color.Blue, false);

                        MyTransparentGeometry.AddBillboardOriented(
                            "ArrowBlue",
                            Vector4.One,
                            forwCenter + forwNormalForwWorld * 0.3f - forwNormalBackWorld * 0.01f,
                            forwNormalForwWorld,
                            forwDirection,
                            0.5f,
                            110, false, projectionId);

                        MyTransparentGeometry.AddBillboardOriented(
                            "ArrowBlue",
                            Vector4.One,
                            forwCenter + forwNormalBackWorld * 0.3f - forwNormalForwWorld * 0.01f,
                            forwNormalBackWorld,
                            forwDirection,
                            0.5f,
                            110, false, projectionId);

                        VRageRender.MyRenderProxy.DebugDrawText3D(forwCenter + forwNormalForwWorld * 0.3f - forwNormalBackWorld * 0.01f, RotationForwardDirection < 0 ? forwControlName1 : forwControlName2, Color.White, textScale, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, projectionId);
                        VRageRender.MyRenderProxy.DebugDrawText3D(forwCenter + forwNormalBackWorld * 0.3f - forwNormalForwWorld * 0.01f, RotationForwardDirection < 0 ? forwControlName2 : forwControlName1, Color.White, textScale, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, projectionId);
                    }
                }
            }
        }
Пример #27
0
        public unsafe void CalculateRotationHints(MatrixD drawMatrix, bool draw, bool fixedAxes = false, bool hideForwardAndUpArrows = false)
        {
            int      num6;
            string   controlButtonName;
            string   str2;
            string   str3;
            string   str4;
            string   str5;
            string   str6;
            Vector3D zero;
            Vector3D vectord14;
            Vector3D vectord15;
            Vector3D vectord16;
            Vector3D vectord17;
            Vector3D vectord18;
            Vector3D vectord19;
            Vector3D vectord20;
            Vector3D vectord21;
            Vector3D vectord22;
            Vector3D vectord23;
            Vector3D vectord24;
            int      num13;
            int      num14;
            int      num15;
            int      num16;
            int      num17;
            int      num18;
            int      num20;
            int      num21;
            float    num22;
            Vector3D vectord25;
            Vector3D vectord26;
            Vector3D vectord27;
            bool     flag2;
            bool     flag3;
            bool     flag5;
            bool     flag6;
            Vector3D vectord29;
            Vector3D vectord30;
            Vector3D vectord31;
            Vector3D vectord32;
            int      num28;
            bool     flag7;
            Vector3  vector3;
            Vector3D vectord38;
            Vector3  vector8;
            Vector3D vectord39;
            Vector3  vector9;
            int      num29;
            bool     flag8;
            Vector3  vector10;
            Matrix   viewMatrix = (Matrix)MySector.MainCamera.ViewMatrix;
            MatrixD  matrix     = MatrixD.Invert(viewMatrix);

            if (!drawMatrix.IsValid())
            {
                return;
            }
            else
            {
                if (viewMatrix.IsValid())
                {
                    int      num7;
                    int      num8;
                    int      num9;
                    int      num10;
                    int      num11;
                    int      num12;
                    MatrixD *xdPtr1 = (MatrixD *)ref matrix;
                    xdPtr1.Translation = ((drawMatrix.Translation - (7.0 * matrix.Forward)) + (1.0 * matrix.Left)) - (0.60000002384185791 * matrix.Up);
                    MatrixD *xdPtr2 = (MatrixD *)ref drawMatrix;
                    xdPtr2.Translation -= matrix.Translation;
                    this.m_viewProjection.CameraPosition = matrix.Translation;
                    matrix.Translation = Vector3D.Zero;
                    Matrix matrix2 = (Matrix)MatrixD.Transpose(matrix);
                    this.m_viewProjection.ViewAtZero = matrix2;
                    float   num = 2.75f;
                    Vector2 screenSizeFromNormalizedSize = MyGuiManager.GetScreenSizeFromNormalizedSize(Vector2.One, false);
                    int     num2 = (int)(screenSizeFromNormalizedSize.X / num);
                    int     num3 = (int)(screenSizeFromNormalizedSize.Y / num);
                    int     num4 = 0;
                    int     num5 = 0;
                    this.m_viewProjection.Viewport   = new MyViewport((float)((((int)MySector.MainCamera.Viewport.Width) - num2) - num4), (float)num5, (float)num2, (float)num3);
                    this.m_viewProjection.Projection = Matrix.CreatePerspectiveFieldOfView(0.7853982f, ((float)num2) / ((float)num3), 0.1f, 10f);
                    BoundingBoxD localbox = new BoundingBoxD(-new Vector3(MyDefinitionManager.Static.GetCubeSize(MyCubeSize.Large) * 0.5f), new Vector3(MyDefinitionManager.Static.GetCubeSize(MyCubeSize.Large)) * 0.5f);
                    num6 = 0;
                    MyRenderProxy.AddBillboardViewProjection(num6, this.m_viewProjection);
                    if (draw)
                    {
                        Color      red          = Color.Red;
                        Color      green        = Color.Green;
                        Color      blue         = Color.Blue;
                        Color      white        = Color.White;
                        Color      color5       = Color.White;
                        Color      color6       = Color.White;
                        Color      wire         = Color.White;
                        MyStringId?lineMaterial = null;
                        MySimpleObjectDraw.DrawTransparentBox(ref drawMatrix, ref localbox, ref red, ref green, ref blue, ref white, ref color5, ref color6, ref wire, MySimpleObjectRasterizer.Solid, 1, 0.04f, new MyStringId?(ID_SQUARE_FULL_COLOR), lineMaterial, false, num6, MyBillboard.BlendTypeEnum.LDR, 1f, null);
                    }
                    new MyOrientedBoundingBoxD(Vector3D.Transform(localbox.Center, drawMatrix), localbox.HalfExtents, Quaternion.CreateFromRotationMatrix(drawMatrix)).GetCorners(this.m_cubeVertices, 0);
                    GetClosestCubeEdge(this.m_cubeVertices, Vector3D.Zero, MyOrientedBoundingBox.StartXVertices, MyOrientedBoundingBox.EndXVertices, out num7, out num8);
                    Vector3D from     = this.m_cubeVertices[MyOrientedBoundingBox.StartXVertices[num7]];
                    Vector3D to       = this.m_cubeVertices[MyOrientedBoundingBox.EndXVertices[num7]];
                    Vector3D vectord3 = this.m_cubeVertices[MyOrientedBoundingBox.StartXVertices[num8]];
                    Vector3D vectord4 = this.m_cubeVertices[MyOrientedBoundingBox.EndXVertices[num8]];
                    GetClosestCubeEdge(this.m_cubeVertices, Vector3D.Zero, MyOrientedBoundingBox.StartYVertices, MyOrientedBoundingBox.EndYVertices, out num9, out num10);
                    Vector3D vectord5 = this.m_cubeVertices[MyOrientedBoundingBox.StartYVertices[num9]];
                    Vector3D vectord6 = this.m_cubeVertices[MyOrientedBoundingBox.EndYVertices[num9]];
                    Vector3D vectord7 = this.m_cubeVertices[MyOrientedBoundingBox.StartYVertices[num10]];
                    Vector3D vectord8 = this.m_cubeVertices[MyOrientedBoundingBox.EndYVertices[num10]];
                    GetClosestCubeEdge(this.m_cubeVertices, Vector3D.Zero, MyOrientedBoundingBox.StartZVertices, MyOrientedBoundingBox.EndZVertices, out num11, out num12);
                    Vector3D vectord9  = this.m_cubeVertices[MyOrientedBoundingBox.StartZVertices[num11]];
                    Vector3D vectord10 = this.m_cubeVertices[MyOrientedBoundingBox.EndZVertices[num11]];
                    Vector3D vectord11 = this.m_cubeVertices[MyOrientedBoundingBox.StartZVertices[num12]];
                    Vector3D vectord12 = this.m_cubeVertices[MyOrientedBoundingBox.EndZVertices[num12]];
                    this.m_cubeEdges.Clear();
                    BoxEdge item = new BoxEdge {
                        Axis = 0,
                        Edge = new LineD(from, to)
                    };
                    this.m_cubeEdges.Add(item);
                    item = new BoxEdge {
                        Axis = 1,
                        Edge = new LineD(vectord5, vectord6)
                    };
                    this.m_cubeEdges.Add(item);
                    item = new BoxEdge {
                        Axis = 2,
                        Edge = new LineD(vectord9, vectord10)
                    };
                    this.m_cubeEdges.Add(item);
                    if (!fixedAxes)
                    {
                        int num23;
                        this.RotationRightAxis        = GetBestAxis(this.m_cubeEdges, MySector.MainCamera.WorldMatrix.Right, out num23);
                        this.RotationRightDirection   = num23;
                        this.RotationUpAxis           = GetBestAxis(this.m_cubeEdges, MySector.MainCamera.WorldMatrix.Up, out num23);
                        this.RotationUpDirection      = num23;
                        this.RotationForwardAxis      = GetBestAxis(this.m_cubeEdges, MySector.MainCamera.WorldMatrix.Forward, out num23);
                        this.RotationForwardDirection = num23;
                    }
                    controlButtonName = MyInput.Static.GetGameControl(MyControlsSpace.CUBE_ROTATE_HORISONTAL_POSITIVE).GetControlButtonName(MyGuiInputDeviceEnum.Keyboard);
                    str2 = MyInput.Static.GetGameControl(MyControlsSpace.CUBE_ROTATE_HORISONTAL_NEGATIVE).GetControlButtonName(MyGuiInputDeviceEnum.Keyboard);
                    str3 = MyInput.Static.GetGameControl(MyControlsSpace.CUBE_ROTATE_VERTICAL_POSITIVE).GetControlButtonName(MyGuiInputDeviceEnum.Keyboard);
                    str4 = MyInput.Static.GetGameControl(MyControlsSpace.CUBE_ROTATE_VERTICAL_NEGATIVE).GetControlButtonName(MyGuiInputDeviceEnum.Keyboard);
                    str5 = MyInput.Static.GetGameControl(MyControlsSpace.CUBE_ROTATE_ROLL_POSITIVE).GetControlButtonName(MyGuiInputDeviceEnum.Keyboard);
                    str6 = MyInput.Static.GetGameControl(MyControlsSpace.CUBE_ROTATE_ROLL_NEGATIVE).GetControlButtonName(MyGuiInputDeviceEnum.Keyboard);
                    if (MyInput.Static.IsJoystickConnected() && MyInput.Static.IsJoystickLastUsed)
                    {
                        controlButtonName = MyControllerHelper.GetCodeForControl(MySpaceBindingCreator.CX_BUILD_MODE, MyControlsSpace.CUBE_ROTATE_HORISONTAL_POSITIVE).ToString();
                        str2 = MyControllerHelper.GetCodeForControl(MySpaceBindingCreator.CX_BUILD_MODE, MyControlsSpace.CUBE_ROTATE_HORISONTAL_NEGATIVE).ToString();
                        str3 = MyControllerHelper.GetCodeForControl(MySpaceBindingCreator.CX_BUILD_MODE, MyControlsSpace.CUBE_ROTATE_VERTICAL_POSITIVE).ToString();
                        str4 = MyControllerHelper.GetCodeForControl(MySpaceBindingCreator.CX_BUILD_MODE, MyControlsSpace.CUBE_ROTATE_VERTICAL_NEGATIVE).ToString();
                        str5 = MyControllerHelper.GetCodeForControl(MySpaceBindingCreator.CX_BUILD_MODE, MyControlsSpace.CUBE_ROTATE_ROLL_POSITIVE).ToString();
                        str6 = MyControllerHelper.GetCodeForControl(MySpaceBindingCreator.CX_BUILD_MODE, MyControlsSpace.CUBE_ROTATE_ROLL_NEGATIVE).ToString();
                    }
                    zero      = Vector3D.Zero;
                    vectord14 = Vector3D.Zero;
                    vectord15 = Vector3D.Zero;
                    vectord16 = Vector3D.Zero;
                    vectord17 = Vector3D.Zero;
                    vectord18 = Vector3D.Zero;
                    vectord19 = Vector3D.Zero;
                    vectord20 = Vector3D.Zero;
                    vectord21 = Vector3D.Zero;
                    vectord22 = Vector3D.Zero;
                    vectord23 = Vector3D.Zero;
                    vectord24 = Vector3D.Zero;
                    num13     = -1;
                    num14     = -1;
                    num15     = -1;
                    num16     = -1;
                    num17     = -1;
                    num18     = -1;
                    int num19 = -1;
                    num20 = -1;
                    num21 = -1;
                    if (this.RotationRightAxis == 0)
                    {
                        zero      = from;
                        vectord14 = to;
                        vectord19 = vectord3;
                        vectord20 = vectord4;
                        num13     = 0;
                        num16     = num7;
                        num19     = num8;
                    }
                    else if (this.RotationRightAxis == 1)
                    {
                        zero      = vectord5;
                        vectord14 = vectord6;
                        vectord19 = vectord7;
                        vectord20 = vectord8;
                        num13     = 1;
                        num16     = num9;
                        num19     = num10;
                    }
                    else if (this.RotationRightAxis == 2)
                    {
                        zero      = vectord9;
                        vectord14 = vectord10;
                        vectord19 = vectord11;
                        vectord20 = vectord12;
                        num13     = 2;
                        num16     = num11;
                        num19     = num12;
                    }
                    if (this.RotationUpAxis == 0)
                    {
                        vectord15 = from;
                        vectord16 = to;
                        vectord21 = vectord3;
                        vectord22 = vectord4;
                        num14     = 0;
                        num17     = num7;
                        num20     = num8;
                    }
                    else if (this.RotationUpAxis == 1)
                    {
                        vectord15 = vectord5;
                        vectord16 = vectord6;
                        vectord21 = vectord7;
                        vectord22 = vectord8;
                        num14     = 1;
                        num17     = num9;
                        num20     = num10;
                    }
                    else if (this.RotationUpAxis == 2)
                    {
                        vectord15 = vectord9;
                        vectord16 = vectord10;
                        vectord21 = vectord11;
                        vectord22 = vectord12;
                        num14     = 2;
                        num17     = num11;
                        num20     = num12;
                    }
                    if (this.RotationForwardAxis == 0)
                    {
                        vectord17 = from;
                        vectord18 = to;
                        vectord23 = vectord3;
                        vectord24 = vectord4;
                        num15     = 0;
                        num18     = num7;
                        num21     = num8;
                    }
                    else if (this.RotationForwardAxis == 1)
                    {
                        vectord17 = vectord5;
                        vectord18 = vectord6;
                        vectord23 = vectord7;
                        vectord24 = vectord8;
                        num15     = 1;
                        num18     = num9;
                        num21     = num10;
                    }
                    else if (this.RotationForwardAxis == 2)
                    {
                        vectord17 = vectord9;
                        vectord18 = vectord10;
                        vectord23 = vectord11;
                        vectord24 = vectord12;
                        num15     = 2;
                        num18     = num11;
                        num21     = num12;
                    }
                    num22 = 0.5448648f;
                    if (!draw)
                    {
                        return;
                    }
                    else
                    {
                        vectord25 = Vector3.Normalize(vectord14 - zero);
                        vectord26 = Vector3.Normalize(vectord16 - vectord15);
                        vectord27 = Vector3.Normalize(vectord18 - vectord17);
                        Vector3D forwardVector = MySector.MainCamera.ForwardVector;
                        float    num24         = Math.Abs(Vector3.Dot((Vector3)forwardVector, (Vector3)vectord25));
                        float    num25         = Math.Abs(Vector3.Dot((Vector3)forwardVector, (Vector3)vectord26));
                        float    num26         = Math.Abs(Vector3.Dot((Vector3)forwardVector, (Vector3)vectord27));
                        bool     flag          = false;
                        flag2 = false;
                        flag3 = false;
                        bool flag4 = false;
                        flag5 = false;
                        flag6 = false;
                        float num27 = 0.4f;
                        if (num24 < num27)
                        {
                            if (num25 < num27)
                            {
                                flag6 = true;
                                flag  = true;
                                flag2 = true;
                            }
                            else if (num26 >= num27)
                            {
                                flag2 = true;
                                flag3 = true;
                            }
                            else
                            {
                                flag5 = true;
                                flag  = true;
                                flag3 = true;
                            }
                        }
                        else if (num25 < num27)
                        {
                            if (num24 < num27)
                            {
                                flag6 = true;
                                flag  = true;
                                flag2 = true;
                            }
                            else if (num26 >= num27)
                            {
                                flag  = true;
                                flag3 = true;
                            }
                            else
                            {
                                flag4 = true;
                                flag2 = true;
                                flag3 = true;
                            }
                        }
                        else if (num26 < num27)
                        {
                            if (num24 < num27)
                            {
                                flag5 = true;
                                flag  = true;
                                flag3 = true;
                            }
                            else if (num25 >= num27)
                            {
                                flag2 = true;
                                flag  = true;
                            }
                            else
                            {
                                flag5 = true;
                                flag  = true;
                                flag3 = true;
                            }
                        }
                        if (hideForwardAndUpArrows && (this.RotationRightAxis != 1))
                        {
                            goto TR_0025;
                        }
                        if (!flag4)
                        {
                            if (!flag)
                            {
                                Vector3 vector4;
                                Vector3 vector5;
                                MyOrientedBoundingBox.GetNormalBetweenEdges(num13, num16, num16 + 1, out vector5);
                                MyOrientedBoundingBox.GetNormalBetweenEdges(num13, num16, num16 - 1, out vector4);
                                Vector3D vectord34 = (zero + vectord14) * 0.5;
                                Vector3D vectord35 = Vector3D.TransformNormal(vector5, drawMatrix);
                                Vector3D vectord36 = Vector3D.TransformNormal(vector4, drawMatrix);
                                MyTransparentGeometry.AddBillboardOriented(ID_ARROW_GREEN, Vector4.One, (vectord34 + (vectord35 * 0.30000001192092896)) - (vectord36 * 0.0099999997764825821), (Vector3)vectord25, (Vector3)vectord35, 0.5f, num6, MyBillboard.BlendTypeEnum.LDR);
                                MyTransparentGeometry.AddBillboardOriented(ID_ARROW_GREEN, Vector4.One, (vectord34 + (vectord36 * 0.30000001192092896)) - (vectord35 * 0.0099999997764825821), (Vector3)vectord25, (Vector3)vectord36, 0.5f, num6, MyBillboard.BlendTypeEnum.LDR);
                                MyRenderProxy.DebugDrawText3D((vectord34 + (vectord35 * 0.30000001192092896)) - (vectord36 * 0.0099999997764825821), (this.RotationRightDirection < 0) ? controlButtonName : str2, Color.White, num22, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, num6, false);
                                MyRenderProxy.DebugDrawText3D((vectord34 + (vectord36 * 0.30000001192092896)) - (vectord35 * 0.0099999997764825821), (this.RotationRightDirection < 0) ? str2 : controlButtonName, Color.White, num22, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, num6, false);
                                goto TR_0025;
                            }
                            else
                            {
                                Vector3 vector;
                                Vector3 vector2;
                                MyOrientedBoundingBox.GetNormalBetweenEdges(num13, num16, num19, out vector2);
                                vectord29 = (zero + vectord14) * 0.5;
                                vectord30 = Vector3D.TransformNormal(vector2, drawMatrix);
                                MyOrientedBoundingBox.GetNormalBetweenEdges(num13, num19, num16, out vector);
                                vectord31 = (vectord19 + vectord20) * 0.5;
                                vectord32 = Vector3D.TransformNormal(vector, drawMatrix);
                                flag7     = false;
                                if ((num16 == 0) && (num19 == 3))
                                {
                                    num28 = num16 + 1;
                                    goto TR_0029;
                                }
                                if ((num16 >= num19) && ((num16 != 3) || (num19 != 0)))
                                {
                                    num28 = num16 + 1;
                                    goto TR_0029;
                                }
                            }
                        }
                        else
                        {
                            Vector3D vectord28 = (((vectord17 + vectord18) + vectord23) + vectord24) * 0.25;
                            MyTransparentGeometry.AddBillboardOriented(ID_ARROW_LEFT_GREEN, Vector4.One, (vectord28 - ((this.RotationForwardDirection * vectord27) * 0.20000000298023224)) - ((this.RotationRightDirection * vectord25) * 0.0099999997764825821), (Vector3)(-this.RotationUpDirection * vectord26), (Vector3)(-this.RotationForwardDirection * vectord27), 0.2f, num6, MyBillboard.BlendTypeEnum.LDR);
                            MyTransparentGeometry.AddBillboardOriented(ID_ARROW_RIGHT_GREEN, Vector4.One, (vectord28 + ((this.RotationForwardDirection * vectord27) * 0.20000000298023224)) - ((this.RotationRightDirection * vectord25) * 0.0099999997764825821), (Vector3)(this.RotationUpDirection * vectord26), (Vector3)(this.RotationForwardDirection * vectord27), 0.2f, num6, MyBillboard.BlendTypeEnum.LDR);
                            MyRenderProxy.DebugDrawText3D((vectord28 - ((this.RotationForwardDirection * vectord27) * 0.20000000298023224)) - ((this.RotationRightDirection * vectord25) * 0.0099999997764825821), str2, Color.White, num22, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, num6, false);
                            MyRenderProxy.DebugDrawText3D((vectord28 + ((this.RotationForwardDirection * vectord27) * 0.20000000298023224)) - ((this.RotationRightDirection * vectord25) * 0.0099999997764825821), controlButtonName, Color.White, num22, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, num6, false);
                            goto TR_0025;
                        }
                        goto TR_002B;
                    }
                    goto TR_0029;
                }
                else
                {
                    return;
                }
                goto TR_002B;
            }
            goto TR_0029;
TR_0013:
            if (!hideForwardAndUpArrows || (this.RotationForwardAxis == 1))
            {
                if (flag6)
                {
                    Vector3D vectord41 = (((zero + vectord14) + vectord19) + vectord20) * 0.25;
                    MyTransparentGeometry.AddBillboardOriented(ID_ARROW_LEFT_BLUE, Vector4.One, (vectord41 + ((this.RotationUpDirection * vectord26) * 0.20000000298023224)) - ((this.RotationForwardDirection * vectord27) * 0.0099999997764825821), (Vector3)(-this.RotationRightDirection * vectord25), (Vector3)(this.RotationUpDirection * vectord26), 0.2f, num6, MyBillboard.BlendTypeEnum.LDR);
                    MyTransparentGeometry.AddBillboardOriented(ID_ARROW_RIGHT_BLUE, Vector4.One, (vectord41 - ((this.RotationUpDirection * vectord26) * 0.20000000298023224)) - ((this.RotationForwardDirection * vectord27) * 0.0099999997764825821), (Vector3)(this.RotationRightDirection * vectord25), (Vector3)(-this.RotationUpDirection * vectord26), 0.2f, num6, MyBillboard.BlendTypeEnum.LDR);
                    MyRenderProxy.DebugDrawText3D((vectord41 + ((this.RotationUpDirection * vectord26) * 0.20000000298023224)) - ((this.RotationForwardDirection * vectord27) * 0.0099999997764825821), str5, Color.White, num22, false, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, num6, false);
                    MyRenderProxy.DebugDrawText3D((vectord41 - ((this.RotationUpDirection * vectord26) * 0.20000000298023224)) - ((this.RotationForwardDirection * vectord27) * 0.0099999997764825821), str6, Color.White, num22, false, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER, num6, false);
                    return;
                }
                if (!flag3)
                {
                    Vector3 vector22;
                    Vector3 vector23;
                    MyOrientedBoundingBox.GetNormalBetweenEdges(num15, num18, num18 + 1, out vector23);
                    MyOrientedBoundingBox.GetNormalBetweenEdges(num15, num18, num18 - 1, out vector22);
                    Vector3D vectord44 = (vectord17 + vectord18) * 0.5;
                    Vector3  upVector  = Vector3.TransformNormal(vector23, drawMatrix);
                    Vector3  vector25  = Vector3.TransformNormal(vector22, drawMatrix);
                    MyTransparentGeometry.AddBillboardOriented(ID_ARROW_BLUE, Vector4.One, (vectord44 + (upVector * 0.3f)) - (vector25 * 0.01f), (Vector3)vectord27, upVector, 0.5f, num6, MyBillboard.BlendTypeEnum.LDR);
                    MyTransparentGeometry.AddBillboardOriented(ID_ARROW_BLUE, Vector4.One, (vectord44 + (vector25 * 0.3f)) - (upVector * 0.01f), (Vector3)vectord27, vector25, 0.5f, num6, MyBillboard.BlendTypeEnum.LDR);
                    MyRenderProxy.DebugDrawText3D((vectord44 + (upVector * 0.3f)) - (vector25 * 0.01f), (this.RotationForwardDirection < 0) ? str5 : str6, Color.White, num22, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, num6, false);
                    MyRenderProxy.DebugDrawText3D((vectord44 + (vector25 * 0.3f)) - (upVector * 0.01f), (this.RotationForwardDirection < 0) ? str6 : str5, Color.White, num22, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, num6, false);
                }
                else
                {
                    Vector3 vector16;
                    Vector3 vector17;
                    int     num30;
                    Vector3 vector20;
                    MyOrientedBoundingBox.GetNormalBetweenEdges(num15, num18, num21, out vector17);
                    Vector3D vectord42 = (vectord17 + vectord18) * 0.5;
                    Vector3  upVector  = Vector3.TransformNormal(vector17, drawMatrix);
                    MyOrientedBoundingBox.GetNormalBetweenEdges(num15, num21, num18, out vector16);
                    Vector3D vectord43 = (vectord23 + vectord24) * 0.5;
                    Vector3  vector19  = Vector3.TransformNormal(vector16, drawMatrix);
                    bool     flag9     = false;
                    if ((num18 == 0) && (num21 == 3))
                    {
                        num30 = num18 + 1;
                    }
                    else if ((num18 >= num21) && ((num18 != 3) || (num21 != 0)))
                    {
                        num30 = num18 + 1;
                    }
                    else
                    {
                        num30 = num18 - 1;
                        flag9 = true;
                    }
                    if (this.RotationForwardDirection < 0)
                    {
                        flag9 = !flag9;
                    }
                    MyOrientedBoundingBox.GetNormalBetweenEdges(num15, num18, num30, out vector20);
                    Vector3 vector21 = Vector3.TransformNormal(vector20, drawMatrix);
                    MyTransparentGeometry.AddBillboardOriented(ID_ARROW_BLUE, Vector4.One, (vectord42 + (upVector * 0.4f)) - (vector21 * 0.01f), (Vector3)vectord27, vector19, 0.5f, num6, MyBillboard.BlendTypeEnum.LDR);
                    MyTransparentGeometry.AddBillboardOriented(ID_ARROW_BLUE, Vector4.One, (vectord43 + (vector19 * 0.4f)) - (vector21 * 0.01f), (Vector3)vectord27, upVector, 0.5f, num6, MyBillboard.BlendTypeEnum.LDR);
                    MyRenderProxy.DebugDrawText3D((vectord42 + (upVector * 0.3f)) - (vector21 * 0.01f), flag9 ? str5 : str6, Color.White, num22, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, num6, false);
                    MyRenderProxy.DebugDrawText3D((vectord43 + (vector19 * 0.3f)) - (vector21 * 0.01f), flag9 ? str6 : str5, Color.White, num22, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, num6, false);
                    return;
                }
            }
            return;

TR_0017:
            if (this.RotationUpDirection < 0)
            {
                flag8 = !flag8;
            }
            MyOrientedBoundingBox.GetNormalBetweenEdges(num14, num17, num29, out vector10);
            Vector3 vector11 = Vector3.TransformNormal(vector10, drawMatrix);

            MyTransparentGeometry.AddBillboardOriented(ID_ARROW_RED, Vector4.One, (vectord38 + (vector8 * 0.4f)) - (vector11 * 0.01f), (Vector3)vectord26, vector9, 0.5f, num6, MyBillboard.BlendTypeEnum.LDR);
            MyTransparentGeometry.AddBillboardOriented(ID_ARROW_RED, Vector4.One, (vectord39 + (vector9 * 0.4f)) - (vector11 * 0.01f), (Vector3)vectord26, vector8, 0.5f, num6, MyBillboard.BlendTypeEnum.LDR);
            MyRenderProxy.DebugDrawText3D((vectord38 + (vector8 * 0.3f)) - (vector11 * 0.01f), flag8 ? str4 : str3, Color.White, num22, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, num6, false);
            MyRenderProxy.DebugDrawText3D((vectord39 + (vector9 * 0.3f)) - (vector11 * 0.01f), flag8 ? str3 : str4, Color.White, num22, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, num6, false);
            goto TR_0013;
TR_0025:
            if (hideForwardAndUpArrows && (this.RotationUpAxis != 1))
            {
                goto TR_0013;
            }
            if (!flag5)
            {
                if (!flag2)
                {
                    Vector3 vector12;
                    Vector3 vector13;
                    MyOrientedBoundingBox.GetNormalBetweenEdges(num14, num17, num17 + 1, out vector13);
                    MyOrientedBoundingBox.GetNormalBetweenEdges(num14, num17, num17 - 1, out vector12);
                    Vector3D vectord40 = (vectord15 + vectord16) * 0.5;
                    Vector3  upVector  = Vector3.TransformNormal(vector13, drawMatrix);
                    Vector3  vector15  = Vector3.TransformNormal(vector12, drawMatrix);
                    MyTransparentGeometry.AddBillboardOriented(ID_ARROW_RED, Vector4.One, (vectord40 + (upVector * 0.3f)) - (vector15 * 0.01f), (Vector3)vectord26, upVector, 0.5f, num6, MyBillboard.BlendTypeEnum.LDR);
                    MyTransparentGeometry.AddBillboardOriented(ID_ARROW_RED, Vector4.One, (vectord40 + (vector15 * 0.3f)) - (upVector * 0.01f), (Vector3)vectord26, vector15, 0.5f, num6, MyBillboard.BlendTypeEnum.LDR);
                    MyRenderProxy.DebugDrawText3D((vectord40 + (upVector * 0.6f)) - (vector15 * 0.01f), (this.RotationUpDirection > 0) ? str3 : str4, Color.White, num22, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, num6, false);
                    MyRenderProxy.DebugDrawText3D((vectord40 + (vector15 * 0.6f)) - (upVector * 0.01f), (this.RotationUpDirection > 0) ? str4 : str3, Color.White, num22, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, num6, false);
                    goto TR_0013;
                }
                else
                {
                    Vector3 vector6;
                    Vector3 vector7;
                    MyOrientedBoundingBox.GetNormalBetweenEdges(num14, num17, num20, out vector7);
                    vectord38 = (vectord15 + vectord16) * 0.5;
                    vector8   = Vector3.TransformNormal(vector7, drawMatrix);
                    MyOrientedBoundingBox.GetNormalBetweenEdges(num14, num20, num17, out vector6);
                    vectord39 = (vectord21 + vectord22) * 0.5;
                    vector9   = Vector3.TransformNormal(vector6, drawMatrix);
                    flag8     = false;
                    if ((num17 == 0) && (num20 == 3))
                    {
                        num29 = num17 + 1;
                        goto TR_0017;
                    }
                    if ((num17 >= num20) && ((num17 != 3) || (num20 != 0)))
                    {
                        num29 = num17 + 1;
                        goto TR_0017;
                    }
                }
            }
            else
            {
                Vector3D vectord37 = (((vectord17 + vectord18) + vectord23) + vectord24) * 0.25;
                MyTransparentGeometry.AddBillboardOriented(ID_ARROW_LEFT_RED, Vector4.One, (vectord37 - ((this.RotationRightDirection * vectord25) * 0.20000000298023224)) - ((this.RotationUpDirection * vectord26) * 0.0099999997764825821), (Vector3)(-this.RotationForwardDirection * vectord27), (Vector3)(-this.RotationRightDirection * vectord25), 0.2f, num6, MyBillboard.BlendTypeEnum.LDR);
                MyTransparentGeometry.AddBillboardOriented(ID_ARROW_RIGHT_RED, Vector4.One, (vectord37 + ((this.RotationRightDirection * vectord25) * 0.20000000298023224)) - ((this.RotationUpDirection * vectord26) * 0.0099999997764825821), (Vector3)(this.RotationForwardDirection * vectord27), (Vector3)(this.RotationRightDirection * vectord25), 0.2f, num6, MyBillboard.BlendTypeEnum.LDR);
                MyRenderProxy.DebugDrawText3D((vectord37 - ((this.RotationRightDirection * vectord25) * 0.20000000298023224)) - ((this.RotationUpDirection * vectord26) * 0.0099999997764825821), str3, Color.White, num22, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, num6, false);
                MyRenderProxy.DebugDrawText3D((vectord37 + ((this.RotationRightDirection * vectord25) * 0.20000000298023224)) - ((this.RotationUpDirection * vectord26) * 0.0099999997764825821), str4, Color.White, num22, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, num6, false);
                goto TR_0013;
            }
            num29 = num17 - 1;
            flag8 = true;
            goto TR_0017;
TR_0029:
            if (this.RotationRightDirection < 0)
            {
                flag7 = !flag7;
            }
            MyOrientedBoundingBox.GetNormalBetweenEdges(num13, num16, num28, out vector3);
            Vector3D vectord33 = Vector3D.TransformNormal(vector3, drawMatrix);

            MyTransparentGeometry.AddBillboardOriented(ID_ARROW_GREEN, Vector4.One, (vectord29 + (vectord30 * 0.40000000596046448)) - (vectord33 * 0.0099999997764825821), (Vector3)vectord25, (Vector3)vectord32, 0.5f, num6, MyBillboard.BlendTypeEnum.LDR);
            MyTransparentGeometry.AddBillboardOriented(ID_ARROW_GREEN, Vector4.One, (vectord31 + (vectord32 * 0.40000000596046448)) - (vectord33 * 0.0099999997764825821), (Vector3)vectord25, (Vector3)vectord30, 0.5f, num6, MyBillboard.BlendTypeEnum.LDR);
            MyRenderProxy.DebugDrawText3D((vectord29 + (vectord30 * 0.30000001192092896)) - (vectord33 * 0.0099999997764825821), flag7 ? controlButtonName : str2, Color.White, num22, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, num6, false);
            MyRenderProxy.DebugDrawText3D((vectord31 + (vectord32 * 0.30000001192092896)) - (vectord33 * 0.0099999997764825821), flag7 ? str2 : controlButtonName, Color.White, num22, false, MyGuiDrawAlignEnum.HORISONTAL_CENTER_AND_VERTICAL_CENTER, num6, false);
            goto TR_0025;
TR_002B:
            num28 = num16 - 1;
            flag7 = true;
            goto TR_0029;
        }