private int GetCellColumnMouseIsOverUnsafe() { var rawColumnNumber = Convert.ToInt32((GuiSpaceMousePosition.GetMouseX() - this.GetStartingX() - this.GetCellWidth() / 2.0) / this.GetCellWidth()); // Clamp down to avoid indexing issues from hitting around the last pixel return(Math.Min(rawColumnNumber, this.inventoryBehavior.GetInventoryWidth() - 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); } }