Even More Modifiers  1.0.0.0
A mod for rolling various bonus stats on items
CheatedItemHackGlobalItem.cs
Go to the documentation of this file.
1 using System.Linq;
2 using Terraria;
3 using Terraria.ModLoader;
4 
5 namespace Loot.Hacks
6 {
10  public sealed class CheatedItemHackGlobalItem : GlobalItem
11  {
12  public override bool InstancePerEntity => true;
13  public override bool CloneNewInstances => true;
14 
20  public bool IsCheated { get; internal set; }
21 
22  public bool ShouldBeIgnored(Item item, Player player)
23  => !IsCheated && IsInVanitySot(item, player)
24  || IsCheated && !IsInVanitySot(item, player) && !IsInInventory(item, player);
25 
26  public bool IsInInventory(Item item, Player player)
27  => player.inventory.Any(x => x.IsTheSameAs(item));
28 
32  public bool IsInVanitySot(Item item, Player player)
33  => player.armor.Skip(13).Any(x => x.IsTheSameAs(item));
34 
35  private bool IsNotEquippedAtAll(Item item, Player player)
36  => !player.armor.Any(x => x.IsTheSameAs(item));
37 
38  public override void UpdateAccessory(Item item, Player player, bool hideVisual)
39  {
40  if (IsInVanitySot(item, player) || IsNotEquippedAtAll(item, player))
41  IsCheated = true;
42  else
43  IsCheated = false;
44  }
45 
46  public override void UpdateEquip(Item item, Player player)
47  {
48  if (IsInVanitySot(item, player) || IsNotEquippedAtAll(item, player))
49  IsCheated = true;
50  else
51  IsCheated = false;
52  }
53 
54  public override void UpdateInventory(Item item, Player player)
55  {
56  IsCheated = false;
57  }
58 
59  public override void PostUpdate(Item item)
60  {
61  IsCheated = false;
62  }
63 
64  public static CheatedItemHackGlobalItem GetInfo(Item item)
65  => item.GetGlobalItem<CheatedItemHackGlobalItem>();
66  }
67 }
override void UpdateInventory(Item item, Player player)
override void UpdateEquip(Item item, Player player)
Can detect if an item was activated via cheats
override void UpdateAccessory(Item item, Player player, bool hideVisual)