-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathEquipSlot.cs
174 lines (163 loc) · 6.02 KB
/
EquipSlot.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
using System.ComponentModel;
namespace PathMapper;
public enum EquipSlot : byte {
Unknown = 0,
MainHand = 1,
OffHand = 2,
Head = 3,
Body = 4,
Hands = 5,
Belt = 6,
Legs = 7,
Feet = 8,
Ears = 9,
Neck = 10,
Wrists = 11,
RFinger = 12,
BothHand = 13,
LFinger = 14, // Not officially existing, means "weapon could be equipped in either hand" for the game.
HeadBody = 15,
BodyHandsLegsFeet = 16,
SoulCrystal = 17,
LegsFeet = 18,
FullBody = 19,
BodyHands = 20,
BodyLegsFeet = 21,
ChestHands = 22,
Nothing = 23,
All = 24, // Not officially existing
}
public static class EquipSlotExtensions {
public static EquipSlot ToEquipSlot(this uint value) => value switch {
0 => EquipSlot.Head,
1 => EquipSlot.Body,
2 => EquipSlot.Hands,
3 => EquipSlot.Legs,
4 => EquipSlot.Feet,
5 => EquipSlot.Ears,
6 => EquipSlot.Neck,
7 => EquipSlot.Wrists,
8 => EquipSlot.RFinger,
9 => EquipSlot.LFinger,
_ => EquipSlot.Unknown,
};
public static uint ToIndex(this EquipSlot slot) => slot switch {
EquipSlot.Head => 0,
EquipSlot.Body => 1,
EquipSlot.Hands => 2,
EquipSlot.Legs => 3,
EquipSlot.Feet => 4,
EquipSlot.Ears => 5,
EquipSlot.Neck => 6,
EquipSlot.Wrists => 7,
EquipSlot.RFinger => 8,
EquipSlot.LFinger => 9,
_ => uint.MaxValue,
};
public static string ToSuffix(this EquipSlot value) {
return value switch {
EquipSlot.Head => "met",
EquipSlot.Hands => "glv",
EquipSlot.Legs => "dwn",
EquipSlot.Feet => "sho",
EquipSlot.Body => "top",
EquipSlot.Ears => "ear",
EquipSlot.Neck => "nek",
EquipSlot.RFinger => "rir",
EquipSlot.LFinger => "ril",
EquipSlot.Wrists => "wrs",
_ => throw new InvalidEnumArgumentException(),
};
}
public static EquipSlot ToSlot(this EquipSlot value) {
return value switch {
EquipSlot.MainHand => EquipSlot.MainHand,
EquipSlot.OffHand => EquipSlot.OffHand,
EquipSlot.Head => EquipSlot.Head,
EquipSlot.Body => EquipSlot.Body,
EquipSlot.Hands => EquipSlot.Hands,
EquipSlot.Belt => EquipSlot.Belt,
EquipSlot.Legs => EquipSlot.Legs,
EquipSlot.Feet => EquipSlot.Feet,
EquipSlot.Ears => EquipSlot.Ears,
EquipSlot.Neck => EquipSlot.Neck,
EquipSlot.Wrists => EquipSlot.Wrists,
EquipSlot.RFinger => EquipSlot.RFinger,
EquipSlot.BothHand => EquipSlot.MainHand,
EquipSlot.LFinger => EquipSlot.RFinger,
EquipSlot.HeadBody => EquipSlot.Body,
EquipSlot.BodyHandsLegsFeet => EquipSlot.Body,
EquipSlot.SoulCrystal => EquipSlot.SoulCrystal,
EquipSlot.LegsFeet => EquipSlot.Legs,
EquipSlot.FullBody => EquipSlot.Body,
EquipSlot.BodyHands => EquipSlot.Body,
EquipSlot.BodyLegsFeet => EquipSlot.Body,
EquipSlot.ChestHands => EquipSlot.Body,
_ => throw new InvalidEnumArgumentException($"{value} ({(int) value}) is not valid."),
};
}
public static string ToName(this EquipSlot value) {
return value switch {
EquipSlot.Head => "Head",
EquipSlot.Hands => "Hands",
EquipSlot.Legs => "Legs",
EquipSlot.Feet => "Feet",
EquipSlot.Body => "Body",
EquipSlot.Ears => "Earrings",
EquipSlot.Neck => "Necklace",
EquipSlot.RFinger => "Right Ring",
EquipSlot.LFinger => "Left Ring",
EquipSlot.Wrists => "Bracelets",
EquipSlot.MainHand => "Primary Weapon",
EquipSlot.OffHand => "Secondary Weapon",
EquipSlot.Belt => "Belt",
EquipSlot.BothHand => "Primary Weapon",
EquipSlot.HeadBody => "Head and Body",
EquipSlot.BodyHandsLegsFeet => "Costume",
EquipSlot.SoulCrystal => "Soul Crystal",
EquipSlot.LegsFeet => "Bottom",
EquipSlot.FullBody => "Costume",
EquipSlot.BodyHands => "Top",
EquipSlot.BodyLegsFeet => "Costume",
EquipSlot.All => "Costume",
_ => "Unknown",
};
}
public static bool IsEquipment(this EquipSlot value) {
return value switch {
EquipSlot.Head => true,
EquipSlot.Hands => true,
EquipSlot.Legs => true,
EquipSlot.Feet => true,
EquipSlot.Body => true,
_ => false,
};
}
public static bool IsAccessory(this EquipSlot value) {
return value switch {
EquipSlot.Ears => true,
EquipSlot.Neck => true,
EquipSlot.RFinger => true,
EquipSlot.LFinger => true,
EquipSlot.Wrists => true,
_ => false,
};
}
public static readonly EquipSlot[] EquipmentSlots = Enum.GetValues<EquipSlot>().Where(e => e.IsEquipment()).ToArray();
public static readonly EquipSlot[] AccessorySlots = Enum.GetValues<EquipSlot>().Where(e => e.IsAccessory()).ToArray();
public static readonly EquipSlot[] EqdpSlots = EquipmentSlots.Concat(AccessorySlots).ToArray();
}
public static partial class Names {
public static readonly Dictionary<string, EquipSlot> SuffixToEquipSlot = new() {
{ EquipSlot.Head.ToSuffix(), EquipSlot.Head },
{ EquipSlot.Hands.ToSuffix(), EquipSlot.Hands },
{ EquipSlot.Legs.ToSuffix(), EquipSlot.Legs },
{ EquipSlot.Feet.ToSuffix(), EquipSlot.Feet },
{ EquipSlot.Body.ToSuffix(), EquipSlot.Body },
{ EquipSlot.Ears.ToSuffix(), EquipSlot.Ears },
{ EquipSlot.Neck.ToSuffix(), EquipSlot.Neck },
{ EquipSlot.RFinger.ToSuffix(), EquipSlot.RFinger },
{ EquipSlot.LFinger.ToSuffix(), EquipSlot.LFinger },
{ EquipSlot.Wrists.ToSuffix(), EquipSlot.Wrists },
};
}