com.wallstop-studios.unity-helpers 2.0.0-rc04 → 2.0.0-rc05

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.
Files changed (98) hide show
  1. package/CHANGELOG.md.meta +7 -7
  2. package/Editor/AnimationEventEditor.cs.meta +11 -11
  3. package/Editor.meta +8 -8
  4. package/LICENSE.md.meta +7 -7
  5. package/README.md.meta +7 -7
  6. package/Runtime/Core/Attributes/AnimationEventAttribute.cs.meta +11 -11
  7. package/Runtime/Core/Attributes/ChildComponentAttribute.cs.meta +11 -11
  8. package/Runtime/Core/Attributes/KSerializableAttribute.cs.meta +11 -11
  9. package/Runtime/Core/Attributes/NotNullAttribute.cs.meta +11 -11
  10. package/Runtime/Core/Attributes/ParentComponent.cs.meta +11 -11
  11. package/Runtime/Core/Attributes/ReadOnlyAttribute.cs.meta +11 -11
  12. package/Runtime/Core/Attributes/RelationalComponentExtensions.cs.meta +11 -11
  13. package/Runtime/Core/DataStructure/Adapters/FastVector2Int.cs.meta +11 -11
  14. package/Runtime/Core/DataStructure/Adapters/FastVector3Int.cs.meta +11 -11
  15. package/Runtime/Core/DataStructure/Adapters/KGuid.cs.meta +11 -11
  16. package/Runtime/Core/DataStructure/Adapters/KVector2.cs.meta +11 -11
  17. package/Runtime/Core/DataStructure/Adapters.meta +8 -8
  18. package/Runtime/Core/DataStructure/Circle.cs.meta +11 -11
  19. package/Runtime/Core/DataStructure/CyclicBuffer.cs.meta +11 -11
  20. package/Runtime/Core/DataStructure/QuadTree.cs.meta +11 -11
  21. package/Runtime/Core/DataStructure/StringWrapper.cs.meta +11 -11
  22. package/Runtime/Core/DataStructure/TimedCache.cs.meta +11 -11
  23. package/Runtime/Core/DataStructure.meta +8 -8
  24. package/Runtime/Core/Extension/AnimatorExtensions.cs.meta +11 -11
  25. package/Runtime/Core/Extension/CircleExtensions.cs.meta +11 -11
  26. package/Runtime/Core/Extension/ColorExtensions.cs.meta +11 -11
  27. package/Runtime/Core/Extension/DictionaryExtensions.cs.meta +11 -11
  28. package/Runtime/Core/Extension/DirectionExtensions.cs.meta +11 -11
  29. package/Runtime/Core/Extension/HashSetExtensions.cs.meta +11 -11
  30. package/Runtime/Core/Extension/IEnumerableExtensions.cs.meta +11 -11
  31. package/Runtime/Core/Extension/IListExtensions.cs.meta +11 -11
  32. package/Runtime/Core/Extension/LoggingExtensions.cs.meta +11 -11
  33. package/Runtime/Core/Extension/RandomExtensions.cs.meta +11 -11
  34. package/Runtime/Core/Extension/StringExtensions.cs.meta +11 -11
  35. package/Runtime/Core/Extension/UnityExtensions.cs.meta +11 -11
  36. package/Runtime/Core/Extension.meta +8 -8
  37. package/Runtime/Core/Helper/Enumerables.cs.meta +11 -11
  38. package/Runtime/Core/Helper/Geometry.cs.meta +11 -11
  39. package/Runtime/Core/Helper/LifetimeHelpers.cs.meta +11 -11
  40. package/Runtime/Core/Helper/Objects.cs.meta +11 -11
  41. package/Runtime/Core/Helper/WallMath.cs.meta +11 -11
  42. package/Runtime/Core/Helper.meta +8 -8
  43. package/Runtime/Core/Math/Line.cs.meta +11 -11
  44. package/Runtime/Core/Math/Parabola.cs.meta +11 -11
  45. package/Runtime/Core/Math/Range.cs.meta +11 -11
  46. package/Runtime/Core/Math.meta +8 -8
  47. package/Runtime/Core/Model/Direction.cs.meta +11 -11
  48. package/Runtime/Core/Model.meta +8 -8
  49. package/Runtime/Core/OneOf/FastOneOf.cs.meta +11 -11
  50. package/Runtime/Core/OneOf/None.cs.meta +11 -11
  51. package/Runtime/Core/OneOf.meta +8 -8
  52. package/Runtime/Core/Random/AbstractRandom.cs.meta +11 -11
  53. package/Runtime/Core/Random/DotNetRandom.cs +54 -0
  54. package/Runtime/Core/Random/DotNetRandom.cs.meta +3 -0
  55. package/Runtime/Core/Random/IRandom.cs.meta +11 -11
  56. package/Runtime/Core/Random/NativePcgRandom.cs.meta +11 -11
  57. package/Runtime/Core/Random/PcgRandom.cs +25 -22
  58. package/Runtime/Core/Random/PcgRandom.cs.meta +11 -11
  59. package/Runtime/Core/Random/RandomState.cs +13 -2
  60. package/Runtime/Core/Random/RandomState.cs.meta +11 -11
  61. package/Runtime/Core/Random/SquirrelRandom.cs +12 -7
  62. package/Runtime/Core/Random/SquirrelRandom.cs.meta +11 -11
  63. package/Runtime/Core/Random/SystemRandom.cs +15 -9
  64. package/Runtime/Core/Random/SystemRandom.cs.meta +11 -11
  65. package/Runtime/Core/Random/ThreadLocalRandom.cs.meta +11 -11
  66. package/Runtime/Core/Random/UnityRandom.cs +39 -4
  67. package/Runtime/Core/Random/WyRandom.cs +123 -0
  68. package/Runtime/Core/Random/WyRandom.cs.meta +3 -0
  69. package/Runtime/Core/Random/XorShiftRandom.cs +8 -4
  70. package/Runtime/Core/Random.meta +8 -8
  71. package/Runtime/Core/Serialization/JsonConverters/Vector2Converter.cs.meta +11 -11
  72. package/Runtime/Core/Serialization/JsonConverters/Vector3Converter.cs.meta +11 -11
  73. package/Runtime/Core/Serialization/JsonConverters.meta +8 -8
  74. package/Runtime/Core/Serialization/Serializer.cs.meta +11 -11
  75. package/Runtime/Core/Serialization.meta +8 -8
  76. package/Runtime/Core/Threading/SingleThreadedThreadPool.cs.meta +11 -11
  77. package/Runtime/Core/Threading.meta +8 -8
  78. package/Runtime/Core.meta +8 -8
  79. package/Runtime/Protobuf-Net.meta +8 -8
  80. package/Runtime/Utils/AnimationEventEqualityComparer.cs.meta +11 -11
  81. package/Runtime/Utils/AnimatorEnumStateMachine.cs.meta +11 -11
  82. package/Runtime/Utils/Buffers.cs.meta +11 -11
  83. package/Runtime/Utils/CircleLineRenderer.cs.meta +11 -11
  84. package/Runtime/Utils/Oscillator.cs.meta +11 -11
  85. package/Runtime/Utils/SetTextureImportData.cs.meta +11 -11
  86. package/Runtime/Utils.meta +8 -8
  87. package/Runtime/WallstopStudios.UnityHelpers.asmdef.meta +7 -7
  88. package/Runtime.meta +8 -8
  89. package/Tests/Runtime/Performance/RandomPerformanceTests.cs +18 -13
  90. package/Tests/Runtime/Random/DotNetRandomTests.cs +9 -0
  91. package/Tests/Runtime/Random/DotNetRandomTests.cs.meta +3 -0
  92. package/Tests/Runtime/Random/RandomTestBase.cs +69 -15
  93. package/Tests/Runtime/Random/WyRandomTests.cs +9 -0
  94. package/Tests/Runtime/Random/WyRandomTests.cs.meta +3 -0
  95. package/Tests.meta +8 -8
  96. package/Third Party Notices.md.meta +7 -7
  97. package/package.json +1 -1
  98. package/package.json.meta +7 -7
@@ -1,8 +1,8 @@
1
- fileFormatVersion: 2
2
- guid: f587675350531c74d881f05c4ef25001
3
- folderAsset: yes
4
- DefaultImporter:
5
- externalObjects: {}
6
- userData:
7
- assetBundleName:
8
- assetBundleVariant:
1
+ fileFormatVersion: 2
2
+ guid: f587675350531c74d881f05c4ef25001
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
@@ -1,11 +1,11 @@
1
- fileFormatVersion: 2
2
- guid: e3a5dbeacede7e84ba9bdd7a37267f8a
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: e3a5dbeacede7e84ba9bdd7a37267f8a
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -1,8 +1,8 @@
1
- fileFormatVersion: 2
2
- guid: a5624b5006f75b146a68b87ffcbcb64e
3
- folderAsset: yes
4
- DefaultImporter:
5
- externalObjects: {}
6
- userData:
7
- assetBundleName:
8
- assetBundleVariant:
1
+ fileFormatVersion: 2
2
+ guid: a5624b5006f75b146a68b87ffcbcb64e
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
@@ -1,11 +1,11 @@
1
- fileFormatVersion: 2
2
- guid: 6091a7935c3d1df438224d058389dc39
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: 6091a7935c3d1df438224d058389dc39
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -1,8 +1,8 @@
1
- fileFormatVersion: 2
2
- guid: 21fb761f52e33444ba9b56e6687093f5
3
- folderAsset: yes
4
- DefaultImporter:
5
- externalObjects: {}
6
- userData:
7
- assetBundleName:
8
- assetBundleVariant:
1
+ fileFormatVersion: 2
2
+ guid: 21fb761f52e33444ba9b56e6687093f5
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
package/Runtime/Core.meta CHANGED
@@ -1,8 +1,8 @@
1
- fileFormatVersion: 2
2
- guid: 7198976a47786b24eb8df722066344b5
3
- folderAsset: yes
4
- DefaultImporter:
5
- externalObjects: {}
6
- userData:
7
- assetBundleName:
8
- assetBundleVariant:
1
+ fileFormatVersion: 2
2
+ guid: 7198976a47786b24eb8df722066344b5
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
@@ -1,8 +1,8 @@
1
- fileFormatVersion: 2
2
- guid: 0073112e88bcac943986f84e475a287f
3
- folderAsset: yes
4
- DefaultImporter:
5
- externalObjects: {}
6
- userData:
7
- assetBundleName:
8
- assetBundleVariant:
1
+ fileFormatVersion: 2
2
+ guid: 0073112e88bcac943986f84e475a287f
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
@@ -1,11 +1,11 @@
1
- fileFormatVersion: 2
2
- guid: 5723e1a7cd396dd46850faa4ba007aaf
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: 5723e1a7cd396dd46850faa4ba007aaf
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: 79f211d11bdd01648804f772c64c9726
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: 79f211d11bdd01648804f772c64c9726
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: 0351cf6d1c040c84fa9cbe195ab5508e
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: 0351cf6d1c040c84fa9cbe195ab5508e
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: 1d0268c3b20fd1b4a90000e64b66a97b
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: 1d0268c3b20fd1b4a90000e64b66a97b
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: f143adfc6e1409a429bba016d8f2bbe3
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: f143adfc6e1409a429bba016d8f2bbe3
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: 88a78536726a47a438d250cb8206ce26
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: 88a78536726a47a438d250cb8206ce26
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -1,8 +1,8 @@
1
- fileFormatVersion: 2
2
- guid: 21a94927e8953294aa5277276d6a7bfd
3
- folderAsset: yes
4
- DefaultImporter:
5
- externalObjects: {}
6
- userData:
7
- assetBundleName:
8
- assetBundleVariant:
1
+ fileFormatVersion: 2
2
+ guid: 21a94927e8953294aa5277276d6a7bfd
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
@@ -1,7 +1,7 @@
1
- fileFormatVersion: 2
2
- guid: 63a0f107903545b4fae68b24d4dd4b41
3
- AssemblyDefinitionImporter:
4
- externalObjects: {}
5
- userData:
6
- assetBundleName:
7
- assetBundleVariant:
1
+ fileFormatVersion: 2
2
+ guid: 63a0f107903545b4fae68b24d4dd4b41
3
+ AssemblyDefinitionImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
package/Runtime.meta CHANGED
@@ -1,8 +1,8 @@
1
- fileFormatVersion: 2
2
- guid: 4ab0b5c03f18e0845b8a5571f9704c0a
3
- folderAsset: yes
4
- DefaultImporter:
5
- externalObjects: {}
6
- userData:
7
- assetBundleName:
8
- assetBundleVariant:
1
+ fileFormatVersion: 2
2
+ guid: 4ab0b5c03f18e0845b8a5571f9704c0a
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
@@ -10,28 +10,34 @@
10
10
  [Test]
11
11
  public void Benchmark()
12
12
  {
13
- TimeSpan timeout = TimeSpan.FromSeconds(1);
13
+ TimeSpan timeout = TimeSpan.FromSeconds(1.125);
14
14
 
15
15
  UnityEngine.Debug.Log($"| Random | Next | NextFloat | NextDouble |");
16
16
  UnityEngine.Debug.Log($"| ------ | ---- | --------- | ---------- |");
17
-
17
+
18
18
  RunTest(new PcgRandom(), timeout);
19
19
  RunTest(new SystemRandom(), timeout);
20
20
  RunTest(new SquirrelRandom(), timeout);
21
21
  RunTest(new XorShiftRandom(), timeout);
22
+ RunTest(new DotNetRandom(), timeout);
23
+ RunTest(new WyRandom(), timeout);
22
24
  }
23
25
 
24
- private void RunTest<T>(T random, TimeSpan timeout) where T : IRandom
26
+ private static void RunTest<T>(T random, TimeSpan timeout)
27
+ where T : IRandom
25
28
  {
26
29
  int nextInt = RunNext(timeout, random);
27
30
  int nextFloat = RunNextFloat(timeout, random);
28
31
  int nextDouble = RunNextDouble(timeout, random);
29
32
 
30
- UnityEngine.Debug.Log($"| {random.GetType().Name} | {(nextInt / timeout.TotalSeconds):N0} | {(nextFloat / timeout.TotalSeconds):N0} | {(nextDouble / timeout.TotalSeconds):N0} |");
33
+ UnityEngine.Debug.Log(
34
+ $"| {random.GetType().Name} | {(nextInt / timeout.TotalSeconds):N0} | {(nextFloat / timeout.TotalSeconds):N0} | {(nextDouble / timeout.TotalSeconds):N0} |"
35
+ );
31
36
  }
32
37
 
33
38
  // Copy-pasta'd for maximum speed
34
- private int RunNext<T>(TimeSpan timeout, T random) where T : IRandom
39
+ private static int RunNext<T>(TimeSpan timeout, T random)
40
+ where T : IRandom
35
41
  {
36
42
  int count = 0;
37
43
  Stopwatch timer = Stopwatch.StartNew();
@@ -39,13 +45,13 @@
39
45
  {
40
46
  _ = random.Next();
41
47
  ++count;
42
- }
43
- while (timer.Elapsed < timeout);
48
+ } while (timer.Elapsed < timeout);
44
49
 
45
50
  return count;
46
51
  }
47
52
 
48
- private int RunNextFloat<T>(TimeSpan timeout, T random) where T : IRandom
53
+ private static int RunNextFloat<T>(TimeSpan timeout, T random)
54
+ where T : IRandom
49
55
  {
50
56
  int count = 0;
51
57
  Stopwatch timer = Stopwatch.StartNew();
@@ -53,13 +59,13 @@
53
59
  {
54
60
  _ = random.NextFloat();
55
61
  ++count;
56
- }
57
- while (timer.Elapsed < timeout);
62
+ } while (timer.Elapsed < timeout);
58
63
 
59
64
  return count;
60
65
  }
61
66
 
62
- private int RunNextDouble<T>(TimeSpan timeout, T random) where T : IRandom
67
+ private static int RunNextDouble<T>(TimeSpan timeout, T random)
68
+ where T : IRandom
63
69
  {
64
70
  int count = 0;
65
71
  Stopwatch timer = Stopwatch.StartNew();
@@ -67,8 +73,7 @@
67
73
  {
68
74
  _ = random.NextDouble();
69
75
  ++count;
70
- }
71
- while (timer.Elapsed < timeout);
76
+ } while (timer.Elapsed < timeout);
72
77
 
73
78
  return count;
74
79
  }
@@ -0,0 +1,9 @@
1
+ namespace UnityHelpers.Tests.Random
2
+ {
3
+ using Core.Random;
4
+
5
+ public sealed class DotNetRandomTests : RandomTestBase
6
+ {
7
+ protected override IRandom NewRandom() => new DotNetRandom();
8
+ }
9
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 45efbe46a3704e97b7d86757c8528a5c
3
+ timeCreated: 1732482168
@@ -8,9 +8,9 @@
8
8
 
9
9
  public abstract class RandomTestBase
10
10
  {
11
- protected const int SampleCount = 10_000_000;
11
+ private const int SampleCount = 12_500_000;
12
12
 
13
- protected readonly int[] _samples = new int[1_000];
13
+ private readonly int[] _samples = new int[1_000];
14
14
 
15
15
  protected abstract IRandom NewRandom();
16
16
 
@@ -48,22 +48,37 @@
48
48
  public void Byte()
49
49
  {
50
50
  TestAndVerify(
51
- random => random.NextByte(0, (byte)(_samples.Length < byte.MaxValue ? _samples.Length : byte.MaxValue)),
52
- byte.MaxValue);
51
+ random =>
52
+ random.NextByte(
53
+ 0,
54
+ (byte)(_samples.Length < byte.MaxValue ? _samples.Length : byte.MaxValue)
55
+ ),
56
+ byte.MaxValue
57
+ );
53
58
  }
54
59
 
55
60
  [Test]
56
61
  public void Float()
57
62
  {
58
- TestAndVerify(
59
- random => Math.Clamp((int)Math.Floor(random.NextFloat(0, _samples.Length)), 0, _samples.Length - 1));
63
+ TestAndVerify(random =>
64
+ Math.Clamp(
65
+ (int)Math.Floor(random.NextFloat(0, _samples.Length)),
66
+ 0,
67
+ _samples.Length - 1
68
+ )
69
+ );
60
70
  }
61
71
 
62
72
  [Test]
63
73
  public void Double()
64
74
  {
65
- TestAndVerify(
66
- random => Math.Clamp((int)Math.Floor(random.NextDouble(0, _samples.Length)), 0, _samples.Length - 1));
75
+ TestAndVerify(random =>
76
+ Math.Clamp(
77
+ (int)Math.Floor(random.NextDouble(0, _samples.Length)),
78
+ 0,
79
+ _samples.Length - 1
80
+ )
81
+ );
67
82
  }
68
83
 
69
84
  [Test]
@@ -78,7 +93,37 @@
78
93
  TestAndVerify(random => (int)random.NextUlong(0, (ulong)_samples.Length));
79
94
  }
80
95
 
81
- protected void TestAndVerify(Func<IRandom, int> sample, int? maxLength = null)
96
+ [Test]
97
+ public void Copy()
98
+ {
99
+ const int numGeneratorChecks = 1_000;
100
+ IRandom random1 = NewRandom();
101
+ IRandom random2 = random1.Copy();
102
+ Assert.AreEqual(random1.InternalState, random2.InternalState);
103
+ // UnityRandom has shared state, the below test is not possible for it. We did all we could.
104
+ if (NewRandom() is not UnityRandom)
105
+ {
106
+ for (int i = 0; i < numGeneratorChecks; ++i)
107
+ {
108
+ Assert.AreEqual(random1.Next(), random2.Next());
109
+ Assert.AreEqual(random1.InternalState, random2.InternalState);
110
+ }
111
+ }
112
+
113
+ Assert.AreEqual(random1.InternalState, random2.InternalState);
114
+ IRandom random3 = random1.Copy();
115
+ Assert.AreEqual(random1.InternalState, random3.InternalState);
116
+ if (NewRandom() is not UnityRandom)
117
+ {
118
+ for (int i = 0; i < numGeneratorChecks; ++i)
119
+ {
120
+ Assert.AreEqual(random1.Next(), random3.Next());
121
+ Assert.AreEqual(random1.InternalState, random3.InternalState);
122
+ }
123
+ }
124
+ }
125
+
126
+ private void TestAndVerify(Func<IRandom, int> sample, int? maxLength = null)
82
127
  {
83
128
  IRandom random = NewRandom();
84
129
  for (int i = 0; i < SampleCount; ++i)
@@ -114,12 +159,21 @@
114
159
  }
115
160
 
116
161
  Assert.AreEqual(
117
- 0, zeroCountIndexes.Count, "No samples at {0} indices: [{1}]", zeroCountIndexes.Count,
118
- string.Join(",", zeroCountIndexes));
162
+ 0,
163
+ zeroCountIndexes.Count,
164
+ "No samples at {0} indices: [{1}]",
165
+ zeroCountIndexes.Count,
166
+ string.Join(",", zeroCountIndexes)
167
+ );
119
168
  Assert.AreEqual(
120
- 0, outsideRange.Count, "{0} indexes outside of dev {1:0.00}. Expected: {2:0.00}. Found: [{3}]",
121
- outsideRange.Count, deviationAllowed, average,
122
- string.Join(",", outsideRange.Select(index => _samples[index])));
169
+ 0,
170
+ outsideRange.Count,
171
+ "{0} indexes outside of dev {1:0.00}. Expected: {2:0.00}. Found: [{3}]",
172
+ outsideRange.Count,
173
+ deviationAllowed,
174
+ average,
175
+ string.Join(",", outsideRange.Select(index => _samples[index]))
176
+ );
123
177
  }
124
178
  }
125
- }
179
+ }
@@ -0,0 +1,9 @@
1
+ namespace UnityHelpers.Tests.Random
2
+ {
3
+ using Core.Random;
4
+
5
+ public sealed class WyRandomTests : RandomTestBase
6
+ {
7
+ protected override IRandom NewRandom() => new WyRandom();
8
+ }
9
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 700b0f9e94074d7fb2177d37ff9bcd4f
3
+ timeCreated: 1732481488
package/Tests.meta CHANGED
@@ -1,8 +1,8 @@
1
- fileFormatVersion: 2
2
- guid: 95113a6d0bd1caa45a97f7f4db1e7c0a
3
- folderAsset: yes
4
- DefaultImporter:
5
- externalObjects: {}
6
- userData:
7
- assetBundleName:
8
- assetBundleVariant:
1
+ fileFormatVersion: 2
2
+ guid: 95113a6d0bd1caa45a97f7f4db1e7c0a
3
+ folderAsset: yes
4
+ DefaultImporter:
5
+ externalObjects: {}
6
+ userData:
7
+ assetBundleName:
8
+ assetBundleVariant:
@@ -1,7 +1,7 @@
1
- fileFormatVersion: 2
2
- guid: 4908409161853e24bbbd3b2522b0fcc2
3
- TextScriptImporter:
4
- externalObjects: {}
5
- userData:
6
- assetBundleName:
7
- assetBundleVariant:
1
+ fileFormatVersion: 2
2
+ guid: 4908409161853e24bbbd3b2522b0fcc2
3
+ TextScriptImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.wallstop-studios.unity-helpers",
3
- "version": "2.0.0-rc04",
3
+ "version": "2.0.0-rc05",
4
4
  "displayName": "Unity Helpers",
5
5
  "description": "Various Unity Helper Library",
6
6
  "dependencies": {},
package/package.json.meta CHANGED
@@ -1,7 +1,7 @@
1
- fileFormatVersion: 2
2
- guid: 37c8a4d958841ed4b9cf38ef3b01ea92
3
- PackageManifestImporter:
4
- externalObjects: {}
5
- userData:
6
- assetBundleName:
7
- assetBundleVariant:
1
+ fileFormatVersion: 2
2
+ guid: 37c8a4d958841ed4b9cf38ef3b01ea92
3
+ PackageManifestImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant: