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.
Files changed (46) hide show
  1. package/Runtime/Core/DataStructure/TimedCache.cs +4 -3
  2. package/Runtime/Core/Extension/IListExtensions.cs +2 -2
  3. package/Runtime/Core/Extension/RandomExtensions.cs +23 -4
  4. package/Runtime/Core/Extension/UnityExtensions.cs +278 -90
  5. package/Runtime/Core/Helper/ArrayConverter.cs +39 -0
  6. package/Runtime/Core/Helper/ArrayConverter.cs.meta +3 -0
  7. package/Runtime/Core/Helper/Helpers.cs +133 -563
  8. package/Runtime/Core/Helper/Partials/LogHelpers.cs +13 -0
  9. package/Runtime/Core/Helper/Partials/LogHelpers.cs.meta +3 -0
  10. package/Runtime/Core/Helper/Partials/MathHelpers.cs +30 -0
  11. package/Runtime/Core/Helper/Partials/MathHelpers.cs.meta +3 -0
  12. package/Runtime/Core/Helper/Partials/ObjectHelpers.cs +388 -0
  13. package/Runtime/Core/Helper/Partials/ObjectHelpers.cs.meta +3 -0
  14. package/Runtime/Core/Helper/Partials/TransformHelpers.cs +167 -0
  15. package/Runtime/Core/Helper/Partials/TransformHelpers.cs.meta +3 -0
  16. package/Runtime/Core/Helper/Partials.meta +3 -0
  17. package/Runtime/Core/Helper/WallMath.cs +85 -22
  18. package/Runtime/Core/Random/AbstractRandom.cs +208 -162
  19. package/Runtime/Core/Random/DotNetRandom.cs +3 -5
  20. package/Runtime/Core/Random/PRNG.cs +7 -0
  21. package/Runtime/Core/Random/PRNG.cs.meta +3 -0
  22. package/Runtime/Core/Random/PcgRandom.cs +4 -6
  23. package/Runtime/Core/Random/RandomState.cs +31 -3
  24. package/Runtime/Core/Random/SquirrelRandom.cs +12 -15
  25. package/Runtime/Core/Random/SystemRandom.cs +92 -46
  26. package/Runtime/Core/Random/ThreadLocalRandom.cs +2 -1
  27. package/Runtime/Core/Random/UnityRandom.cs +2 -4
  28. package/Runtime/Core/Random/WyRandom.cs +2 -4
  29. package/Runtime/Core/Random/XorShiftRandom.cs +3 -5
  30. package/Runtime/Core/Serialization/Serializer.cs +36 -14
  31. package/Runtime/Utils/CircleLineRenderer.cs +17 -5
  32. package/Tests/Runtime/DataStructures/SpatialTreeTests.cs +34 -10
  33. package/Tests/Runtime/Helper/ArrayConverterTests.cs +19 -0
  34. package/Tests/Runtime/Helper/ArrayConverterTests.cs.meta +3 -0
  35. package/Tests/Runtime/Helper/ObjectHelperTests.cs +402 -0
  36. package/Tests/Runtime/Helper/ObjectHelperTests.cs.meta +3 -0
  37. package/Tests/Runtime/Helper/WallMathTests.cs +221 -0
  38. package/Tests/Runtime/Helper/WallMathTests.cs.meta +3 -0
  39. package/Tests/Runtime/Helper.meta +3 -0
  40. package/Tests/Runtime/Performance/RandomPerformanceTests.cs +58 -3
  41. package/Tests/Runtime/Performance/SpatialTreePerformanceTest.cs +47 -34
  42. package/Tests/Runtime/Random/RandomTestBase.cs +284 -9
  43. package/Tests/Runtime/Random/SquirrelRandomTests.cs +5 -0
  44. package/Tests/Runtime/Serialization/JsonSerializationTest.cs +24 -11
  45. package/Tests/Runtime/Utils/SpriteRendererMetadataTests.cs +21 -17
  46. package/package.json +1 -1
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 5041bafe46dc450bb37153e394011636
3
+ timeCreated: 1732564259
@@ -15,8 +15,6 @@
15
15
  IComparable,
16
16
  IComparable<PcgRandom>
17
17
  {
18
- [DataMember(Name = "State")]
19
- [JsonPropertyName("State")]
20
18
  public static IRandom Instance => ThreadLocalRandom<PcgRandom>.Instance;
21
19
 
22
20
  internal readonly ulong _increment;
@@ -34,11 +32,11 @@
34
32
  }
35
33
 
36
34
  [JsonConstructor]
37
- public PcgRandom(RandomState state)
35
+ public PcgRandom(RandomState internalState)
38
36
  {
39
- _state = state.State1;
40
- _increment = state.State2;
41
- _cachedGaussian = state.Gaussian;
37
+ _state = internalState.State1;
38
+ _increment = internalState.State2;
39
+ _cachedGaussian = internalState.Gaussian;
42
40
  }
43
41
 
44
42
  public PcgRandom(ulong increment, ulong state)
@@ -1,16 +1,20 @@
1
1
  namespace UnityHelpers.Core.Random
2
2
  {
3
3
  using System;
4
+ using System.Linq;
5
+ using System.Runtime.Serialization;
4
6
  using System.Text.Json.Serialization;
5
7
  using Extension;
6
8
  using Helper;
7
9
  using ProtoBuf;
8
10
 
9
11
  [Serializable]
12
+ [DataContract]
10
13
  [ProtoContract]
11
14
  public struct RandomState : IEquatable<RandomState>
12
15
  {
13
16
  public ulong State1 => _state1;
17
+
14
18
  public ulong State2 => _state2;
15
19
 
16
20
  public double? Gaussian
@@ -26,6 +30,8 @@
26
30
  }
27
31
  }
28
32
 
33
+ public byte[] Payload => _payload;
34
+
29
35
  [ProtoMember(1)]
30
36
  private ulong _state1;
31
37
 
@@ -38,16 +44,31 @@
38
44
  [ProtoMember(4)]
39
45
  private double _gaussian;
40
46
 
47
+ [ProtoMember(5)]
48
+ private byte[] _payload;
49
+
41
50
  private int _hashCode;
42
51
 
43
52
  [JsonConstructor]
44
- public RandomState(ulong state1, ulong state2 = 0, double? gaussian = null)
53
+ public RandomState(
54
+ ulong state1,
55
+ ulong state2 = 0,
56
+ double? gaussian = null,
57
+ byte[] payload = null
58
+ )
45
59
  {
46
60
  _state1 = state1;
47
61
  _state2 = state2;
48
62
  _hasGaussian = gaussian.HasValue;
49
63
  _gaussian = gaussian ?? 0;
50
- _hashCode = Objects.ValueTypeHashCode(state1, state2, _hasGaussian, _gaussian);
64
+ _payload = payload?.ToArray();
65
+ _hashCode = Objects.ValueTypeHashCode(
66
+ state1,
67
+ state2,
68
+ _hasGaussian,
69
+ _gaussian,
70
+ _payload != null
71
+ );
51
72
  }
52
73
 
53
74
  public RandomState(Guid guid)
@@ -57,7 +78,14 @@
57
78
  _state2 = BitConverter.ToUInt64(guidBytes, sizeof(ulong));
58
79
  _hasGaussian = false;
59
80
  _gaussian = 0;
60
- _hashCode = Objects.ValueTypeHashCode(_state1, _state2, _hasGaussian, _gaussian);
81
+ _payload = null;
82
+ _hashCode = Objects.ValueTypeHashCode(
83
+ _state1,
84
+ _state2,
85
+ _hasGaussian,
86
+ _gaussian,
87
+ _payload != null
88
+ );
61
89
  }
62
90
 
63
91
  [ProtoAfterDeserialization]
@@ -16,8 +16,6 @@
16
16
 
17
17
  public static readonly SquirrelRandom Instance = ThreadLocalRandom<SquirrelRandom>.Instance;
18
18
 
19
- [JsonPropertyName("State")]
20
- [DataMember(Name = "State")]
21
19
  public override RandomState InternalState => new(_position, gaussian: _cachedGaussian);
22
20
 
23
21
  private uint _position;
@@ -31,15 +29,15 @@
31
29
  }
32
30
 
33
31
  [JsonConstructor]
34
- public SquirrelRandom(RandomState randomState)
32
+ public SquirrelRandom(RandomState internalState)
35
33
  {
36
- _position = unchecked((uint)randomState.State1);
37
- _cachedGaussian = randomState.Gaussian;
34
+ _position = unchecked((uint)internalState.State1);
35
+ _cachedGaussian = internalState.Gaussian;
38
36
  }
39
37
 
40
38
  public override uint NextUint()
41
39
  {
42
- return _position = NextUintInternal(_position);
40
+ return NextUintInternal(ref _position);
43
41
  }
44
42
 
45
43
  // Does not advance the RNG
@@ -53,16 +51,15 @@
53
51
  return new SquirrelRandom(InternalState);
54
52
  }
55
53
 
56
- private static uint NextUintInternal(uint seed)
54
+ private static uint NextUintInternal(ref uint seed)
57
55
  {
58
- uint result = seed;
59
- result *= BitNoise1;
60
- result ^= (result >> 8);
61
- result += BitNoise2;
62
- result ^= (result << 8);
63
- result *= BitNoise3;
64
- result ^= (result >> 8);
65
- return result;
56
+ seed *= BitNoise1;
57
+ seed ^= (seed >> 8);
58
+ seed += BitNoise2;
59
+ seed ^= (seed << 8);
60
+ seed *= BitNoise3;
61
+ seed ^= (seed >> 8);
62
+ return seed;
66
63
  }
67
64
 
68
65
  // https://youtu.be/LWFzPP8ZbdU?t=2906
@@ -3,6 +3,7 @@
3
3
  using System;
4
4
  using System.Runtime.Serialization;
5
5
  using System.Text.Json.Serialization;
6
+ using Helper;
6
7
 
7
8
  /// <summary>
8
9
  /// Implementation dependent upon .Net's Random class.
@@ -11,105 +12,150 @@
11
12
  [DataContract]
12
13
  public sealed class SystemRandom : AbstractRandom
13
14
  {
14
- [JsonPropertyName("State")]
15
- [DataMember(Name = "State")]
15
+ private const int HalfwayInt = int.MaxValue / 2;
16
+ private const int SeedArraySize = 56;
17
+ private const int LastSeedIndex = SeedArraySize - 1;
18
+
19
+ public static IRandom Instance => ThreadLocalRandom<SystemRandom>.Instance;
20
+
16
21
  public override RandomState InternalState =>
17
- new(unchecked((ulong)inext), unchecked((ulong)inextp), _cachedGaussian);
22
+ new(
23
+ unchecked((ulong)_inext),
24
+ unchecked((ulong)_inextp),
25
+ _cachedGaussian,
26
+ ArrayConverter.IntArrayToByteArrayBlockCopy(_seedArray)
27
+ );
18
28
 
19
29
  /*
20
30
  Copied from Random.cs source. Apparently it isn't guaranteed to be the
21
- same across platforms and we depend on that.
31
+ same across platforms, a fact which defeats the purpose of these serializable
32
+ randoms.
22
33
  */
23
- private int inext;
24
- private int inextp;
25
- private readonly int[] SeedArray = new int[56];
26
-
27
- public static IRandom Instance => ThreadLocalRandom<SystemRandom>.Instance;
34
+ private int _inext;
35
+ private int _inextp;
36
+ private readonly int[] _seedArray = new int[SeedArraySize];
28
37
 
29
38
  public SystemRandom()
30
- : this(Environment.TickCount) { }
39
+ : this(Guid.NewGuid().GetHashCode()) { }
31
40
 
32
41
  public SystemRandom(int seed)
33
42
  {
34
43
  int num1 = 161803398 - (seed == int.MinValue ? int.MaxValue : Math.Abs(seed));
35
- this.SeedArray[55] = num1;
44
+ _seedArray[LastSeedIndex] = num1;
36
45
  int num2 = 1;
37
- for (int index1 = 1; index1 < 55; ++index1)
46
+ for (int index1 = 1; index1 < LastSeedIndex; ++index1)
38
47
  {
39
- int index2 = 21 * index1 % 55;
40
- this.SeedArray[index2] = num2;
48
+ int index2 = 21 * index1 % LastSeedIndex;
49
+ _seedArray[index2] = num2;
41
50
  num2 = num1 - num2;
42
51
  if (num2 < 0)
52
+ {
43
53
  num2 += int.MaxValue;
44
- num1 = this.SeedArray[index2];
54
+ }
55
+
56
+ num1 = _seedArray[index2];
45
57
  }
46
58
  for (int index3 = 1; index3 < 5; ++index3)
47
59
  {
48
- for (int index4 = 1; index4 < 56; ++index4)
60
+ for (int index4 = 1; index4 < SeedArraySize; ++index4)
49
61
  {
50
- this.SeedArray[index4] -= this.SeedArray[1 + (index4 + 30) % 55];
51
- if (this.SeedArray[index4] < 0)
52
- this.SeedArray[index4] += int.MaxValue;
62
+ int value = _seedArray[index4] -= _seedArray[1 + (index4 + 30) % LastSeedIndex];
63
+ if (value < 0)
64
+ {
65
+ _seedArray[index4] += int.MaxValue;
66
+ }
53
67
  }
54
68
  }
55
- this.inext = 0;
56
- this.inextp = 21;
69
+
70
+ _inext = 0;
71
+ _inextp = 21;
57
72
  }
58
73
 
59
74
  [JsonConstructor]
60
- public SystemRandom(RandomState randomState)
75
+ public SystemRandom(RandomState internalState)
61
76
  {
62
- inext = unchecked((int)randomState.State1);
63
- inextp = unchecked((int)randomState.State2);
64
- _cachedGaussian = randomState.Gaussian;
77
+ unchecked
78
+ {
79
+ _inext = (int)internalState.State1;
80
+ _inextp = (int)internalState.State2;
81
+ }
82
+ _cachedGaussian = internalState.Gaussian;
83
+ _seedArray = ArrayConverter.ByteArrayToIntArrayBlockCopy(internalState.Payload);
65
84
  }
66
85
 
67
- public override uint NextUint()
86
+ public override int Next()
68
87
  {
69
- int inext = this.inext;
70
- int inextp = this.inextp;
88
+ int localINext = _inext;
89
+ int localINextP = _inextp;
71
90
  int index1;
72
- if ((index1 = inext + 1) >= 56)
91
+ if ((index1 = localINext + 1) >= SeedArraySize)
92
+ {
73
93
  index1 = 1;
94
+ }
95
+
74
96
  int index2;
75
- if ((index2 = inextp + 1) >= 56)
97
+ if ((index2 = localINextP + 1) >= SeedArraySize)
98
+ {
76
99
  index2 = 1;
77
- int num = this.SeedArray[index1] - this.SeedArray[index2];
100
+ }
101
+
102
+ int num = _seedArray[index1] - _seedArray[index2];
78
103
  if (num == int.MaxValue)
104
+ {
79
105
  --num;
106
+ }
107
+
80
108
  if (num < 0)
109
+ {
81
110
  num += int.MaxValue;
82
- this.SeedArray[index1] = num;
83
- this.inext = index1;
84
- this.inextp = index2;
85
- return unchecked((uint)num);
111
+ }
112
+
113
+ _seedArray[index1] = num;
114
+ _inext = index1;
115
+ _inextp = index2;
116
+ return num;
117
+ }
118
+
119
+ public override uint NextUint()
120
+ {
121
+ if (NextBool())
122
+ {
123
+ return unchecked((uint)(Next() ^ 0x80000000));
124
+ }
125
+ return unchecked((uint)Next());
126
+ }
127
+
128
+ public override bool NextBool()
129
+ {
130
+ return Next() < HalfwayInt;
86
131
  }
87
132
 
88
133
  public override double NextDouble()
89
134
  {
90
- double generated;
135
+ double random;
91
136
  do
92
137
  {
93
- generated = unchecked((int)NextUint()) * 4.6566128752458E-10;
94
- } while (generated < 0 || 1 <= generated);
138
+ random = Next() / (1.0 * int.MaxValue);
139
+ } while (1.0 <= random);
95
140
 
96
- return generated;
141
+ return random;
97
142
  }
98
143
 
99
144
  public override float NextFloat()
100
145
  {
101
- return (float)NextDouble();
146
+ float random;
147
+ do
148
+ {
149
+ random = Next() * (1f / int.MaxValue);
150
+ } while (1f <= random);
151
+
152
+ return random;
102
153
  }
103
154
 
104
155
  public override IRandom Copy()
105
156
  {
106
157
  SystemRandom copy = new(InternalState);
107
-
108
- for (int i = 0; i < SeedArray.Length; ++i)
109
- {
110
- copy.SeedArray[i] = SeedArray[i];
111
- }
112
-
158
+ Array.Copy(_seedArray, copy._seedArray, _seedArray.Length);
113
159
  return copy;
114
160
  }
115
161
  }
@@ -2,7 +2,8 @@
2
2
  {
3
3
  using System.Threading;
4
4
 
5
- public static class ThreadLocalRandom<T> where T : IRandom, new()
5
+ public static class ThreadLocalRandom<T>
6
+ where T : IRandom, new()
6
7
  {
7
8
  private static readonly ThreadLocal<T> RandomCache = new ThreadLocal<T>(() => new T());
8
9
 
@@ -10,8 +10,6 @@
10
10
  {
11
11
  public static readonly UnityRandom Instance = new();
12
12
 
13
- [JsonPropertyName("State")]
14
- [DataMember(Name = "State")]
15
13
  public override RandomState InternalState
16
14
  {
17
15
  get
@@ -38,11 +36,11 @@
38
36
  }
39
37
 
40
38
  [JsonConstructor]
41
- public UnityRandom(RandomState state)
39
+ public UnityRandom(RandomState internalState)
42
40
  {
43
41
  unchecked
44
42
  {
45
- _seed = state.Gaussian != null ? (int)state.State1 : null;
43
+ _seed = internalState.Gaussian != null ? (int)internalState.State1 : null;
46
44
  }
47
45
  }
48
46
 
@@ -16,8 +16,6 @@
16
16
 
17
17
  public static IRandom Instance => ThreadLocalRandom<WyRandom>.Instance;
18
18
 
19
- [JsonPropertyName("State")]
20
- [DataMember(Name = "State")]
21
19
  public override RandomState InternalState => new RandomState(_state);
22
20
 
23
21
  private ulong _state;
@@ -32,9 +30,9 @@
32
30
  }
33
31
 
34
32
  [JsonConstructor]
35
- public WyRandom(RandomState randomState)
33
+ public WyRandom(RandomState internalState)
36
34
  {
37
- _state = randomState.State1;
35
+ _state = internalState.State1;
38
36
  }
39
37
 
40
38
  public WyRandom(ulong state)
@@ -10,8 +10,6 @@
10
10
  {
11
11
  public static IRandom Instance => ThreadLocalRandom<XorShiftRandom>.Instance;
12
12
 
13
- [JsonPropertyName("State")]
14
- [DataMember(Name = "State")]
15
13
  public override RandomState InternalState => new(_state, 0, _cachedGaussian);
16
14
 
17
15
  private uint _state;
@@ -25,10 +23,10 @@
25
23
  }
26
24
 
27
25
  [JsonConstructor]
28
- public XorShiftRandom(RandomState state)
26
+ public XorShiftRandom(RandomState internalState)
29
27
  {
30
- _state = unchecked((uint)state.State1);
31
- _cachedGaussian = state.Gaussian;
28
+ _state = unchecked((uint)internalState.State1);
29
+ _cachedGaussian = internalState.Gaussian;
32
30
  }
33
31
 
34
32
  public override uint NextUint()
@@ -2,13 +2,13 @@
2
2
  {
3
3
  using System;
4
4
  using System.ComponentModel;
5
- using Extension;
6
- using JsonConverters;
7
5
  using System.IO;
8
6
  using System.Runtime.Serialization.Formatters.Binary;
9
7
  using System.Text;
10
8
  using System.Text.Json;
11
9
  using System.Text.Json.Serialization;
10
+ using Extension;
11
+ using JsonConverters;
12
12
 
13
13
  internal static class SerializerEncoding
14
14
  {
@@ -30,7 +30,7 @@
30
30
  {
31
31
  new JsonStringEnumConverter(),
32
32
  Vector3Converter.Instance,
33
- Vector2Converter.Instance
33
+ Vector2Converter.Instance,
34
34
  },
35
35
  };
36
36
 
@@ -45,7 +45,7 @@
45
45
  {
46
46
  new JsonStringEnumConverter(),
47
47
  Vector3Converter.Instance,
48
- Vector2Converter.Instance
48
+ Vector2Converter.Instance,
49
49
  },
50
50
  WriteIndented = true,
51
51
  };
@@ -70,7 +70,10 @@
70
70
  return ProtoDeserialize<T>(serialized);
71
71
  default:
72
72
  throw new InvalidEnumArgumentException(
73
- nameof(serializationType), (int)serializationType, typeof(SerializationType));
73
+ nameof(serializationType),
74
+ (int)serializationType,
75
+ typeof(SerializationType)
76
+ );
74
77
  }
75
78
  }
76
79
 
@@ -84,7 +87,10 @@
84
87
  return ProtoSerialize(instance);
85
88
  default:
86
89
  throw new InvalidEnumArgumentException(
87
- nameof(serializationType), (int)serializationType, typeof(SerializationType));
90
+ nameof(serializationType),
91
+ (int)serializationType,
92
+ typeof(SerializationType)
93
+ );
88
94
  }
89
95
  }
90
96
 
@@ -123,9 +129,14 @@
123
129
  return memoryStream.ToArray();
124
130
  }
125
131
 
126
- public static T JsonDeserialize<T>(string data)
132
+ public static T JsonDeserialize<T>(string data, Type type = null)
127
133
  {
128
- return JsonSerializer.Deserialize<T>(data, SerializerEncoding.NormalJsonOptions);
134
+ return (T)
135
+ JsonSerializer.Deserialize(
136
+ data,
137
+ type ?? typeof(T),
138
+ SerializerEncoding.NormalJsonOptions
139
+ );
129
140
  }
130
141
 
131
142
  public static byte[] JsonSerialize<T>(T input)
@@ -135,13 +146,24 @@
135
146
 
136
147
  public static string JsonStringify<T>(T input, bool pretty = false)
137
148
  {
138
- JsonSerializerOptions options =
139
- pretty ? SerializerEncoding.PrettyJsonOptions : SerializerEncoding.NormalJsonOptions;
140
- if (typeof(T) == typeof(object))
149
+ JsonSerializerOptions options = pretty
150
+ ? SerializerEncoding.PrettyJsonOptions
151
+ : SerializerEncoding.NormalJsonOptions;
152
+ Type parameterType = typeof(T);
153
+ if (
154
+ parameterType.IsAbstract
155
+ || parameterType.IsInterface
156
+ || parameterType == typeof(object)
157
+ )
141
158
  {
142
159
  object data = input;
143
- Type type = data?.GetType();
144
- return JsonSerializer.Serialize(data, data?.GetType(), options);
160
+ if (data == null)
161
+ {
162
+ return "{}";
163
+ }
164
+
165
+ Type type = data.GetType();
166
+ return JsonSerializer.Serialize(data, type, options);
145
167
  }
146
168
 
147
169
  return JsonSerializer.Serialize(input, options);
@@ -159,4 +181,4 @@
159
181
  File.WriteAllText(path, jsonAsText);
160
182
  }
161
183
  }
162
- }
184
+ }
@@ -17,7 +17,7 @@
17
17
  public int baseSegments = 4;
18
18
  public float updateRateSeconds = 0.1f;
19
19
  public Color color = Color.grey;
20
-
20
+
21
21
  public Vector3 Offset
22
22
  {
23
23
  get => _offset;
@@ -26,6 +26,7 @@
26
26
 
27
27
  [SiblingComponent]
28
28
  private CircleCollider2D _collider;
29
+
29
30
  [SiblingComponent]
30
31
  private LineRenderer[] _lineRenderers;
31
32
 
@@ -70,7 +71,11 @@
70
71
 
71
72
  if (maxLineWidth < minLineWidth)
72
73
  {
73
- this.LogWarn("MaxLineWidth {0} smaller than MinLineWidth {1}.", maxLineWidth, minLineWidth);
74
+ this.LogWarn(
75
+ "MaxLineWidth {0} smaller than MinLineWidth {1}.",
76
+ maxLineWidth,
77
+ minLineWidth
78
+ );
74
79
  }
75
80
  }
76
81
 
@@ -98,7 +103,10 @@
98
103
  lineRenderer.positionCount = numSegments;
99
104
 
100
105
  // ReSharper disable once CompareOfFloatsByEqualityOperator
101
- float lineWidth = minLineWidth == maxLineWidth ? minLineWidth : PcgRandom.Instance.NextFloat(minLineWidth, maxLineWidth);
106
+ float lineWidth =
107
+ minLineWidth == maxLineWidth
108
+ ? minLineWidth
109
+ : PRNG.Instance.NextFloat(minLineWidth, maxLineWidth);
102
110
 
103
111
  lineRenderer.startWidth = lineWidth;
104
112
  lineRenderer.endWidth = lineWidth;
@@ -106,12 +114,16 @@
106
114
  float distanceMultiplier = _collider.radius;
107
115
 
108
116
  float angle = 360f / numSegments;
109
- float offsetRadians = PcgRandom.Instance.NextFloat(angle);
117
+ float offsetRadians = PRNG.Instance.NextFloat(angle);
110
118
  float currentOffset = offsetRadians;
111
119
  Vector3[] positions = new Vector3[numSegments];
112
120
  for (int i = 0; i < numSegments; ++i)
113
121
  {
114
- positions[i] = new Vector3(Mathf.Cos(Mathf.Deg2Rad * currentOffset), Mathf.Sin(Mathf.Deg2Rad * currentOffset)) * distanceMultiplier;
122
+ positions[i] =
123
+ new Vector3(
124
+ Mathf.Cos(Mathf.Deg2Rad * currentOffset),
125
+ Mathf.Sin(Mathf.Deg2Rad * currentOffset)
126
+ ) * distanceMultiplier;
115
127
  currentOffset += angle % 360f;
116
128
  }
117
129