Even More Modifiers  1.0.0.0
A mod for rolling various bonus stats on items
CraftingComponentButton.cs
Go to the documentation of this file.
1 using Loot.Api.Strategy;
3 using Microsoft.Xna.Framework.Graphics;
4 using Terraria;
5 using Terraria.UI;
6 
7 namespace Loot.UI.Tabs.CraftingTab
8 {
13  internal abstract class CraftingComponentButton : GuiInteractableItemButton
14  {
15  public CraftingComponentLink Link;
16 
17  internal CraftingComponentButton(ButtonType buttonType, int netId = 0, int stack = 0, Texture2D hintTexture = null, string hintText = null, string hintOnHover = null) : base(buttonType, netId, stack, hintTexture, hintText, hintOnHover)
18  {
19  RightClickFunctionalityEnabled = false;
20  TakeUserItemOnClick = false;
21  HintOnHover = " (click to unslot)";
22  }
23 
24  public abstract RollingStrategy GetRollingStrategy(Item item, RollingStrategyProperties rollingStrategyProperties);
25 
26  public override void PostOnClick(UIMouseEvent evt, UIElement e)
27  {
28 
29  }
30 
31  public override void ChangeItem(int type, Item item = null)
32  {
33  if (item != null)
34  {
36  }
37  else
38  {
39  var component = new Item();
40  component.SetDefaults(type);
41  SetLink(new CraftingComponentLink(component, CraftingComponentLink.ComponentSource.Dynamic));
42  }
43  }
44 
45  public void SetLink(CraftingComponentLink link)
46  {
47  if (link == null)
48  {
49  Item.TurnToAir();
50  Link = null;
51  }
52  else
53  {
54  Link = link;
55  Item = Link.Component.Clone();
56  }
57  OnItemChange?.Invoke(Item);
58  }
59  }
60 }
Defines properties that will be used when an item is being rolled in a IRollingStrategy<T> These can ...