-
Notifications
You must be signed in to change notification settings - Fork 101
/
ItemData.cs
38 lines (28 loc) · 961 Bytes
/
ItemData.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using MagicStorage.Common.Systems.RecurrentRecipes;
using System;
using Terraria;
namespace MagicStorage
{
public readonly struct ItemData
{
public readonly int Type;
public readonly int Prefix;
public ItemData(int type, int prefix = 0)
{
Type = type;
Prefix = prefix;
}
public ItemData(Item item) : this(item.type, item.prefix)
{
}
public ItemData(ItemInfo info) : this(info.type, info.prefix)
{
}
public bool Equals(ItemData other) => Type == other.Type && Prefix == other.Prefix;
public override bool Equals(object obj) => obj is ItemData other && Equals(other);
public override int GetHashCode() => HashCode.Combine(Type, Prefix);
public static bool operator ==(ItemData left, ItemData right) => left.Equals(right);
public static bool operator !=(ItemData left, ItemData right) => !left.Equals(right);
public static bool Matches(Item item1, Item item2) => new ItemData(item1) == new ItemData(item2);
}
}