File tree Expand file tree Collapse file tree 1 file changed +46
-0
lines changed
MapleLib/WzLib/WzStructure/Data/ItemStructure Expand file tree Collapse file tree 1 file changed +46
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments