com.wallstop-studios.unity-helpers 2.0.0-rc16 → 2.0.0-rc17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
return random.NextVector2(-amplitude, amplitude);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
public static T NextEnumExcept<T>(this IRandom random, params T[]
|
|
17
|
+
public static T NextEnumExcept<T>(this IRandom random, params T[] exceptions)
|
|
18
18
|
where T : struct, Enum
|
|
19
19
|
{
|
|
20
20
|
T value;
|
|
21
21
|
do
|
|
22
22
|
{
|
|
23
23
|
value = random.NextEnum<T>();
|
|
24
|
-
} while (
|
|
24
|
+
} while (0 <= Array.IndexOf(exceptions, value));
|
|
25
25
|
|
|
26
26
|
return value;
|
|
27
27
|
}
|
|
@@ -33,10 +33,38 @@
|
|
|
33
33
|
)
|
|
34
34
|
{
|
|
35
35
|
T value;
|
|
36
|
-
|
|
36
|
+
|
|
37
|
+
switch (values)
|
|
37
38
|
{
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
case IReadOnlyList<T> list:
|
|
40
|
+
{
|
|
41
|
+
do
|
|
42
|
+
{
|
|
43
|
+
value = random.NextOf(list);
|
|
44
|
+
} while (0 <= Array.IndexOf(exceptions, value));
|
|
45
|
+
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
case IReadOnlyCollection<T> collection:
|
|
49
|
+
{
|
|
50
|
+
do
|
|
51
|
+
{
|
|
52
|
+
value = random.NextOf(collection);
|
|
53
|
+
} while (0 <= Array.IndexOf(exceptions, value));
|
|
54
|
+
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
default:
|
|
58
|
+
{
|
|
59
|
+
T[] input = values.ToArray();
|
|
60
|
+
do
|
|
61
|
+
{
|
|
62
|
+
value = random.NextOf(input);
|
|
63
|
+
} while (0 <= Array.IndexOf(exceptions, value));
|
|
64
|
+
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
40
68
|
|
|
41
69
|
return value;
|
|
42
70
|
}
|