Even More Modifiers  1.0.0.0
A mod for rolling various bonus stats on items
GuiCraftItemButton.cs
Go to the documentation of this file.
1 using System;
2 using Loot.Api.Ext;
4 using Microsoft.Xna.Framework.Graphics;
5 using Terraria;
6 using Terraria.UI;
7 
8 namespace Loot.UI.Tabs.Cubing
9 {
10  internal class GuiCraftItemButton : GuiInteractableItemButton
11  {
12  public Action PostOnClickAction;
13  public Action PreOnClickAction;
14  public Func<Item, bool> CanTakeItemAction;
15 
16  internal GuiCraftItemButton(ButtonType buttonType, int netId = 0, int stack = 0, Texture2D hintTexture = null, string hintText = null, string hintOnHover = null) : base(buttonType, netId, stack, hintTexture, hintText, hintOnHover)
17  {
18  RightClickFunctionalityEnabled = false;
19  HintOnHover = " (click to take item)";
20  }
21 
22  public override bool CanTakeItem(Item givenItem) => base.CanTakeItem(givenItem) && givenItem.IsModifierRollableItem() && (CanTakeItemAction?.Invoke(givenItem) ?? true);
23 
24  public override void PreOnClick(UIMouseEvent evt, UIElement e)
25  {
26  if (!Item.IsAir)
27  {
28  LootModItem.GetInfo(Item).SlottedInUI = false;
29  }
30  PreOnClickAction?.Invoke();
31  }
32 
33  public override void PostOnClick(UIMouseEvent evt, UIElement e)
34  {
35  if (!Item.IsAir)
36  {
37  LootModItem.GetInfo(Item).SlottedInUI = true;
38  }
39  PostOnClickAction?.Invoke();
40  }
41  }
42 }
Defines an item that may be modified by modifiers from mods
Definition: LootModItem.cs:21
static LootModItem GetInfo(Item item)