Skip to content

Commit 0dbab49

Browse files
committed
Create InventoryType.cs
1 parent 5d7034c commit 0dbab49

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
7+
namespace MapleLib.WzLib.WzStructure.Data.ItemStructure
8+
{
9+
public enum InventoryType : byte
10+
{
11+
EQUIP = 1,
12+
USE = 2,
13+
SETUP = 3,
14+
ETC = 4,
15+
CASH = 5,
16+
EQUIPPED = 255, // Using 255 instead of -1 as enums in C# are unsigned by default
17+
18+
NONE = 0, // or null
19+
}
20+
21+
public static class InventoryTypeExtensions
22+
{
23+
public static short GetBitfieldEncoding(this InventoryType inventoryType)
24+
{
25+
return (short)(2 << (byte)inventoryType);
26+
}
27+
28+
public static InventoryType? GetByType(byte type)
29+
{
30+
return Enum.GetValues<InventoryType>().FirstOrDefault(t => (byte)t == type);
31+
}
32+
33+
public static InventoryType? GetByWZName(string name)
34+
{
35+
return name switch
36+
{
37+
"Install" => InventoryType.SETUP,
38+
"Consume" => InventoryType.USE,
39+
"Etc" => InventoryType.ETC,
40+
"Cash" => InventoryType.CASH,
41+
"Pet" => InventoryType.CASH,
42+
_ => null
43+
};
44+
}
45+
}
46+
}

0 commit comments

Comments
 (0)