コード例 #1
0
        private void HandleMouseInput()
        {
            if (this.EnablePanning)
            {
                if (UnityInput.GetMouseButtonDown(this.MouseButtonIndexForPan))
                {
                    mPanningPosition = UnityInput.mousePosition;
                }
                else if (UnityInput.GetMouseButton(this.MouseButtonIndexForPan))
                {
                    // Only trigger this once if we actually moved.
                    // TODO: Determine if we need to add a 'deadzone' for panning difference detection
                    if (!mIsPanning && UnityInput.mousePosition != mPanningPosition)
                    {
                        mIsPanning = true;
                        this.OnBeginPanAction?.Invoke(mPanningPosition);
                    }

                    PanCameraTo(UnityInput.mousePosition);
                }
                else if (UnityInput.GetMouseButtonUp(this.MouseButtonIndexForPan))
                {
                    mIsPanning = false;
                    if (this.OnFinishedPanAction != null)
                    {
                        this.OnFinishedPanAction(mPanningPosition);
                    }
                }
            }
        }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        var mouseDelta = Input.mouseScrollDelta;

        if (mouseDelta != Vector2.zero)
        {
            Zoom(mouseDelta.y);
        }

        var mousePos = _mainCamera.ScreenToWorldPoint(Input.mousePosition);

        if (Input.GetMouseButtonDown(2) || Input.GetMouseButtonDown(1) || Input.GetMouseButtonUp(2) || Input.GetMouseButtonUp(1))
        {
            _currentMouseOff = mousePos;
        }

        if (Input.GetMouseButton(2) || Input.GetMouseButton(1))
        {
            var offset = _currentMouseOff - mousePos;

            MoveCamera(offset);
        }

        _mainCamera.orthographicSize = Mathf.SmoothDamp(_mainCamera.orthographicSize, currentZoomLevel, ref _velocity, smoothTime);
    }
コード例 #3
0
        protected override void OnUpdate()
        {
            base.OnUpdate();

            // keyboard
            for (int i = 0; i < m_KeyEventList.Length; ++i)
            {
                var key = m_KeyEventList[i];
                if (key.Down)
                {
                    m_inputState.KeyDown(key.KeyCode);
                }
                else
                {
                    m_inputState.KeyUp(key.KeyCode);
                }
            }

            m_KeyEventList.Clear();

            // mouse
            m_inputState.hasMouse = UnityInput.mousePresent;
            var mouse = UnityInput.mousePosition;

            if (!m_MouseInitDelta)
            {
                m_inputState.mouseDeltaX = (int)mouse.x - m_inputState.mouseX;
                m_inputState.mouseDeltaY = (int)mouse.y - m_inputState.mouseY;
            }
            else
            {
                m_inputState.mouseDeltaX = 0;
                m_inputState.mouseDeltaY = 0;
                m_MouseInitDelta         = false;
            }

            m_inputState.mouseX = (int)mouse.x;
            m_inputState.mouseY = (int)mouse.y;
            for (int i = 0; i < 3; ++i)
            {
                if (UnityInput.GetMouseButtonUp(i))
                {
                    m_inputState.MouseUp(i);
                }
                if (UnityInput.GetMouseButtonDown(i))
                {
                    m_inputState.MouseDown(i);
                }
            }

            m_inputState.scrollDeltaX = (int)UnityInput.mouseScrollDelta.x;
            m_inputState.scrollDeltaY = (int)UnityInput.mouseScrollDelta.y;
            Debug.Log(m_inputState.scrollDeltaX + " " + m_inputState.scrollDeltaY);
        }
コード例 #4
0
        private void HandleLandscapingInput()
        {
            if (TerrainPaintingEnabled)
            {
                if (Input.GetKeyDown(KeyCode.Equals))
                {
                    CycleTerrainTypeIndex();
                }
                else if (Input.GetKeyDown(KeyCode.Minus))
                {
                    CycleTerrainTypeIndex(false);
                }
            }

            if (_isDragSelecting)
            {
                return;
            }



            if (TerrainModificationEnabled || TerrainPaintingEnabled)
            {
                if (Input.GetMouseButtonUp(0))
                {
                    var actionParams = GetLandscapingActionParameters();
                    if (TerrainModificationEnabled)
                    {
                        new RaiseTerrain(actionParams).ExecuteAction();
                    }
                    else if (TerrainPaintingEnabled)
                    {
                        new PaintTerrain(actionParams).ExecuteAction();
                    }
                }
                else if (Input.GetMouseButtonUp(1))
                {
                    var actionParams = GetLandscapingActionParameters();
                    if (TerrainModificationEnabled)
                    {
                        new LowerTerrain(actionParams).ExecuteAction();
                    }
                    else if (TerrainPaintingEnabled)
                    {
                        new PaintTerrain(actionParams).ExecuteAction();
                    }
                }
                else if (TerrainPaintingEnabled && Input.GetMouseButtonDown(2))
                {
                    var actionParams = GetLandscapingActionParameters();
                    new PaintTerrain(actionParams).ExecuteAction();
                }
            }
        }
コード例 #5
0
ファイル: Mouse.cs プロジェクト: gendalf90/WhenGunsSpeak
        private void UpdateFire()
        {
            if (UnityInput.GetMouseButtonDown(0))
            {
                observable.Publish(new StartFireEvent());
            }

            if (UnityInput.GetMouseButtonUp(0))
            {
                observable.Publish(new EndFireEvent());
            }
        }
コード例 #6
0
        protected override bool PollReleased(MouseButton inputBind)

        {
            bool bRet = UInput.GetMouseButtonUp((int)inputBind);



            if (bRet)

            {
                RetroEvents.Chapter("Input_" + BoundInputID.ToString()).Set(new KeyInputEvent(false, Time.deltaTime, false, BoundInputID));
            }



            return(bRet);
        }
コード例 #7
0
 public void Execute()
 {
     _entities
     .SlinqWithIndex()
     .ForEach(value =>
     {
         value.Match()
         .Where(v => UniInput.GetMouseButtonDown(v.Item2))
         .Do(v => value.Item1.ReplaceButtonDown(Camera.main.ScreenToWorldPoint(UniInput.mousePosition)))
         .Where(v => UniInput.GetMouseButton(v.Item2))
         .Do(v => value.Item1.ReplaceButtonPressed(Camera.main.ScreenToWorldPoint(UniInput.mousePosition)))
         .Where(v => UniInput.GetMouseButtonUp(v.Item2))
         .Do(v => value.Item1.ReplaceButtonUp(Camera.main.ScreenToWorldPoint(UniInput.mousePosition)))
         .IgnoreElse()
         .Exec();
     });
 }
コード例 #8
0
ファイル: InputHybrid.cs プロジェクト: isaveu/SimpleUIDemo
        protected override void OnUpdate()
        {
            base.OnUpdate();

            // keyboard
            for (int i = 0; i < m_KeyEventList.Length; ++i)
            {
                var key = m_KeyEventList[i];
                if (key.Down)
                {
                    m_inputState.KeyDown(key.KeyCode);
                }
                else
                {
                    m_inputState.KeyUp(key.KeyCode);
                }
            }

            m_KeyEventList.Clear();

            // mouse
            m_inputState.hasMouse = UnityInput.mousePresent;
            var mouse = UnityInput.mousePosition;

            m_inputState.mouseX = (int)mouse.x;
            m_inputState.mouseY = (int)mouse.y;
            for (int i = 0; i < 3; ++i)
            {
                if (UnityInput.GetMouseButtonUp(i))
                {
                    m_inputState.MouseUp(i);
                }
                if (UnityInput.GetMouseButtonDown(i))
                {
                    m_inputState.MouseDown(i);
                }
            }
        }
コード例 #9
0
ファイル: InputSystem.cs プロジェクト: yabos/SaveTheQueen
        private void MouseUpdate()
        {
            if (EditMouseUpdate == false)
            {
                return;
            }

            float scroll = UInput.GetAxis("Mouse ScrollWheel");

            if (scroll != 0.0f)
            {
                Vector2 mousePos   = UInput.mousePosition;
                Rect    gameScreen = new Rect(0.0f, 0.0f, Screen.width, Screen.height);
                if (gameScreen.Contains(mousePos))
                {
                    MouseEvent mouseEvent = m_mouseTranslator.MouseWheel(mousePos, -scroll);
                    if (CallBackMouseEvent != null && mouseEvent != MouseEvent.None)
                    {
                        CallBackMouseEvent(mouseEvent);
                    }
                }
            }

            bool updateRaycast = false;

            for (int i = 0; i < 3; ++i)
            {
                if (UInput.GetMouseButton(i) || UInput.GetMouseButtonUp(i) || m_mouseDown)
                {
                    updateRaycast = true;
                    break;
                }
            }

            Vector3 mouseposition;

            if (updateRaycast)
            {
                mouseposition = UInput.mousePosition;
            }
            else
            {
                return;
            }

            MouseEvent.E_Buttons eventbutton = MouseEvent.E_Buttons.Left;
            for (int i = 0; i < 3; ++i)
            {
                bool pressed   = UInput.GetMouseButtonDown(i);
                bool unpressed = UInput.GetMouseButtonUp(i);
                //bool pressing = Input.GetMouseButton(i);

                //E_MOUSE_EVENT dowingEvent = E_MOUSE_EVENT.LDOWNING;


                if (i == 0)
                {
                    eventbutton = MouseEvent.E_Buttons.Left;
                    //dowingEvent = E_MOUSE_EVENT.LDOWNING;
                }
                else if (i == 1)
                {
                    eventbutton = MouseEvent.E_Buttons.Right;
                    //dowingEvent = E_MOUSE_EVENT.RDOWNING;
                }
                else if (i == 2)
                {
                    eventbutton = MouseEvent.E_Buttons.Middle;
                    //dowingEvent = E_MOUSE_EVENT.MDOWNING;
                }


                if (pressed)
                {
                    PushTouchesEventMsg(mouseposition, true, eventbutton);
                    m_mouseDown = true;
                }

                if (unpressed)
                {
                    PushTouchesEventMsg(mouseposition, false, eventbutton);
                    m_mouseDown = false;
                }
            }


            bool Moved = UInput.GetAxis("Mouse X") != 0.0f || UInput.GetAxis("Mouse Y") != 0.0f;

            if (Moved)
            {
                PushTouchesEventMsg(mouseposition, false, eventbutton, true);
            }
        }
コード例 #10
0
        private void Update()
        {
#if UNITY_EDITOR
            if (UInput.GetMouseButtonDown(0))
            {
                _lastMousePosition = UInput.mousePosition;
                TouchInputEvent tie = new TouchInputEvent()
                {
                    touchPos   = _lastMousePosition,
                    touchDelta = Vector3.zero
                };
                OnTouchStart?.Invoke(tie);
            }
            else if (UInput.GetMouseButton(0))
            {
                TouchInputEvent tie = new TouchInputEvent()
                {
                    touchPos = UInput.mousePosition
                };
                tie.touchDelta     = tie.touchPos - _lastMousePosition;
                _lastMousePosition = tie.touchPos;
                OnTouchStay?.Invoke(tie);
            }
            else if (UInput.GetMouseButtonUp(0))
            {
                TouchInputEvent tie = new TouchInputEvent()
                {
                    touchPos   = UInput.mousePosition,
                    touchDelta = Vector3.zero
                };
                OnTouchRelease?.Invoke(tie);
            }
#elif UNITY_ANDROID
            if (UInput.touchCount > 0)
            {
                // Only polling touch 0
                Touch           touch = UInput.GetTouch(0);
                TouchInputEvent tie   = new TouchInputEvent()
                {
                    touchPos   = touch.position,
                    touchDelta = touch.deltaPosition
                };

                // Send the respective event depending on touch phase state
                switch (touch.phase)
                {
                case TouchPhase.Began:
                    OnTouchStart?.Invoke(tie);
                    break;

                case TouchPhase.Moved:
                case TouchPhase.Stationary:
                    OnTouchStay?.Invoke(tie);
                    break;

                case TouchPhase.Canceled:
                case TouchPhase.Ended:
                    OnTouchRelease?.Invoke(tie);
                    break;
                }
            }
#endif
        }
コード例 #11
0
        void Update()
        {
            LastFrame = CurrentFrame;

            CurrentFrame.MouseLeftHeld = I.GetMouseButton(0);
            CurrentFrame.MouseLeftDown = I.GetMouseButtonDown(0);
            CurrentFrame.MouseLeftUp   = I.GetMouseButtonUp(0);

            CurrentFrame.MouseRightHeld = I.GetMouseButton(1);
            CurrentFrame.MouseRightDown = I.GetMouseButtonDown(1);
            CurrentFrame.MouseRightUp   = I.GetMouseButtonUp(1);

            CurrentFrame.MouseMiddleHeld = I.GetMouseButton(2);
            CurrentFrame.MouseMiddleDown = I.GetMouseButtonDown(2);
            CurrentFrame.MouseMiddleUp   = I.GetMouseButtonUp(2);

            CurrentFrame.MouseScreenPosition = UnityEngine.Input.mousePosition;
            CurrentFrame.MouseScreenDelta    = CurrentFrame.MouseScreenPosition - LastFrame.MouseScreenPosition;

            CurrentFrame.MouseLeftDragging    = CurrentFrame.MouseLeftHeld;
            CurrentFrame.MouseLeftDragStarted = CurrentFrame.MouseLeftDragging && !LastFrame.MouseLeftDragging;
            CurrentFrame.MouseLeftDragStopped = !CurrentFrame.MouseLeftDragging && LastFrame.MouseLeftDragging;

            CurrentFrame.MouseRightDragging    = CurrentFrame.MouseRightHeld;
            CurrentFrame.MouseRightDragStarted = CurrentFrame.MouseRightDragging && !LastFrame.MouseRightDragging;
            CurrentFrame.MouseRightDragStopped = !CurrentFrame.MouseRightDragging && LastFrame.MouseRightDragging;

            var mainCamera = CameraController.Instance;
            var ray        = mainCamera.MainCamera.ScreenPointToRay(CurrentFrame.MouseScreenPosition);

            CurrentFrame.MouseScreenPositionLeftDown   = CurrentFrame.MouseLeftDown ? CurrentFrame.MouseScreenPosition : LastFrame.MouseScreenPositionLeftDown;
            CurrentFrame.MouseScreenPositionRightDown  = CurrentFrame.MouseRightDown ? CurrentFrame.MouseScreenPosition : LastFrame.MouseScreenPositionRightDown;
            CurrentFrame.MouseScreenPositionMiddleDown = CurrentFrame.MouseMiddleDown ? CurrentFrame.MouseScreenPosition : LastFrame.MouseScreenPositionMiddleDown;

            if (Physics.RaycastNonAlloc(ray, m_Results) > 0)
            {
                CurrentFrame.MouseLocalPosition = m_Results[0].point / mainCamera.Data.Units;
                CurrentFrame.MouseLocalDelta    = CurrentFrame.MouseLeftDragStarted ? float3.zero : CurrentFrame.MouseLocalPosition - LastFrame.MouseLocalPosition;

                CurrentFrame.MouseWorldPosition = mainCamera.Data.LookAtPosition + CurrentFrame.MouseLocalPosition;
                CurrentFrame.MouseWorldDelta    = CurrentFrame.MouseLeftDragStarted ? double3.zero : CurrentFrame.MouseWorldPosition - LastFrame.MouseWorldPosition;
            }
            else
            {
                CurrentFrame.MouseLocalPosition = LastFrame.MouseLocalPosition;
                CurrentFrame.MouseLocalDelta    = LastFrame.MouseLocalDelta;
                CurrentFrame.MouseWorldPosition = LastFrame.MouseWorldPosition;
                CurrentFrame.MouseWorldDelta    = LastFrame.MouseWorldDelta;
            }

            var topLeft = mainCamera.MainCamera.ScreenPointToRay(new Vector3(Screen.width, Screen.height, 0f));

            if (Physics.RaycastNonAlloc(topLeft, m_Results) > 0)
            {
                CurrentFrame.TopLeftLocalPosition = m_Results[0].point / mainCamera.Data.Units;
                CurrentFrame.TopLeftWorldPosition = mainCamera.Data.LookAtPosition + CurrentFrame.TopLeftLocalPosition;
            }
            else
            {
                CurrentFrame.TopLeftLocalPosition = LastFrame.TopLeftLocalPosition;
                CurrentFrame.TopLeftWorldPosition = LastFrame.TopLeftWorldPosition;
            }

            CurrentFrame.PrimaryAxis   = new float2(I.GetAxis("Horizontal"), I.GetAxis("Vertical"));
            CurrentFrame.SecondaryAxis = new float2(I.GetAxis("Mouse ScrollWheel"), 0f);

            CurrentFrame.MouseLeftClicked = CurrentFrame.MouseLeftUp && LastFrame.MouseLeftHeld &&
                                            math.lengthsq(CurrentFrame.MouseScreenPosition - CurrentFrame.MouseScreenPositionLeftDown) < 2;

            CurrentFrame.MouseRightClicked = CurrentFrame.MouseRightUp && LastFrame.MouseRightHeld &&
                                             math.lengthsq(CurrentFrame.MouseScreenPosition - CurrentFrame.MouseScreenPositionRightDown) < 2;

            CurrentFrame.MouseMiddleClicked = CurrentFrame.MouseMiddleUp && LastFrame.MouseMiddleHeld &&
                                              math.lengthsq(CurrentFrame.MouseScreenPosition - CurrentFrame.MouseScreenPositionMiddleDown) < 2;

            CurrentFrame.PrimaryAction    = I.GetAxis("Fire1") > 0f;
            CurrentFrame.SecondaryAction  = I.GetAxis("Fire2") > 0f;
            CurrentFrame.TertiaryAction   = I.GetAxis("Fire3") > 0f;
            CurrentFrame.QuaternaryAction = I.GetAxis("Jump") > 0f;

            CurrentFrame.CycleForwardAction  = I.GetKeyUp(KeyCode.Equals);
            CurrentFrame.CycleBackwardAction = I.GetKeyUp(KeyCode.Minus);

            CurrentFrame.CancelAction = I.GetKeyUp(KeyCode.Escape);

            CurrentFrame.SubActions[0]  = I.GetKeyUp(KeyCode.F1);
            CurrentFrame.SubActions[1]  = I.GetKeyUp(KeyCode.F2);
            CurrentFrame.SubActions[2]  = I.GetKeyUp(KeyCode.F3);
            CurrentFrame.SubActions[3]  = I.GetKeyUp(KeyCode.F4);
            CurrentFrame.SubActions[4]  = I.GetKeyUp(KeyCode.F5);
            CurrentFrame.SubActions[5]  = I.GetKeyUp(KeyCode.F6);
            CurrentFrame.SubActions[6]  = I.GetKeyUp(KeyCode.F7);
            CurrentFrame.SubActions[7]  = I.GetKeyUp(KeyCode.F8);
            CurrentFrame.SubActions[8]  = I.GetKeyUp(KeyCode.F9);
            CurrentFrame.SubActions[9]  = I.GetKeyUp(KeyCode.F10);
            CurrentFrame.SubActions[10] = I.GetKeyUp(KeyCode.F11);
            CurrentFrame.SubActions[11] = I.GetKeyUp(KeyCode.F12);
        }
コード例 #12
0
 public static bool IsNewMouseButtonRelease(MouseButton mouseButton)
 {
     return(UnityInput.GetMouseButtonUp((int)mouseButton));
 }
コード例 #13
0
        private void Update()
        {
            if (difficultyCooldown > 0)
            {
                difficultyCooldown -= Time.deltaTime;
            }
            LevelUpDuration -= Time.deltaTime;

            if (_openedMenu == OpenedMenuMode.Stats)
            {
                BookScrollAmountGoal = Mathf.Clamp(BookScrollAmountGoal + 500 * screenScale * Input.GetAxis("Mouse ScrollWheel"), -Screen.height * 10 * screenScale, 0);
                if (Input.GetKeyDown(KeyCode.RightArrow))
                {
                    ChangePage(guidePage + 1);
                }
                if (Input.GetKeyDown(KeyCode.LeftArrow))
                {
                    ChangePage(guidePage - 1);
                }
                if (Input.GetKeyDown(KeyCode.DownArrow))
                {
                    BookScrollAmountGoal = Mathf.Clamp(BookScrollAmountGoal - 1000f * screenScale, -Screen.height * 10 * screenScale, 0);
                }
                if (Input.GetKeyDown(KeyCode.UpArrow))
                {
                    BookScrollAmountGoal = Mathf.Clamp(BookScrollAmountGoal + 1000f * screenScale, -Screen.height * 10 * screenScale, 0);
                }
                BookScrollAmount = Vector3.Slerp(new Vector3(BookScrollAmount, 0, 0), new Vector3(BookScrollAmountGoal, 0, 0), Time.deltaTime * 30f * screenScale).x;
            }
            else if (_openedMenu == OpenedMenuMode.Inventory)
            {
                if (Input.GetKeyDown(KeyCode.LeftAlt))
                {
                    drawTotal = !drawTotal;
                }
            }

            try
            {
                PingUpdate();
            }
            catch (Exception exc)
            {
                ModAPI.Console.Write("ERROR with ping update\n" + exc.ToString());
            }

            if (_openedMenu != OpenedMenuMode.Hud)
            {
                if (_openedMenu == OpenedMenuMode.Inventory)
                {
                    if (Input.GetMouseButtonUp(1))
                    {
                        if (consumedsomething)
                        {
                            consumedsomething = false;
                        }
                    }

                    if (SelectedItem != -1 && Inventory.Instance.ItemSlots[SelectedItem] != null)
                    {
                        var item = Inventory.Instance.ItemSlots[SelectedItem];
                        if (Input.GetMouseButtonDown(0))
                        {
                            if (Input.GetKey(KeyCode.LeftShift))
                            {
                                //unequip if equipped
                                if (SelectedItem < -1)
                                {
                                    for (int i = 0; i < Inventory.SlotCount; i++)
                                    {
                                        if (Inventory.Instance.ItemSlots[i] == null)
                                        {
                                            DraggedItem = null;
                                            isDragging  = false;
                                            CustomCrafting.ClearIndex(SelectedItem);
                                            CustomCrafting.ClearIndex(i);
                                            DraggedItemIndex = -1;
                                            Inventory.Instance.ItemSlots[i]            = item;
                                            Inventory.Instance.ItemSlots[SelectedItem] = null;
                                            SelectedItem = -1;
                                            break;
                                        }
                                    }
                                }
                                else                                //move to its correct slot or swap if slot is not empty
                                {
                                    int targetSlot = -1;

                                    switch (item.type)
                                    {
                                    case BaseItem.ItemType.Helmet:
                                        targetSlot = -2;
                                        break;

                                    case BaseItem.ItemType.ChestArmor:
                                        targetSlot = -3;
                                        break;

                                    case BaseItem.ItemType.Pants:
                                        targetSlot = -4;
                                        break;

                                    case BaseItem.ItemType.Boot:
                                        targetSlot = -5;
                                        break;

                                    case BaseItem.ItemType.ShoulderArmor:
                                        targetSlot = -6;
                                        break;

                                    case BaseItem.ItemType.Glove:
                                        targetSlot = -7;
                                        break;

                                    case BaseItem.ItemType.Amulet:
                                        targetSlot = -8;
                                        break;

                                    case BaseItem.ItemType.Bracer:
                                        targetSlot = -9;
                                        break;

                                    case BaseItem.ItemType.Ring:
                                        if (Inventory.Instance.ItemSlots[-10] == null)
                                        {
                                            targetSlot = -10;
                                        }
                                        else if (Inventory.Instance.ItemSlots[-11] == null)
                                        {
                                            targetSlot = -11;
                                        }
                                        else
                                        {
                                            targetSlot = -10;
                                        }
                                        break;

                                    case BaseItem.ItemType.Weapon:
                                        targetSlot = -12;
                                        break;

                                    case BaseItem.ItemType.Quiver:
                                    case BaseItem.ItemType.SpellScroll:
                                    case BaseItem.ItemType.Shield:
                                        targetSlot = -13;
                                        break;
                                    }
                                    if (targetSlot != -1)
                                    {
                                        if (Inventory.Instance.ItemSlots[targetSlot] == null)
                                        {
                                            DraggedItem      = null;
                                            isDragging       = false;
                                            DraggedItemIndex = -1;
                                            CustomCrafting.ClearIndex(SelectedItem);
                                            Inventory.Instance.ItemSlots[targetSlot]   = item;
                                            Inventory.Instance.ItemSlots[SelectedItem] = null;
                                            SelectedItem = -1;
                                        }
                                        else
                                        {
                                            DraggedItem      = null;
                                            isDragging       = false;
                                            DraggedItemIndex = -1;
                                            CustomCrafting.ClearIndex(SelectedItem);
                                            Inventory.Instance.ItemSlots[SelectedItem] = Inventory.Instance.ItemSlots[targetSlot];
                                            Inventory.Instance.ItemSlots[targetSlot]   = item;
                                            SelectedItem = -1;
                                        }
                                    }
                                }
                            }
                            else if (Input.GetKey(KeyCode.LeftControl))
                            {
                                if (SelectedItem > -1 && CustomCrafting.instance.craftMode != CustomCrafting.CraftMode.None)
                                {
                                    if (CustomCrafting.instance.changedItem.i == null)
                                    {
                                        CustomCrafting.instance.changedItem.Assign(SelectedItem, Inventory.Instance.ItemSlots[SelectedItem]);
                                    }
                                    else
                                    {
                                        int max = CustomCrafting.instance.CurrentCraftingMode.IngredientCount;
                                        for (int j = 0; j < max; j++)
                                        {
                                            if (CustomCrafting.Ingredients[j].i == null)
                                            {
                                                if (!(CustomCrafting.Ingredients.Any(x => x.i == item) || CustomCrafting.instance.changedItem.i == item))
                                                {
                                                    CustomCrafting.Ingredients[j].Assign(SelectedItem, item);
                                                    DraggedItem      = null;
                                                    DraggedItemIndex = -1;
                                                    isDragging       = false;
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else if (consumedsomething)
                {
                    consumedsomething = false;
                }
                //LocalPlayer.FpCharacter.LockView(false);
                LevelsToGain = 0;
                if (Input.GetKeyDown(KeyCode.Escape))
                {
                    StartCoroutine(FadeMenuSwitch(OpenedMenuMode.Hud));
                }
            }
            else
            {
                if (LevelsToGain > 0)
                {
                    if (ProgressBarAmount < 1)
                    {
                        ProgressBarAmount = Mathf.MoveTowards(ProgressBarAmount, 1, Time.unscaledDeltaTime * 2);
                    }
                    else
                    {
                        LevelsToGain--;
                        ProgressBarAmount = 0;
                    }
                }
                else
                {
                    if (ProgressBarAmount < (float)ModdedPlayer.instance.ExpCurrent / ModdedPlayer.instance.ExpGoal)
                    {
                        ProgressBarAmount = Mathf.MoveTowards(ProgressBarAmount, Convert.ToSingle((float)ModdedPlayer.instance.ExpCurrent / ModdedPlayer.instance.ExpGoal), Time.unscaledDeltaTime / 2);
                    }
                    else
                    {
                        ProgressBarAmount = Convert.ToSingle((float)ModdedPlayer.instance.ExpCurrent / ModdedPlayer.instance.ExpGoal);
                    }
                }
                ProgressBarAmount = Mathf.Clamp01(ProgressBarAmount);
            }
            isCrouching = LocalPlayer.FpCharacter.crouching;
            if (ModAPI.Input.GetButtonDown("MenuToggle"))
            {
                MenuKeyPressAction();
            }
        }