private int GetCellRowMouseIsOverUnsafe() { var rawRowNumber = Convert.ToInt32((GuiSpaceMousePosition.GetMouseY() - this.GetStartingY() - this.GetCellWidth() / 2.0) / this.GetCellWidth()); // Clamp down to avoid indexing issues from hitting around the last pixel return(Math.Min(rawRowNumber, this.inventoryBehavior.GetInventoryHeight() - 1)); }
public bool IsMouseOverInventory() { if (!this.isInventoryOpen) { this.mouseOverGuiElementHandler.SetMouseExitGuiElement(); return(false); } var mouseX = GuiSpaceMousePosition.GetMouseX(); var mouseY = GuiSpaceMousePosition.GetMouseY(); var mouseWithinXBounds = mouseX >= this.GetStartingX() && mouseX < this.GetEndX(); var mouseWithinYBounds = mouseY >= this.GetStartingY() && mouseY < this.GetEndY(); if (mouseWithinXBounds && mouseWithinYBounds) { this.mouseOverGuiElementHandler.SetMouseIsOverGuiElement(); return(true); } else { this.mouseOverGuiElementHandler.SetMouseExitGuiElement(); return(false); } }