com.wallstop-studios.unity-helpers 2.0.0-rc05 → 2.0.0-rc07
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/Runtime/Core/DataStructure/TimedCache.cs +4 -3
- package/Runtime/Core/Extension/IListExtensions.cs +2 -2
- package/Runtime/Core/Extension/RandomExtensions.cs +23 -4
- package/Runtime/Core/Extension/UnityExtensions.cs +278 -90
- package/Runtime/Core/Helper/ArrayConverter.cs +39 -0
- package/Runtime/Core/Helper/ArrayConverter.cs.meta +3 -0
- package/Runtime/Core/Helper/Helpers.cs +133 -563
- package/Runtime/Core/Helper/Partials/LogHelpers.cs +13 -0
- package/Runtime/Core/Helper/Partials/LogHelpers.cs.meta +3 -0
- package/Runtime/Core/Helper/Partials/MathHelpers.cs +30 -0
- package/Runtime/Core/Helper/Partials/MathHelpers.cs.meta +3 -0
- package/Runtime/Core/Helper/Partials/ObjectHelpers.cs +388 -0
- package/Runtime/Core/Helper/Partials/ObjectHelpers.cs.meta +3 -0
- package/Runtime/Core/Helper/Partials/TransformHelpers.cs +167 -0
- package/Runtime/Core/Helper/Partials/TransformHelpers.cs.meta +3 -0
- package/Runtime/Core/Helper/Partials.meta +3 -0
- package/Runtime/Core/Helper/WallMath.cs +85 -22
- package/Runtime/Core/Random/AbstractRandom.cs +208 -162
- package/Runtime/Core/Random/DotNetRandom.cs +3 -5
- package/Runtime/Core/Random/PRNG.cs +7 -0
- package/Runtime/Core/Random/PRNG.cs.meta +3 -0
- package/Runtime/Core/Random/PcgRandom.cs +4 -6
- package/Runtime/Core/Random/RandomState.cs +31 -3
- package/Runtime/Core/Random/SquirrelRandom.cs +12 -15
- package/Runtime/Core/Random/SystemRandom.cs +92 -46
- package/Runtime/Core/Random/ThreadLocalRandom.cs +2 -1
- package/Runtime/Core/Random/UnityRandom.cs +2 -4
- package/Runtime/Core/Random/WyRandom.cs +2 -4
- package/Runtime/Core/Random/XorShiftRandom.cs +3 -5
- package/Runtime/Core/Serialization/Serializer.cs +36 -14
- package/Runtime/Utils/CircleLineRenderer.cs +17 -5
- 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/ObjectHelperTests.cs +402 -0
- package/Tests/Runtime/Helper/ObjectHelperTests.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 +58 -3
- package/Tests/Runtime/Performance/SpatialTreePerformanceTest.cs +47 -34
- package/Tests/Runtime/Random/RandomTestBase.cs +284 -9
- package/Tests/Runtime/Random/SquirrelRandomTests.cs +5 -0
- package/Tests/Runtime/Serialization/JsonSerializationTest.cs +24 -11
- package/Tests/Runtime/Utils/SpriteRendererMetadataTests.cs +21 -17
- package/package.json +1 -1
|
@@ -28,16 +28,17 @@
|
|
|
28
28
|
|
|
29
29
|
public TimedCache(Func<T> valueProducer, float cacheTtl, bool useJitter = false)
|
|
30
30
|
{
|
|
31
|
-
_valueProducer =
|
|
31
|
+
_valueProducer =
|
|
32
|
+
valueProducer ?? throw new ArgumentNullException(nameof(valueProducer));
|
|
32
33
|
if (cacheTtl < 0)
|
|
33
34
|
{
|
|
34
35
|
throw new ArgumentException(nameof(cacheTtl));
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
_cacheTtl = cacheTtl;
|
|
38
|
-
if (useJitter && 0 <_cacheTtl)
|
|
39
|
+
if (useJitter && 0 < _cacheTtl)
|
|
39
40
|
{
|
|
40
|
-
_cacheTtl +=
|
|
41
|
+
_cacheTtl += PRNG.Instance.NextFloat(_cacheTtl);
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
namespace UnityHelpers.Core.Extension
|
|
2
2
|
{
|
|
3
|
-
using Random;
|
|
4
3
|
using System.Collections.Generic;
|
|
4
|
+
using Random;
|
|
5
5
|
|
|
6
6
|
public static class IListExtensions
|
|
7
7
|
{
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
random ??=
|
|
15
|
+
random ??= PRNG.Instance;
|
|
16
16
|
|
|
17
17
|
int length = list.Count;
|
|
18
18
|
for (int i = 0; i < length - 1; ++i)
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
namespace UnityHelpers.Core.Extension
|
|
2
2
|
{
|
|
3
|
-
using Random;
|
|
4
3
|
using System;
|
|
5
4
|
using System.Collections.Generic;
|
|
6
5
|
using System.Linq;
|
|
6
|
+
using Helper;
|
|
7
|
+
using Random;
|
|
7
8
|
using UnityEngine;
|
|
8
9
|
|
|
9
10
|
public static class RandomExtensions
|
|
@@ -13,7 +14,20 @@
|
|
|
13
14
|
return random.NextVector2(-amplitude, amplitude);
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
public static Vector2
|
|
17
|
+
public static Vector2 NextVector2InRange(
|
|
18
|
+
this IRandom random,
|
|
19
|
+
float range,
|
|
20
|
+
Vector2? origin = null
|
|
21
|
+
)
|
|
22
|
+
{
|
|
23
|
+
return Helpers.GetRandomPointInCircle(origin ?? Vector2.zero, range, random);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public static Vector2 NextVector2(
|
|
27
|
+
this IRandom random,
|
|
28
|
+
float minAmplitude,
|
|
29
|
+
float maxAmplitude
|
|
30
|
+
)
|
|
17
31
|
{
|
|
18
32
|
float x = random.NextFloat(minAmplitude, maxAmplitude);
|
|
19
33
|
float y = random.NextFloat(minAmplitude, maxAmplitude);
|
|
@@ -25,7 +39,11 @@
|
|
|
25
39
|
return random.NextVector3(-amplitude, amplitude);
|
|
26
40
|
}
|
|
27
41
|
|
|
28
|
-
public static Vector3 NextVector3(
|
|
42
|
+
public static Vector3 NextVector3(
|
|
43
|
+
this IRandom random,
|
|
44
|
+
float minAmplitude,
|
|
45
|
+
float maxAmplitude
|
|
46
|
+
)
|
|
29
47
|
{
|
|
30
48
|
float z = random.NextFloat(minAmplitude, maxAmplitude);
|
|
31
49
|
Vector3 result = random.NextVector2(minAmplitude, maxAmplitude);
|
|
@@ -33,7 +51,8 @@
|
|
|
33
51
|
return result;
|
|
34
52
|
}
|
|
35
53
|
|
|
36
|
-
public static T NextEnum<T>(this IRandom random)
|
|
54
|
+
public static T NextEnum<T>(this IRandom random)
|
|
55
|
+
where T : struct
|
|
37
56
|
{
|
|
38
57
|
T[] enumValues = (T[])Enum.GetValues(typeof(T));
|
|
39
58
|
if (enumValues.Length == 0)
|