Even More Modifiers  1.0.0.0
A mod for rolling various bonus stats on items
MagicalCube.cs
Go to the documentation of this file.
1 using System.Collections.Generic;
2 using System.Linq;
3 using Microsoft.Xna.Framework;
4 using Terraria.ModLoader;
5 
6 namespace Loot.Api.Cubes
7 {
12  public abstract class MagicalCube : ModItem
13  {
14  public abstract int EssenceCraftCost { get; }
15 
16  protected abstract string CubeName { get; }
17  protected virtual Color? OverrideNameColor => null;
18  protected virtual TooltipLine ExtraTooltip => null;
19 
20  public sealed override void SetDefaults()
21  {
22  item.Size = new Vector2(36);
23  item.maxStack = 999;
24  item.consumable = false;
25  SafeDefaults();
26  }
27 
28  public override void SetStaticDefaults()
29  {
30  SafeStaticDefaults();
31  }
32 
33  protected virtual void SafeStaticDefaults()
34  {
35  }
36 
37  protected virtual void SafeDefaults()
38  {
39  }
40 
41  public override void ModifyTooltips(List<TooltipLine> tooltips)
42  {
43  base.ModifyTooltips(tooltips);
44 
45  var tts = tooltips.Where(x => x.mod.Equals("Terraria"));
46 
47  if (OverrideNameColor != null)
48  {
49  var itemName = tts.FirstOrDefault(x => x.Name.Equals("ItemName"));
50  if (itemName != null)
51  {
52  itemName.overrideColor = OverrideNameColor.Value;
53  }
54  }
55 
56  if (ExtraTooltip != null)
57  {
58  var desc = tts.Last(x => x.Name.StartsWith("Tooltip"));
59  if (desc != null)
60  {
61  tooltips.Insert(tooltips.IndexOf(desc) + 1, ExtraTooltip);
62  }
63  }
64  }
65  }
66 }
override void SetStaticDefaults()
Definition: MagicalCube.cs:28
Defines a magical cube A magical cube is used to change modifiers on an item
Definition: MagicalCube.cs:12
override void ModifyTooltips(List< TooltipLine > tooltips)
Definition: MagicalCube.cs:41
virtual void SafeStaticDefaults()
Definition: MagicalCube.cs:33
virtual void SafeDefaults()
Definition: MagicalCube.cs:37
sealed override void SetDefaults()
Definition: MagicalCube.cs:20