forked from laicasaane/unity-supplements
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnumLength.cs
86 lines (77 loc) · 3.52 KB
/
EnumLength.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
using System.Collections.Generic;
namespace System
{
public static class EnumLength
{
public static int Get<T>() where T : unmanaged, Enum
=> EnumValues<T>.UnderlyingValueCount;
public static Length2 Get<TA, TB>()
where TA : unmanaged, Enum
where TB : unmanaged, Enum
=> new Length2(EnumValues<TA>.UnderlyingValueCount, EnumValues<TB>.UnderlyingValueCount);
public static Length3 Get<TA, TB, TC>()
where TA : unmanaged, Enum
where TB : unmanaged, Enum
where TC : unmanaged, Enum
=> new Length3(EnumValues<TA>.UnderlyingValueCount, EnumValues<TB>.UnderlyingValueCount,
EnumValues<TC>.UnderlyingValueCount);
public static Length4 Get<TA, TB, TC, TD>()
where TA : unmanaged, Enum
where TB : unmanaged, Enum
where TC : unmanaged, Enum
where TD : unmanaged, Enum
=> new Length4(EnumValues<TA>.UnderlyingValueCount, EnumValues<TB>.UnderlyingValueCount,
EnumValues<TC>.UnderlyingValueCount, EnumValues<TD>.UnderlyingValueCount);
public static Length5 Get<TA, TB, TC, TD, TE>()
where TA : unmanaged, Enum
where TB : unmanaged, Enum
where TC : unmanaged, Enum
where TD : unmanaged, Enum
where TE : unmanaged, Enum
=> new Length5(EnumValues<TA>.UnderlyingValueCount, EnumValues<TB>.UnderlyingValueCount,
EnumValues<TC>.UnderlyingValueCount, EnumValues<TD>.UnderlyingValueCount,
EnumValues<TE>.UnderlyingValueCount);
public static Length2 With<TA, TB>(in this Length2 self, bool A = false, bool B = false)
where TA : unmanaged, Enum
where TB : unmanaged, Enum
=> new Length2(
A ? Get<TA>() : self.A,
B ? Get<TB>() : self.B
);
public static Length3 With<TA, TB, TC>(in this Length3 self, bool A = false, bool B = false, bool C = false)
where TA : unmanaged, Enum
where TB : unmanaged, Enum
where TC : unmanaged, Enum
=> new Length3(
A ? Get<TA>() : self.A,
B ? Get<TB>() : self.B,
C ? Get<TC>() : self.C
);
public static Length4 With<TA, TB, TC, TD>(in this Length4 self, bool A = false, bool B = false, bool C = false,
bool D = false)
where TA : unmanaged, Enum
where TB : unmanaged, Enum
where TC : unmanaged, Enum
where TD : unmanaged, Enum
=> new Length4(
A ? Get<TA>() : self.A,
B ? Get<TB>() : self.B,
C ? Get<TC>() : self.C,
D ? Get<TD>() : self.D
);
public static Length5 With<TA, TB, TC, TD, TE>(in this Length5 self, bool A = false, bool B = false, bool C = false,
bool D = false, bool E = false)
where TA : unmanaged, Enum
where TB : unmanaged, Enum
where TC : unmanaged, Enum
where TD : unmanaged, Enum
where TE : unmanaged, Enum
=> new Length5(
A ? Get<TA>() : self.A,
B ? Get<TB>() : self.B,
C ? Get<TC>() : self.C,
D ? Get<TD>() : self.D,
E ? Get<TE>() : self.E
);
}
}