com.wallstop-studios.unity-helpers 2.0.0-rc04 → 2.0.0-rc06
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.
- package/CHANGELOG.md.meta +7 -7
- package/Editor/AnimationEventEditor.cs.meta +11 -11
- package/Editor.meta +8 -8
- package/LICENSE.md.meta +7 -7
- package/README.md.meta +7 -7
- package/Runtime/Core/Attributes/AnimationEventAttribute.cs.meta +11 -11
- package/Runtime/Core/Attributes/ChildComponentAttribute.cs.meta +11 -11
- package/Runtime/Core/Attributes/KSerializableAttribute.cs.meta +11 -11
- package/Runtime/Core/Attributes/NotNullAttribute.cs.meta +11 -11
- package/Runtime/Core/Attributes/ParentComponent.cs.meta +11 -11
- package/Runtime/Core/Attributes/ReadOnlyAttribute.cs.meta +11 -11
- package/Runtime/Core/Attributes/RelationalComponentExtensions.cs.meta +11 -11
- package/Runtime/Core/DataStructure/Adapters/FastVector2Int.cs.meta +11 -11
- package/Runtime/Core/DataStructure/Adapters/FastVector3Int.cs.meta +11 -11
- package/Runtime/Core/DataStructure/Adapters/KGuid.cs.meta +11 -11
- package/Runtime/Core/DataStructure/Adapters/KVector2.cs.meta +11 -11
- package/Runtime/Core/DataStructure/Adapters.meta +8 -8
- package/Runtime/Core/DataStructure/Circle.cs.meta +11 -11
- package/Runtime/Core/DataStructure/CyclicBuffer.cs.meta +11 -11
- package/Runtime/Core/DataStructure/QuadTree.cs.meta +11 -11
- package/Runtime/Core/DataStructure/StringWrapper.cs.meta +11 -11
- package/Runtime/Core/DataStructure/TimedCache.cs +4 -3
- package/Runtime/Core/DataStructure/TimedCache.cs.meta +11 -11
- package/Runtime/Core/DataStructure.meta +8 -8
- package/Runtime/Core/Extension/AnimatorExtensions.cs.meta +11 -11
- package/Runtime/Core/Extension/CircleExtensions.cs.meta +11 -11
- package/Runtime/Core/Extension/ColorExtensions.cs.meta +11 -11
- package/Runtime/Core/Extension/DictionaryExtensions.cs.meta +11 -11
- package/Runtime/Core/Extension/DirectionExtensions.cs.meta +11 -11
- package/Runtime/Core/Extension/HashSetExtensions.cs.meta +11 -11
- package/Runtime/Core/Extension/IEnumerableExtensions.cs.meta +11 -11
- package/Runtime/Core/Extension/IListExtensions.cs +2 -2
- package/Runtime/Core/Extension/IListExtensions.cs.meta +11 -11
- package/Runtime/Core/Extension/LoggingExtensions.cs.meta +11 -11
- package/Runtime/Core/Extension/RandomExtensions.cs +23 -4
- package/Runtime/Core/Extension/RandomExtensions.cs.meta +11 -11
- package/Runtime/Core/Extension/StringExtensions.cs.meta +11 -11
- package/Runtime/Core/Extension/UnityExtensions.cs +278 -90
- package/Runtime/Core/Extension/UnityExtensions.cs.meta +11 -11
- package/Runtime/Core/Extension.meta +8 -8
- package/Runtime/Core/Helper/ArrayConverter.cs +39 -0
- package/Runtime/Core/Helper/ArrayConverter.cs.meta +3 -0
- package/Runtime/Core/Helper/Enumerables.cs.meta +11 -11
- package/Runtime/Core/Helper/Geometry.cs.meta +11 -11
- package/Runtime/Core/Helper/Helpers.cs +209 -84
- package/Runtime/Core/Helper/LifetimeHelpers.cs.meta +11 -11
- package/Runtime/Core/Helper/Objects.cs.meta +11 -11
- package/Runtime/Core/Helper/WallMath.cs +85 -22
- package/Runtime/Core/Helper/WallMath.cs.meta +11 -11
- package/Runtime/Core/Helper.meta +8 -8
- package/Runtime/Core/Math/Line.cs.meta +11 -11
- package/Runtime/Core/Math/Parabola.cs.meta +11 -11
- package/Runtime/Core/Math/Range.cs.meta +11 -11
- package/Runtime/Core/Math.meta +8 -8
- package/Runtime/Core/Model/Direction.cs.meta +11 -11
- package/Runtime/Core/Model.meta +8 -8
- package/Runtime/Core/OneOf/FastOneOf.cs.meta +11 -11
- package/Runtime/Core/OneOf/None.cs.meta +11 -11
- package/Runtime/Core/OneOf.meta +8 -8
- package/Runtime/Core/Random/AbstractRandom.cs +34 -20
- package/Runtime/Core/Random/AbstractRandom.cs.meta +11 -11
- package/Runtime/Core/Random/DotNetRandom.cs +52 -0
- package/Runtime/Core/Random/DotNetRandom.cs.meta +3 -0
- package/Runtime/Core/Random/IRandom.cs.meta +11 -11
- package/Runtime/Core/Random/NativePcgRandom.cs.meta +11 -11
- package/Runtime/Core/Random/PRNG.cs +7 -0
- package/Runtime/Core/Random/PRNG.cs.meta +3 -0
- package/Runtime/Core/Random/PcgRandom.cs +23 -22
- package/Runtime/Core/Random/PcgRandom.cs.meta +11 -11
- package/Runtime/Core/Random/RandomState.cs +44 -5
- package/Runtime/Core/Random/RandomState.cs.meta +11 -11
- package/Runtime/Core/Random/SquirrelRandom.cs +13 -10
- package/Runtime/Core/Random/SquirrelRandom.cs.meta +11 -11
- package/Runtime/Core/Random/SystemRandom.cs +31 -16
- package/Runtime/Core/Random/SystemRandom.cs.meta +11 -11
- package/Runtime/Core/Random/ThreadLocalRandom.cs +2 -1
- package/Runtime/Core/Random/ThreadLocalRandom.cs.meta +11 -11
- package/Runtime/Core/Random/UnityRandom.cs +37 -4
- package/Runtime/Core/Random/WyRandom.cs +121 -0
- package/Runtime/Core/Random/WyRandom.cs.meta +3 -0
- package/Runtime/Core/Random/XorShiftRandom.cs +9 -7
- package/Runtime/Core/Random.meta +8 -8
- package/Runtime/Core/Serialization/JsonConverters/Vector2Converter.cs.meta +11 -11
- package/Runtime/Core/Serialization/JsonConverters/Vector3Converter.cs.meta +11 -11
- package/Runtime/Core/Serialization/JsonConverters.meta +8 -8
- package/Runtime/Core/Serialization/Serializer.cs +36 -14
- package/Runtime/Core/Serialization/Serializer.cs.meta +11 -11
- package/Runtime/Core/Serialization.meta +8 -8
- package/Runtime/Core/Threading/SingleThreadedThreadPool.cs.meta +11 -11
- package/Runtime/Core/Threading.meta +8 -8
- package/Runtime/Core.meta +8 -8
- package/Runtime/Protobuf-Net.meta +8 -8
- package/Runtime/Utils/AnimationEventEqualityComparer.cs.meta +11 -11
- package/Runtime/Utils/AnimatorEnumStateMachine.cs.meta +11 -11
- package/Runtime/Utils/Buffers.cs.meta +11 -11
- package/Runtime/Utils/CircleLineRenderer.cs +17 -5
- package/Runtime/Utils/CircleLineRenderer.cs.meta +11 -11
- package/Runtime/Utils/Oscillator.cs.meta +11 -11
- package/Runtime/Utils/SetTextureImportData.cs.meta +11 -11
- package/Runtime/Utils.meta +8 -8
- package/Runtime/WallstopStudios.UnityHelpers.asmdef.meta +7 -7
- package/Runtime.meta +8 -8
- package/Tests/Runtime/DataStructures/SpatialTreeTests.cs +34 -10
- package/Tests/Runtime/Helper/ArrayConverterTests.cs +19 -0
- package/Tests/Runtime/Helper/ArrayConverterTests.cs.meta +3 -0
- package/Tests/Runtime/Helper/WallMathTests.cs +221 -0
- package/Tests/Runtime/Helper/WallMathTests.cs.meta +3 -0
- package/Tests/Runtime/Helper.meta +3 -0
- package/Tests/Runtime/Performance/RandomPerformanceTests.cs +18 -13
- package/Tests/Runtime/Performance/SpatialTreePerformanceTest.cs +47 -34
- package/Tests/Runtime/Random/DotNetRandomTests.cs +9 -0
- package/Tests/Runtime/Random/DotNetRandomTests.cs.meta +3 -0
- package/Tests/Runtime/Random/RandomTestBase.cs +89 -15
- package/Tests/Runtime/Random/WyRandomTests.cs +9 -0
- package/Tests/Runtime/Random/WyRandomTests.cs.meta +3 -0
- package/Tests/Runtime/Serialization/JsonSerializationTest.cs +24 -11
- package/Tests/Runtime/Utils/SpriteRendererMetadataTests.cs +21 -17
- package/Tests.meta +8 -8
- package/Third Party Notices.md.meta +7 -7
- package/package.json +1 -1
- package/package.json.meta +7 -7
|
@@ -14,7 +14,9 @@
|
|
|
14
14
|
|
|
15
15
|
public static double BoundedDouble(double max, double value)
|
|
16
16
|
{
|
|
17
|
-
return value < max
|
|
17
|
+
return value < max
|
|
18
|
+
? value
|
|
19
|
+
: BitConverter.Int64BitsToDouble(BitConverter.DoubleToInt64Bits(value) - 1);
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
public static float BoundedFloat(float max, float value)
|
|
@@ -22,52 +24,113 @@
|
|
|
22
24
|
return value < max
|
|
23
25
|
? value
|
|
24
26
|
: BitConverter.ToSingle(
|
|
25
|
-
BitConverter.GetBytes(
|
|
27
|
+
BitConverter.GetBytes(
|
|
28
|
+
BitConverter.ToInt32(BitConverter.GetBytes(value), 0) - 1
|
|
29
|
+
),
|
|
30
|
+
0
|
|
31
|
+
);
|
|
26
32
|
}
|
|
27
33
|
|
|
28
|
-
public static int WrappedAdd(int value, int increment, int max)
|
|
34
|
+
public static int WrappedAdd(this int value, int increment, int max)
|
|
29
35
|
{
|
|
30
36
|
WrappedAdd(ref value, increment, max);
|
|
31
37
|
return value;
|
|
32
38
|
}
|
|
33
39
|
|
|
34
|
-
public static
|
|
40
|
+
public static int WrappedAdd(ref int value, int increment, int max)
|
|
35
41
|
{
|
|
36
|
-
value
|
|
42
|
+
value += increment;
|
|
37
43
|
if (value < max)
|
|
38
44
|
{
|
|
39
|
-
return;
|
|
45
|
+
return value;
|
|
40
46
|
}
|
|
41
|
-
value %= max;
|
|
47
|
+
return value %= max;
|
|
42
48
|
}
|
|
43
49
|
|
|
44
|
-
public static int WrappedIncrement(int value, int max)
|
|
50
|
+
public static int WrappedIncrement(this int value, int max)
|
|
45
51
|
{
|
|
46
52
|
return WrappedAdd(value, 1, max);
|
|
47
53
|
}
|
|
48
54
|
|
|
49
|
-
public static
|
|
55
|
+
public static int WrappedIncrement(ref int value, int max)
|
|
56
|
+
{
|
|
57
|
+
return WrappedAdd(ref value, 1, max);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public static T Clamp<T>(this T value, T min, T max)
|
|
61
|
+
where T : IComparable<T>
|
|
62
|
+
{
|
|
63
|
+
if (value.CompareTo(min) < 0)
|
|
64
|
+
{
|
|
65
|
+
return min;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return max.CompareTo(value) < 0 ? max : value;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public static Vector2 Clamp(this Rect bounds, Vector2 point)
|
|
50
72
|
{
|
|
51
|
-
|
|
73
|
+
return Clamp(bounds, ref point);
|
|
52
74
|
}
|
|
53
75
|
|
|
54
|
-
public static
|
|
76
|
+
public static Vector2 Clamp(this Rect bounds, ref Vector2 point)
|
|
55
77
|
{
|
|
56
|
-
if (
|
|
78
|
+
if (bounds.Contains(point))
|
|
79
|
+
{
|
|
80
|
+
return point;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
Vector2 center = bounds.center;
|
|
84
|
+
Vector2 direction = point - center;
|
|
85
|
+
|
|
86
|
+
if (direction == Vector2.zero)
|
|
87
|
+
{
|
|
88
|
+
return center;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
float tMax = float.MaxValue;
|
|
92
|
+
Vector2 min = bounds.min;
|
|
93
|
+
Vector2 max = bounds.max;
|
|
94
|
+
|
|
95
|
+
if (direction.x != 0)
|
|
96
|
+
{
|
|
97
|
+
if (0 < direction.x)
|
|
98
|
+
{
|
|
99
|
+
float t2 = (max.x - center.x) / direction.x;
|
|
100
|
+
tMax = Math.Min(tMax, t2);
|
|
101
|
+
}
|
|
102
|
+
else
|
|
103
|
+
{
|
|
104
|
+
float t1 = (min.x - center.x) / direction.x;
|
|
105
|
+
tMax = Math.Min(tMax, t1);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (direction.y != 0)
|
|
57
110
|
{
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
111
|
+
if (direction.y > 0)
|
|
112
|
+
{
|
|
113
|
+
float t2 = (max.y - center.y) / direction.y;
|
|
114
|
+
tMax = Math.Min(tMax, t2);
|
|
115
|
+
}
|
|
116
|
+
else
|
|
117
|
+
{
|
|
118
|
+
float t1 = (min.y - center.y) / direction.y;
|
|
119
|
+
tMax = Math.Min(tMax, t1);
|
|
120
|
+
}
|
|
67
121
|
}
|
|
122
|
+
|
|
123
|
+
tMax = Mathf.Clamp01(tMax);
|
|
124
|
+
|
|
125
|
+
point = center + direction * tMax;
|
|
126
|
+
point = new Vector2(
|
|
127
|
+
Mathf.Clamp(point.x, min.x, max.x),
|
|
128
|
+
Mathf.Clamp(point.y, min.y, max.y)
|
|
129
|
+
);
|
|
130
|
+
return point;
|
|
68
131
|
}
|
|
69
132
|
|
|
70
|
-
public static bool Approximately(float lhs, float rhs, float tolerance = 0.045f)
|
|
133
|
+
public static bool Approximately(this float lhs, float rhs, float tolerance = 0.045f)
|
|
71
134
|
{
|
|
72
135
|
return Math.Abs(lhs - rhs) <= tolerance;
|
|
73
136
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: e3e4af682073d054489c5cb1fe1c5b5a
|
|
3
|
-
MonoImporter:
|
|
4
|
-
externalObjects: {}
|
|
5
|
-
serializedVersion: 2
|
|
6
|
-
defaultReferences: []
|
|
7
|
-
executionOrder: 0
|
|
8
|
-
icon: {instanceID: 0}
|
|
9
|
-
userData:
|
|
10
|
-
assetBundleName:
|
|
11
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: e3e4af682073d054489c5cb1fe1c5b5a
|
|
3
|
+
MonoImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
defaultReferences: []
|
|
7
|
+
executionOrder: 0
|
|
8
|
+
icon: {instanceID: 0}
|
|
9
|
+
userData:
|
|
10
|
+
assetBundleName:
|
|
11
|
+
assetBundleVariant:
|
package/Runtime/Core/Helper.meta
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: 63459188a950ba74db1e2d843839f821
|
|
3
|
-
folderAsset: yes
|
|
4
|
-
DefaultImporter:
|
|
5
|
-
externalObjects: {}
|
|
6
|
-
userData:
|
|
7
|
-
assetBundleName:
|
|
8
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: 63459188a950ba74db1e2d843839f821
|
|
3
|
+
folderAsset: yes
|
|
4
|
+
DefaultImporter:
|
|
5
|
+
externalObjects: {}
|
|
6
|
+
userData:
|
|
7
|
+
assetBundleName:
|
|
8
|
+
assetBundleVariant:
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: 806e572a2d471104f8b68b9ecc4bd919
|
|
3
|
-
MonoImporter:
|
|
4
|
-
externalObjects: {}
|
|
5
|
-
serializedVersion: 2
|
|
6
|
-
defaultReferences: []
|
|
7
|
-
executionOrder: 0
|
|
8
|
-
icon: {instanceID: 0}
|
|
9
|
-
userData:
|
|
10
|
-
assetBundleName:
|
|
11
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: 806e572a2d471104f8b68b9ecc4bd919
|
|
3
|
+
MonoImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
defaultReferences: []
|
|
7
|
+
executionOrder: 0
|
|
8
|
+
icon: {instanceID: 0}
|
|
9
|
+
userData:
|
|
10
|
+
assetBundleName:
|
|
11
|
+
assetBundleVariant:
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: 378ba2f7355b4b148986cd42bc9813df
|
|
3
|
-
MonoImporter:
|
|
4
|
-
externalObjects: {}
|
|
5
|
-
serializedVersion: 2
|
|
6
|
-
defaultReferences: []
|
|
7
|
-
executionOrder: 0
|
|
8
|
-
icon: {instanceID: 0}
|
|
9
|
-
userData:
|
|
10
|
-
assetBundleName:
|
|
11
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: 378ba2f7355b4b148986cd42bc9813df
|
|
3
|
+
MonoImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
defaultReferences: []
|
|
7
|
+
executionOrder: 0
|
|
8
|
+
icon: {instanceID: 0}
|
|
9
|
+
userData:
|
|
10
|
+
assetBundleName:
|
|
11
|
+
assetBundleVariant:
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: d0976d7d8aebfeb4db8f058c5e803057
|
|
3
|
-
MonoImporter:
|
|
4
|
-
externalObjects: {}
|
|
5
|
-
serializedVersion: 2
|
|
6
|
-
defaultReferences: []
|
|
7
|
-
executionOrder: 0
|
|
8
|
-
icon: {instanceID: 0}
|
|
9
|
-
userData:
|
|
10
|
-
assetBundleName:
|
|
11
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: d0976d7d8aebfeb4db8f058c5e803057
|
|
3
|
+
MonoImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
defaultReferences: []
|
|
7
|
+
executionOrder: 0
|
|
8
|
+
icon: {instanceID: 0}
|
|
9
|
+
userData:
|
|
10
|
+
assetBundleName:
|
|
11
|
+
assetBundleVariant:
|
package/Runtime/Core/Math.meta
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: adcccded420bef24ab8fd609fb00feb0
|
|
3
|
-
folderAsset: yes
|
|
4
|
-
DefaultImporter:
|
|
5
|
-
externalObjects: {}
|
|
6
|
-
userData:
|
|
7
|
-
assetBundleName:
|
|
8
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: adcccded420bef24ab8fd609fb00feb0
|
|
3
|
+
folderAsset: yes
|
|
4
|
+
DefaultImporter:
|
|
5
|
+
externalObjects: {}
|
|
6
|
+
userData:
|
|
7
|
+
assetBundleName:
|
|
8
|
+
assetBundleVariant:
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: 09b76f49035ddaf40948ba4cc4ebf959
|
|
3
|
-
MonoImporter:
|
|
4
|
-
externalObjects: {}
|
|
5
|
-
serializedVersion: 2
|
|
6
|
-
defaultReferences: []
|
|
7
|
-
executionOrder: 0
|
|
8
|
-
icon: {instanceID: 0}
|
|
9
|
-
userData:
|
|
10
|
-
assetBundleName:
|
|
11
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: 09b76f49035ddaf40948ba4cc4ebf959
|
|
3
|
+
MonoImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
defaultReferences: []
|
|
7
|
+
executionOrder: 0
|
|
8
|
+
icon: {instanceID: 0}
|
|
9
|
+
userData:
|
|
10
|
+
assetBundleName:
|
|
11
|
+
assetBundleVariant:
|
package/Runtime/Core/Model.meta
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: 6448620daa761f54bbcd28028fcec20f
|
|
3
|
-
folderAsset: yes
|
|
4
|
-
DefaultImporter:
|
|
5
|
-
externalObjects: {}
|
|
6
|
-
userData:
|
|
7
|
-
assetBundleName:
|
|
8
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: 6448620daa761f54bbcd28028fcec20f
|
|
3
|
+
folderAsset: yes
|
|
4
|
+
DefaultImporter:
|
|
5
|
+
externalObjects: {}
|
|
6
|
+
userData:
|
|
7
|
+
assetBundleName:
|
|
8
|
+
assetBundleVariant:
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: 0aeb8725615721e42b22eb8ff560abb3
|
|
3
|
-
MonoImporter:
|
|
4
|
-
externalObjects: {}
|
|
5
|
-
serializedVersion: 2
|
|
6
|
-
defaultReferences: []
|
|
7
|
-
executionOrder: 0
|
|
8
|
-
icon: {instanceID: 0}
|
|
9
|
-
userData:
|
|
10
|
-
assetBundleName:
|
|
11
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: 0aeb8725615721e42b22eb8ff560abb3
|
|
3
|
+
MonoImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
defaultReferences: []
|
|
7
|
+
executionOrder: 0
|
|
8
|
+
icon: {instanceID: 0}
|
|
9
|
+
userData:
|
|
10
|
+
assetBundleName:
|
|
11
|
+
assetBundleVariant:
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: 7bd7c572f1e481541839edaf4d39b8eb
|
|
3
|
-
MonoImporter:
|
|
4
|
-
externalObjects: {}
|
|
5
|
-
serializedVersion: 2
|
|
6
|
-
defaultReferences: []
|
|
7
|
-
executionOrder: 0
|
|
8
|
-
icon: {instanceID: 0}
|
|
9
|
-
userData:
|
|
10
|
-
assetBundleName:
|
|
11
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: 7bd7c572f1e481541839edaf4d39b8eb
|
|
3
|
+
MonoImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
defaultReferences: []
|
|
7
|
+
executionOrder: 0
|
|
8
|
+
icon: {instanceID: 0}
|
|
9
|
+
userData:
|
|
10
|
+
assetBundleName:
|
|
11
|
+
assetBundleVariant:
|
package/Runtime/Core/OneOf.meta
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: f34b22dccaf2c534283095976d8ffe81
|
|
3
|
-
folderAsset: yes
|
|
4
|
-
DefaultImporter:
|
|
5
|
-
externalObjects: {}
|
|
6
|
-
userData:
|
|
7
|
-
assetBundleName:
|
|
8
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: f34b22dccaf2c534283095976d8ffe81
|
|
3
|
+
folderAsset: yes
|
|
4
|
+
DefaultImporter:
|
|
5
|
+
externalObjects: {}
|
|
6
|
+
userData:
|
|
7
|
+
assetBundleName:
|
|
8
|
+
assetBundleVariant:
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
using System.Collections.Generic;
|
|
6
6
|
using System.Linq;
|
|
7
7
|
using System.Runtime.Serialization;
|
|
8
|
+
using System.Text.Json.Serialization;
|
|
8
9
|
using DataStructure.Adapters;
|
|
9
10
|
using UnityEngine;
|
|
10
11
|
|
|
@@ -30,8 +31,7 @@
|
|
|
30
31
|
do
|
|
31
32
|
{
|
|
32
33
|
result = unchecked((int)NextUint());
|
|
33
|
-
}
|
|
34
|
-
while (result < 0);
|
|
34
|
+
} while (result < 0);
|
|
35
35
|
|
|
36
36
|
return result;
|
|
37
37
|
}
|
|
@@ -50,7 +50,9 @@
|
|
|
50
50
|
{
|
|
51
51
|
if (max <= min)
|
|
52
52
|
{
|
|
53
|
-
throw new ArgumentException(
|
|
53
|
+
throw new ArgumentException(
|
|
54
|
+
$"Min {min} cannot be larger-than or equal-to max {max}"
|
|
55
|
+
);
|
|
54
56
|
}
|
|
55
57
|
|
|
56
58
|
uint range = unchecked((uint)(max - min));
|
|
@@ -83,7 +85,9 @@
|
|
|
83
85
|
{
|
|
84
86
|
if (max <= min)
|
|
85
87
|
{
|
|
86
|
-
throw new ArgumentException(
|
|
88
|
+
throw new ArgumentException(
|
|
89
|
+
$"Min {min} cannot be larger-than or equal-to max {max}"
|
|
90
|
+
);
|
|
87
91
|
}
|
|
88
92
|
|
|
89
93
|
return min + NextUint(max - min);
|
|
@@ -147,8 +151,7 @@
|
|
|
147
151
|
do
|
|
148
152
|
{
|
|
149
153
|
withinRange = NextLong();
|
|
150
|
-
}
|
|
151
|
-
while (withinRange < 0 || max <= withinRange);
|
|
154
|
+
} while (withinRange < 0 || max <= withinRange);
|
|
152
155
|
return withinRange;
|
|
153
156
|
}
|
|
154
157
|
|
|
@@ -156,7 +159,9 @@
|
|
|
156
159
|
{
|
|
157
160
|
if (max <= min)
|
|
158
161
|
{
|
|
159
|
-
throw new ArgumentException(
|
|
162
|
+
throw new ArgumentException(
|
|
163
|
+
$"Min {min} cannot be larger-than or equal-to Max {max}"
|
|
164
|
+
);
|
|
160
165
|
}
|
|
161
166
|
|
|
162
167
|
return min + NextLong(max - min);
|
|
@@ -176,7 +181,9 @@
|
|
|
176
181
|
{
|
|
177
182
|
if (max <= min)
|
|
178
183
|
{
|
|
179
|
-
throw new ArgumentException(
|
|
184
|
+
throw new ArgumentException(
|
|
185
|
+
$"Min {min} cannot be larger-than or equal-to max {max}"
|
|
186
|
+
);
|
|
180
187
|
}
|
|
181
188
|
|
|
182
189
|
return unchecked((ulong)NextLong(unchecked((long)min), unchecked((long)max)));
|
|
@@ -227,8 +234,7 @@
|
|
|
227
234
|
do
|
|
228
235
|
{
|
|
229
236
|
value = NextUint() * MagicDouble;
|
|
230
|
-
}
|
|
231
|
-
while (value < 0 || 1 <= value);
|
|
237
|
+
} while (value < 0 || 1 <= value);
|
|
232
238
|
|
|
233
239
|
return value;
|
|
234
240
|
}
|
|
@@ -247,7 +253,9 @@
|
|
|
247
253
|
{
|
|
248
254
|
if (max <= min)
|
|
249
255
|
{
|
|
250
|
-
throw new ArgumentException(
|
|
256
|
+
throw new ArgumentException(
|
|
257
|
+
$"Min {min} cannot be larger-than or equal-to max {max}"
|
|
258
|
+
);
|
|
251
259
|
}
|
|
252
260
|
|
|
253
261
|
double range = max - min;
|
|
@@ -277,8 +285,7 @@
|
|
|
277
285
|
x = 2 * NextDouble() - 1;
|
|
278
286
|
y = 2 * NextDouble() - 1;
|
|
279
287
|
square = x * x + y * y;
|
|
280
|
-
}
|
|
281
|
-
while (square > 1 || square == 0);
|
|
288
|
+
} while (square > 1 || square == 0);
|
|
282
289
|
|
|
283
290
|
double fac = Math.Sqrt(-2 * Math.Log(square) / square);
|
|
284
291
|
_cachedGaussian = x * fac;
|
|
@@ -292,8 +299,7 @@
|
|
|
292
299
|
{
|
|
293
300
|
uint floatAsInt = NextUint();
|
|
294
301
|
value = (floatAsInt >> 8) * MagicFloat;
|
|
295
|
-
}
|
|
296
|
-
while (value < 0 || 1 <= value);
|
|
302
|
+
} while (value < 0 || 1 <= value);
|
|
297
303
|
|
|
298
304
|
return value;
|
|
299
305
|
}
|
|
@@ -312,7 +318,9 @@
|
|
|
312
318
|
{
|
|
313
319
|
if (max <= min)
|
|
314
320
|
{
|
|
315
|
-
throw new ArgumentException(
|
|
321
|
+
throw new ArgumentException(
|
|
322
|
+
$"Min {min} cannot be larger-than or equal-to max {max}"
|
|
323
|
+
);
|
|
316
324
|
}
|
|
317
325
|
|
|
318
326
|
return min + NextFloat(max - min);
|
|
@@ -397,7 +405,8 @@
|
|
|
397
405
|
}
|
|
398
406
|
}
|
|
399
407
|
|
|
400
|
-
public T Next<T>()
|
|
408
|
+
public T Next<T>()
|
|
409
|
+
where T : struct, Enum
|
|
401
410
|
{
|
|
402
411
|
Type enumType = typeof(T);
|
|
403
412
|
T[] enumValues;
|
|
@@ -413,7 +422,8 @@
|
|
|
413
422
|
return RandomOf(enumValues);
|
|
414
423
|
}
|
|
415
424
|
|
|
416
|
-
public T NextCachedEnum<T>()
|
|
425
|
+
public T NextCachedEnum<T>()
|
|
426
|
+
where T : struct, Enum
|
|
417
427
|
{
|
|
418
428
|
Type enumType = typeof(T);
|
|
419
429
|
T[] enumValues = (T[])EnumTypeCache.GetOrAdd(enumType, Enum.GetValues);
|
|
@@ -511,7 +521,11 @@
|
|
|
511
521
|
{
|
|
512
522
|
// Returns a value between 0f and 1f based on noiseMap value
|
|
513
523
|
// minNoiseHeight being 0f, and maxNoiseHeight being 1f
|
|
514
|
-
noiseMap[x, y] = Mathf.InverseLerp(
|
|
524
|
+
noiseMap[x, y] = Mathf.InverseLerp(
|
|
525
|
+
minNoiseHeight,
|
|
526
|
+
maxNoiseHeight,
|
|
527
|
+
noiseMap[x, y]
|
|
528
|
+
);
|
|
515
529
|
}
|
|
516
530
|
}
|
|
517
531
|
return noiseMap;
|
|
@@ -534,4 +548,4 @@
|
|
|
534
548
|
|
|
535
549
|
public abstract IRandom Copy();
|
|
536
550
|
}
|
|
537
|
-
}
|
|
551
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: 7a01d87ed7d46ae439a1ad70cd477704
|
|
3
|
-
MonoImporter:
|
|
4
|
-
externalObjects: {}
|
|
5
|
-
serializedVersion: 2
|
|
6
|
-
defaultReferences: []
|
|
7
|
-
executionOrder: 0
|
|
8
|
-
icon: {instanceID: 0}
|
|
9
|
-
userData:
|
|
10
|
-
assetBundleName:
|
|
11
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: 7a01d87ed7d46ae439a1ad70cd477704
|
|
3
|
+
MonoImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
defaultReferences: []
|
|
7
|
+
executionOrder: 0
|
|
8
|
+
icon: {instanceID: 0}
|
|
9
|
+
userData:
|
|
10
|
+
assetBundleName:
|
|
11
|
+
assetBundleVariant:
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
namespace UnityHelpers.Core.Random
|
|
2
|
+
{
|
|
3
|
+
using System;
|
|
4
|
+
using System.Runtime.Serialization;
|
|
5
|
+
using System.Text.Json.Serialization;
|
|
6
|
+
|
|
7
|
+
[Serializable]
|
|
8
|
+
[DataContract]
|
|
9
|
+
public sealed class DotNetRandom : AbstractRandom
|
|
10
|
+
{
|
|
11
|
+
public override RandomState InternalState =>
|
|
12
|
+
new RandomState(unchecked((ulong)_seed), state2: _numberGenerated);
|
|
13
|
+
|
|
14
|
+
private ulong _numberGenerated;
|
|
15
|
+
private int _seed;
|
|
16
|
+
private Random _random;
|
|
17
|
+
|
|
18
|
+
public DotNetRandom()
|
|
19
|
+
: this(Guid.NewGuid()) { }
|
|
20
|
+
|
|
21
|
+
public DotNetRandom(Guid guid)
|
|
22
|
+
{
|
|
23
|
+
_seed = guid.GetHashCode();
|
|
24
|
+
_random = new Random(_seed);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
[JsonConstructor]
|
|
28
|
+
public DotNetRandom(RandomState internalState)
|
|
29
|
+
{
|
|
30
|
+
_seed = unchecked((int)internalState.State1);
|
|
31
|
+
_random = new Random(_seed);
|
|
32
|
+
_numberGenerated = 0;
|
|
33
|
+
ulong generationCount = internalState.State2;
|
|
34
|
+
|
|
35
|
+
while (_numberGenerated < generationCount)
|
|
36
|
+
{
|
|
37
|
+
_ = NextUint();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public override uint NextUint()
|
|
42
|
+
{
|
|
43
|
+
++_numberGenerated;
|
|
44
|
+
return unchecked((uint)_random.Next(int.MinValue, int.MaxValue));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public override IRandom Copy()
|
|
48
|
+
{
|
|
49
|
+
return new DotNetRandom(InternalState);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: ddc39031f4659de4bbdd61deab3d299a
|
|
3
|
-
MonoImporter:
|
|
4
|
-
externalObjects: {}
|
|
5
|
-
serializedVersion: 2
|
|
6
|
-
defaultReferences: []
|
|
7
|
-
executionOrder: 0
|
|
8
|
-
icon: {instanceID: 0}
|
|
9
|
-
userData:
|
|
10
|
-
assetBundleName:
|
|
11
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: ddc39031f4659de4bbdd61deab3d299a
|
|
3
|
+
MonoImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
defaultReferences: []
|
|
7
|
+
executionOrder: 0
|
|
8
|
+
icon: {instanceID: 0}
|
|
9
|
+
userData:
|
|
10
|
+
assetBundleName:
|
|
11
|
+
assetBundleVariant:
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: 738be60c0f0a5ad428b38b79c266f408
|
|
3
|
-
MonoImporter:
|
|
4
|
-
externalObjects: {}
|
|
5
|
-
serializedVersion: 2
|
|
6
|
-
defaultReferences: []
|
|
7
|
-
executionOrder: 0
|
|
8
|
-
icon: {instanceID: 0}
|
|
9
|
-
userData:
|
|
10
|
-
assetBundleName:
|
|
11
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: 738be60c0f0a5ad428b38b79c266f408
|
|
3
|
+
MonoImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
defaultReferences: []
|
|
7
|
+
executionOrder: 0
|
|
8
|
+
icon: {instanceID: 0}
|
|
9
|
+
userData:
|
|
10
|
+
assetBundleName:
|
|
11
|
+
assetBundleVariant:
|