protected override void DrawSelf(SpriteBatch spriteBatch) { Rectangle rectangle = GetDimensions().ToRectangle(); if (IsMouseHovering) { OnMouseHover?.Invoke(); } if (ContainsPoint(Main.MouseScreen) && !PlayerInput.IgnoreMouseInterface) { Main.LocalPlayer.mouseInterface = true; if (validItem == null || validItem(Main.mouseItem)) { bool?pre = PreItemChange?.Invoke(item); if (pre == null || pre == true) { ItemSlot.Handle(ref item, context); //Handle handles all the click and hover actions based on the context. } PostItemChange?.Invoke(item); } } //Draw draws the slot itself and Item bool?preDraw = PreDrawItemSlot?.Invoke(item); if (preDraw == null || preDraw == true) { Draw(item, rectangle.TopLeft(), backgroundTexture, scale); } PostDrawItemSlot?.Invoke(item); }
public void ChangeItem(Item newItem) { if (newItem == null) { throw new ArgumentNullException(); } bool?pre = PreItemChange?.Invoke(newItem); if (pre == null || pre == true) { item = newItem; } PostItemChange?.Invoke(item); }
public void ChangeItem(int type) { if (type <= 0) { throw new ArgumentException(); } bool?pre = PreItemChange?.Invoke(item); if (pre == null || pre == true) { item.type = type; } PostItemChange?.Invoke(item); }