public void Update(GameTime time) { if (_currentState == null) { return; } GetMousePosition(); bool flag = Main.mouseLeft && Main.hasFocus; UIElement uIElement = Main.hasFocus ? _currentState.GetElementAt(MousePosition) : null; _clickDisabledTimeRemaining = Math.Max(0.0, _clickDisabledTimeRemaining - time.ElapsedGameTime.TotalMilliseconds); bool flag2 = _clickDisabledTimeRemaining > 0.0; if (uIElement != _lastElementHover) { if (_lastElementHover != null) { _lastElementHover.MouseOut(new UIMouseEvent(_lastElementHover, MousePosition)); } uIElement?.MouseOver(new UIMouseEvent(uIElement, MousePosition)); _lastElementHover = uIElement; } if (flag && !_wasMouseDown && uIElement != null && !flag2) { _lastElementDown = uIElement; uIElement.MouseDown(new UIMouseEvent(uIElement, MousePosition)); if (_lastElementClicked == uIElement && time.TotalGameTime.TotalMilliseconds - _lastMouseDownTime < 500.0) { uIElement.DoubleClick(new UIMouseEvent(uIElement, MousePosition)); _lastElementClicked = null; } _lastMouseDownTime = time.TotalGameTime.TotalMilliseconds; } else if (!flag && _wasMouseDown && _lastElementDown != null && !flag2) { UIElement lastElementDown = _lastElementDown; if (lastElementDown.ContainsPoint(MousePosition)) { lastElementDown.Click(new UIMouseEvent(lastElementDown, MousePosition)); _lastElementClicked = _lastElementDown; } lastElementDown.MouseUp(new UIMouseEvent(lastElementDown, MousePosition)); _lastElementDown = null; } if (PlayerInput.ScrollWheelDeltaForUI != 0) { uIElement?.ScrollWheel(new UIScrollWheelEvent(uIElement, MousePosition, PlayerInput.ScrollWheelDeltaForUI)); PlayerInput.ScrollWheelDeltaForUI = 0; } _wasMouseDown = flag; if (_currentState != null) { _currentState.Update(time); } }