com.wallstop-studios.unity-helpers 1.0.0-rc4
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/.gitattributes +63 -0
- package/CHANGELOG.md +0 -0
- package/CHANGELOG.md.meta +7 -0
- package/Editor/AnimationCreator.cs +218 -0
- package/Editor/AnimationCreator.cs.meta +11 -0
- package/Editor/AnimationEventEditor.cs +742 -0
- package/Editor/AnimationEventEditor.cs.meta +11 -0
- package/Editor/PrefabCheckWizard.cs +140 -0
- package/Editor/PrefabCheckWizard.cs.meta +11 -0
- package/Editor/WallstopStudios.UnityHelpers.Editor.asmdef +16 -0
- package/Editor/WallstopStudios.UnityHelpers.Editor.asmdef.meta +7 -0
- package/Editor.meta +8 -0
- package/LICENSE +21 -0
- package/LICENSE.md +7 -0
- package/LICENSE.md.meta +7 -0
- package/LICENSE.meta +7 -0
- package/README.md +2 -0
- package/README.md.meta +7 -0
- package/Runtime/Core/Attributes/AnimationEventAttribute.cs +102 -0
- package/Runtime/Core/Attributes/AnimationEventAttribute.cs.meta +11 -0
- package/Runtime/Core/Attributes/AutomaticallyFindAttribute.cs +43 -0
- package/Runtime/Core/Attributes/AutomaticallyFindAttribute.cs.meta +11 -0
- package/Runtime/Core/Attributes/ChildComponentAttribute.cs +85 -0
- package/Runtime/Core/Attributes/ChildComponentAttribute.cs.meta +11 -0
- package/Runtime/Core/Attributes/KSerializableAttribute.cs +23 -0
- package/Runtime/Core/Attributes/KSerializableAttribute.cs.meta +11 -0
- package/Runtime/Core/Attributes/NotNullAttribute.cs +33 -0
- package/Runtime/Core/Attributes/NotNullAttribute.cs.meta +11 -0
- package/Runtime/Core/Attributes/ParentComponent.cs +85 -0
- package/Runtime/Core/Attributes/ParentComponent.cs.meta +11 -0
- package/Runtime/Core/Attributes/ReadOnlyAttribute.cs +8 -0
- package/Runtime/Core/Attributes/ReadOnlyAttribute.cs.meta +11 -0
- package/Runtime/Core/Attributes/RelationalComponentExtensions.cs +14 -0
- package/Runtime/Core/Attributes/RelationalComponentExtensions.cs.meta +11 -0
- package/Runtime/Core/Attributes/SiblingComponentAttribute.cs +89 -0
- package/Runtime/Core/Attributes/SiblingComponentAttribute.cs.meta +11 -0
- package/Runtime/Core/Attributes/ValidateAssignmentAttribute.cs +66 -0
- package/Runtime/Core/Attributes/ValidateAssignmentAttribute.cs.meta +11 -0
- package/Runtime/Core/Attributes.meta +8 -0
- package/Runtime/Core/DataStructure/Adapters/FastVector2Int.cs +91 -0
- package/Runtime/Core/DataStructure/Adapters/FastVector2Int.cs.meta +11 -0
- package/Runtime/Core/DataStructure/Adapters/FastVector3Int.cs +180 -0
- package/Runtime/Core/DataStructure/Adapters/FastVector3Int.cs.meta +11 -0
- package/Runtime/Core/DataStructure/Adapters/KGuid.cs +274 -0
- package/Runtime/Core/DataStructure/Adapters/KGuid.cs.meta +11 -0
- package/Runtime/Core/DataStructure/Adapters/KVector2.cs +79 -0
- package/Runtime/Core/DataStructure/Adapters/KVector2.cs.meta +11 -0
- package/Runtime/Core/DataStructure/Adapters.meta +8 -0
- package/Runtime/Core/DataStructure/Circle.cs +50 -0
- package/Runtime/Core/DataStructure/Circle.cs.meta +11 -0
- package/Runtime/Core/DataStructure/CyclicBuffer.cs +130 -0
- package/Runtime/Core/DataStructure/CyclicBuffer.cs.meta +11 -0
- package/Runtime/Core/DataStructure/ISpatialTree.cs +58 -0
- package/Runtime/Core/DataStructure/ISpatialTree.cs.meta +11 -0
- package/Runtime/Core/DataStructure/KDTree.cs +186 -0
- package/Runtime/Core/DataStructure/KDTree.cs.meta +11 -0
- package/Runtime/Core/DataStructure/QuadTree.cs +184 -0
- package/Runtime/Core/DataStructure/QuadTree.cs.meta +11 -0
- package/Runtime/Core/DataStructure/RTree.cs +247 -0
- package/Runtime/Core/DataStructure/RTree.cs.meta +11 -0
- package/Runtime/Core/DataStructure/StringWrapper.cs +90 -0
- package/Runtime/Core/DataStructure/StringWrapper.cs.meta +11 -0
- package/Runtime/Core/DataStructure/TimedCache.cs +50 -0
- package/Runtime/Core/DataStructure/TimedCache.cs.meta +11 -0
- package/Runtime/Core/DataStructure.meta +8 -0
- package/Runtime/Core/Extension/AnimatorExtensions.cs +25 -0
- package/Runtime/Core/Extension/AnimatorExtensions.cs.meta +11 -0
- package/Runtime/Core/Extension/CircleExtensions.cs +25 -0
- package/Runtime/Core/Extension/CircleExtensions.cs.meta +11 -0
- package/Runtime/Core/Extension/ColorExtensions.cs +72 -0
- package/Runtime/Core/Extension/ColorExtensions.cs.meta +11 -0
- package/Runtime/Core/Extension/DictionaryExtensions.cs +173 -0
- package/Runtime/Core/Extension/DictionaryExtensions.cs.meta +11 -0
- package/Runtime/Core/Extension/DirectionExtensions.cs +210 -0
- package/Runtime/Core/Extension/DirectionExtensions.cs.meta +11 -0
- package/Runtime/Core/Extension/HashSetExtensions.cs +12 -0
- package/Runtime/Core/Extension/HashSetExtensions.cs.meta +11 -0
- package/Runtime/Core/Extension/IEnumerableExtensions.cs +109 -0
- package/Runtime/Core/Extension/IEnumerableExtensions.cs.meta +11 -0
- package/Runtime/Core/Extension/IListExtensions.cs +49 -0
- package/Runtime/Core/Extension/IListExtensions.cs.meta +11 -0
- package/Runtime/Core/Extension/LoggingExtensions.cs +196 -0
- package/Runtime/Core/Extension/LoggingExtensions.cs.meta +11 -0
- package/Runtime/Core/Extension/RandomExtensions.cs +110 -0
- package/Runtime/Core/Extension/RandomExtensions.cs.meta +11 -0
- package/Runtime/Core/Extension/StringExtensions.cs +76 -0
- package/Runtime/Core/Extension/StringExtensions.cs.meta +11 -0
- package/Runtime/Core/Extension/UnityExtensions.cs +1409 -0
- package/Runtime/Core/Extension/UnityExtensions.cs.meta +11 -0
- package/Runtime/Core/Extension.meta +8 -0
- package/Runtime/Core/Helper/AssignUtilities.cs +14 -0
- package/Runtime/Core/Helper/AssignUtilities.cs.meta +11 -0
- package/Runtime/Core/Helper/Enumerables.cs +17 -0
- package/Runtime/Core/Helper/Enumerables.cs.meta +11 -0
- package/Runtime/Core/Helper/Geometry.cs +26 -0
- package/Runtime/Core/Helper/Geometry.cs.meta +11 -0
- package/Runtime/Core/Helper/Helpers.cs +1092 -0
- package/Runtime/Core/Helper/Helpers.cs.meta +11 -0
- package/Runtime/Core/Helper/IterationHelpers.cs +32 -0
- package/Runtime/Core/Helper/IterationHelpers.cs.meta +11 -0
- package/Runtime/Core/Helper/LifetimeHelpers.cs +12 -0
- package/Runtime/Core/Helper/LifetimeHelpers.cs.meta +11 -0
- package/Runtime/Core/Helper/Objects.cs +447 -0
- package/Runtime/Core/Helper/Objects.cs.meta +11 -0
- package/Runtime/Core/Helper/SpriteHelpers.cs +53 -0
- package/Runtime/Core/Helper/SpriteHelpers.cs.meta +11 -0
- package/Runtime/Core/Helper/StringInList.cs +31 -0
- package/Runtime/Core/Helper/StringInList.cs.meta +11 -0
- package/Runtime/Core/Helper/WallMath.cs +75 -0
- package/Runtime/Core/Helper/WallMath.cs.meta +11 -0
- package/Runtime/Core/Helper.meta +8 -0
- package/Runtime/Core/Math/Line.cs +51 -0
- package/Runtime/Core/Math/Line.cs.meta +11 -0
- package/Runtime/Core/Math/Parabola.cs +44 -0
- package/Runtime/Core/Math/Parabola.cs.meta +11 -0
- package/Runtime/Core/Math/PointPolygonCheck.cs +25 -0
- package/Runtime/Core/Math/PointPolygonCheck.cs.meta +11 -0
- package/Runtime/Core/Math/Range.cs +56 -0
- package/Runtime/Core/Math/Range.cs.meta +11 -0
- package/Runtime/Core/Math/XXHash.cs +308 -0
- package/Runtime/Core/Math/XXHash.cs.meta +11 -0
- package/Runtime/Core/Math.meta +8 -0
- package/Runtime/Core/Model/Direction.cs +26 -0
- package/Runtime/Core/Model/Direction.cs.meta +11 -0
- package/Runtime/Core/Model.meta +8 -0
- package/Runtime/Core/OneOf/FastOneOf.cs +145 -0
- package/Runtime/Core/OneOf/FastOneOf.cs.meta +11 -0
- package/Runtime/Core/OneOf/None.cs +6 -0
- package/Runtime/Core/OneOf/None.cs.meta +11 -0
- package/Runtime/Core/OneOf.meta +8 -0
- package/Runtime/Core/Random/AbstractRandom.cs +537 -0
- package/Runtime/Core/Random/AbstractRandom.cs.meta +11 -0
- package/Runtime/Core/Random/IRandom.cs +141 -0
- package/Runtime/Core/Random/IRandom.cs.meta +11 -0
- package/Runtime/Core/Random/NativePcgRandom.cs +97 -0
- package/Runtime/Core/Random/NativePcgRandom.cs.meta +11 -0
- package/Runtime/Core/Random/PcgRandom.cs +142 -0
- package/Runtime/Core/Random/PcgRandom.cs.meta +11 -0
- package/Runtime/Core/Random/RandomState.cs +92 -0
- package/Runtime/Core/Random/RandomState.cs.meta +11 -0
- package/Runtime/Core/Random/RandomUtilities.cs +26 -0
- package/Runtime/Core/Random/RandomUtilities.cs.meta +11 -0
- package/Runtime/Core/Random/SquirrelRandom.cs +82 -0
- package/Runtime/Core/Random/SquirrelRandom.cs.meta +11 -0
- package/Runtime/Core/Random/SystemRandom.cs +110 -0
- package/Runtime/Core/Random/SystemRandom.cs.meta +11 -0
- package/Runtime/Core/Random/ThreadLocalRandom.cs +11 -0
- package/Runtime/Core/Random/ThreadLocalRandom.cs.meta +11 -0
- package/Runtime/Core/Random/UnityRandom.cs +24 -0
- package/Runtime/Core/Random/UnityRandom.cs.meta +11 -0
- package/Runtime/Core/Random/XorShiftRandom.cs +45 -0
- package/Runtime/Core/Random/XorShiftRandom.cs.meta +11 -0
- package/Runtime/Core/Random.meta +8 -0
- package/Runtime/Core/Serialization/JsonConverters/Vector2Converter.cs +32 -0
- package/Runtime/Core/Serialization/JsonConverters/Vector2Converter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters/Vector3Converter.cs +32 -0
- package/Runtime/Core/Serialization/JsonConverters/Vector3Converter.cs.meta +11 -0
- package/Runtime/Core/Serialization/JsonConverters.meta +8 -0
- package/Runtime/Core/Serialization/Serializer.cs +125 -0
- package/Runtime/Core/Serialization/Serializer.cs.meta +11 -0
- package/Runtime/Core/Serialization.meta +8 -0
- package/Runtime/Core/Threading/SingleThreadedThreadPool.cs +102 -0
- package/Runtime/Core/Threading/SingleThreadedThreadPool.cs.meta +11 -0
- package/Runtime/Core/Threading.meta +8 -0
- package/Runtime/Core.meta +8 -0
- package/Runtime/Protobuf-Net/System.Buffers.dll +0 -0
- package/Runtime/Protobuf-Net/System.Buffers.dll.meta +33 -0
- package/Runtime/Protobuf-Net/System.Collections.Immutable.dll +0 -0
- package/Runtime/Protobuf-Net/System.Collections.Immutable.dll.meta +33 -0
- package/Runtime/Protobuf-Net/System.Numerics.Vectors.dll +0 -0
- package/Runtime/Protobuf-Net/System.Numerics.Vectors.dll.meta +33 -0
- package/Runtime/Protobuf-Net/System.Runtime.CompilerServices.Unsafe.dll +0 -0
- package/Runtime/Protobuf-Net/System.Runtime.CompilerServices.Unsafe.dll.meta +33 -0
- package/Runtime/Protobuf-Net/protobuf-net.Core.dll +0 -0
- package/Runtime/Protobuf-Net/protobuf-net.Core.dll.meta +33 -0
- package/Runtime/Protobuf-Net/protobuf-net.dll +0 -0
- package/Runtime/Protobuf-Net/protobuf-net.dll.meta +33 -0
- package/Runtime/Protobuf-Net.meta +8 -0
- package/Runtime/Utils/AnimationEventEqualityComparer.cs +149 -0
- package/Runtime/Utils/AnimationEventEqualityComparer.cs.meta +11 -0
- package/Runtime/Utils/AnimatorEnumStateMachine.cs +80 -0
- package/Runtime/Utils/AnimatorEnumStateMachine.cs.meta +11 -0
- package/Runtime/Utils/Buffers.cs +32 -0
- package/Runtime/Utils/Buffers.cs.meta +11 -0
- package/Runtime/Utils/CircleLineRenderer.cs +122 -0
- package/Runtime/Utils/CircleLineRenderer.cs.meta +11 -0
- package/Runtime/Utils/Oscillator.cs +25 -0
- package/Runtime/Utils/Oscillator.cs.meta +11 -0
- package/Runtime/Utils/SetTextureImportData.cs +67 -0
- package/Runtime/Utils/SetTextureImportData.cs.meta +11 -0
- package/Runtime/Utils.meta +8 -0
- package/Runtime/WallstopStudios.UnityHelpers.asmdef +14 -0
- package/Runtime/WallstopStudios.UnityHelpers.asmdef.meta +7 -0
- package/Runtime.meta +8 -0
- package/Tests/Editor/WallstopStudios.UnityHelpers.Tests.Editor.asmdef +17 -0
- package/Tests/Editor/WallstopStudios.UnityHelpers.Tests.Editor.asmdef.meta +7 -0
- package/Tests/Editor.meta +8 -0
- package/Tests/Runtime/DataStructures/BalancedKDTreeTests.cs +14 -0
- package/Tests/Runtime/DataStructures/BalancedKDTreeTests.cs.meta +11 -0
- package/Tests/Runtime/DataStructures/QuadTreeTests.cs +14 -0
- package/Tests/Runtime/DataStructures/QuadTreeTests.cs.meta +11 -0
- package/Tests/Runtime/DataStructures/SpatialTreeTests.cs +106 -0
- package/Tests/Runtime/DataStructures/SpatialTreeTests.cs.meta +11 -0
- package/Tests/Runtime/DataStructures/UnbalancedKDTreeTests.cs +14 -0
- package/Tests/Runtime/DataStructures/UnbalancedKDTreeTests.cs.meta +11 -0
- package/Tests/Runtime/DataStructures.meta +8 -0
- package/Tests/Runtime/Performance/KDTreePerformanceTests.cs +14 -0
- package/Tests/Runtime/Performance/KDTreePerformanceTests.cs.meta +11 -0
- package/Tests/Runtime/Performance/QuadTreePerformanceTests.cs +14 -0
- package/Tests/Runtime/Performance/QuadTreePerformanceTests.cs.meta +11 -0
- package/Tests/Runtime/Performance/RandomPerformanceTests.cs +76 -0
- package/Tests/Runtime/Performance/RandomPerformanceTests.cs.meta +11 -0
- package/Tests/Runtime/Performance/SpatialTreePerformanceTest.cs +141 -0
- package/Tests/Runtime/Performance/SpatialTreePerformanceTest.cs.meta +11 -0
- package/Tests/Runtime/Performance/UnbalancedKDTreeTests.cs +14 -0
- package/Tests/Runtime/Performance/UnbalancedKDTreeTests.cs.meta +11 -0
- package/Tests/Runtime/Performance.meta +8 -0
- package/Tests/Runtime/Random/PcgRandomTests.cs +9 -0
- package/Tests/Runtime/Random/PcgRandomTests.cs.meta +11 -0
- package/Tests/Runtime/Random/RandomTestBase.cs +117 -0
- package/Tests/Runtime/Random/RandomTestBase.cs.meta +11 -0
- package/Tests/Runtime/Random/SquirrelRandomTests.cs +9 -0
- package/Tests/Runtime/Random/SquirrelRandomTests.cs.meta +11 -0
- package/Tests/Runtime/Random/SystemRandomTests.cs +10 -0
- package/Tests/Runtime/Random/SystemRandomTests.cs.meta +11 -0
- package/Tests/Runtime/Random/UnityRandomTests.cs +9 -0
- package/Tests/Runtime/Random/UnityRandomTests.cs.meta +11 -0
- package/Tests/Runtime/Random/XorShiftRandomTests.cs +9 -0
- package/Tests/Runtime/Random/XorShiftRandomTests.cs.meta +11 -0
- package/Tests/Runtime/Random.meta +8 -0
- package/Tests/Runtime/WallstopStudios.UnityHelpers.Tests.Runtime.asmdef +22 -0
- package/Tests/Runtime/WallstopStudios.UnityHelpers.Tests.Runtime.asmdef.meta +7 -0
- package/Tests/Runtime.meta +8 -0
- package/Tests.meta +8 -0
- package/Third Party Notices.md +1 -0
- package/Third Party Notices.md.meta +7 -0
- package/package.json +35 -0
- package/package.json.meta +7 -0
|
@@ -0,0 +1,537 @@
|
|
|
1
|
+
namespace UnityHelpers.Core.Random
|
|
2
|
+
{
|
|
3
|
+
using System;
|
|
4
|
+
using System.Collections.Concurrent;
|
|
5
|
+
using System.Collections.Generic;
|
|
6
|
+
using System.Linq;
|
|
7
|
+
using System.Runtime.Serialization;
|
|
8
|
+
using DataStructure.Adapters;
|
|
9
|
+
using UnityEngine;
|
|
10
|
+
|
|
11
|
+
[Serializable]
|
|
12
|
+
[DataContract]
|
|
13
|
+
public abstract class AbstractRandom : IRandom
|
|
14
|
+
{
|
|
15
|
+
private static readonly ConcurrentDictionary<Type, Array> EnumTypeCache = new();
|
|
16
|
+
|
|
17
|
+
protected const uint HalfwayUint = uint.MaxValue / 2;
|
|
18
|
+
protected const double MagicDouble = 4.6566128752458E-10;
|
|
19
|
+
protected const float MagicFloat = 5.960465E-008F;
|
|
20
|
+
|
|
21
|
+
protected double? _cachedGaussian;
|
|
22
|
+
|
|
23
|
+
protected AbstractRandom() { }
|
|
24
|
+
|
|
25
|
+
public abstract RandomState InternalState { get; }
|
|
26
|
+
|
|
27
|
+
public int Next()
|
|
28
|
+
{
|
|
29
|
+
int result;
|
|
30
|
+
do
|
|
31
|
+
{
|
|
32
|
+
result = unchecked((int)NextUint());
|
|
33
|
+
}
|
|
34
|
+
while (result < 0);
|
|
35
|
+
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public int Next(int max)
|
|
40
|
+
{
|
|
41
|
+
if (max <= 0)
|
|
42
|
+
{
|
|
43
|
+
throw new ArgumentException($"Max {max} cannot be less-than or equal-to 0");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return unchecked((int)NextUint(unchecked((uint)max)));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public int Next(int min, int max)
|
|
50
|
+
{
|
|
51
|
+
if (max <= min)
|
|
52
|
+
{
|
|
53
|
+
throw new ArgumentException($"Min {min} cannot be larger-than or equal-to max {max}");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
uint range = unchecked((uint)(max - min));
|
|
57
|
+
return unchecked((int)NextUint(range)) + min;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Internal sampler
|
|
61
|
+
public abstract uint NextUint();
|
|
62
|
+
|
|
63
|
+
public uint NextUint(uint max)
|
|
64
|
+
{
|
|
65
|
+
/*
|
|
66
|
+
https://github.com/libevent/libevent/blob/3807a30b03ab42f2f503f2db62b1ef5876e2be80/arc4random.c#L531
|
|
67
|
+
|
|
68
|
+
http://cs.stackexchange.com/questions/570/generating-uniformly-distributed-random-numbers-using-a-coin
|
|
69
|
+
Generates a uniform random number within the bound, avoiding modulo bias
|
|
70
|
+
*/
|
|
71
|
+
uint threshold = unchecked((uint)((0x100000000UL - max) % max));
|
|
72
|
+
while (true)
|
|
73
|
+
{
|
|
74
|
+
uint randomValue = NextUint();
|
|
75
|
+
if (threshold <= randomValue)
|
|
76
|
+
{
|
|
77
|
+
return randomValue % max;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
public uint NextUint(uint min, uint max)
|
|
83
|
+
{
|
|
84
|
+
if (max <= min)
|
|
85
|
+
{
|
|
86
|
+
throw new ArgumentException($"Min {min} cannot be larger-than or equal-to max {max}");
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return min + NextUint(max - min);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
public short NextShort()
|
|
93
|
+
{
|
|
94
|
+
return NextShort(short.MaxValue);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
public short NextShort(short max)
|
|
98
|
+
{
|
|
99
|
+
return NextShort(0, max);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
public short NextShort(short min, short max)
|
|
103
|
+
{
|
|
104
|
+
return unchecked((short)Next(min, max));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
public byte NextByte()
|
|
108
|
+
{
|
|
109
|
+
return NextByte(byte.MaxValue);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
public byte NextByte(byte max)
|
|
113
|
+
{
|
|
114
|
+
return NextByte(0, max);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
public byte NextByte(byte min, byte max)
|
|
118
|
+
{
|
|
119
|
+
return unchecked((byte)Next(min, max));
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
public long NextLong()
|
|
123
|
+
{
|
|
124
|
+
uint upper = NextUint();
|
|
125
|
+
uint lower = NextUint();
|
|
126
|
+
// Mix things up a little
|
|
127
|
+
if (NextBool())
|
|
128
|
+
{
|
|
129
|
+
return unchecked((long)((ulong)upper << 32) | lower);
|
|
130
|
+
}
|
|
131
|
+
return unchecked((long)((ulong)lower << 32) | upper);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
public long NextLong(long max)
|
|
135
|
+
{
|
|
136
|
+
if (max <= 0)
|
|
137
|
+
{
|
|
138
|
+
throw new ArgumentException($"Max {max} cannot be less-than or equal-to 0");
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
if (max < int.MaxValue)
|
|
142
|
+
{
|
|
143
|
+
return Next(unchecked((int)max));
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
long withinRange;
|
|
147
|
+
do
|
|
148
|
+
{
|
|
149
|
+
withinRange = NextLong();
|
|
150
|
+
}
|
|
151
|
+
while (withinRange < 0 || max <= withinRange);
|
|
152
|
+
return withinRange;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
public long NextLong(long min, long max)
|
|
156
|
+
{
|
|
157
|
+
if (max <= min)
|
|
158
|
+
{
|
|
159
|
+
throw new ArgumentException($"Min {min} cannot be larger-than or equal-to Max {max}");
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return min + NextLong(max - min);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
public ulong NextUlong()
|
|
166
|
+
{
|
|
167
|
+
return unchecked((ulong)NextLong());
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
public ulong NextUlong(ulong max)
|
|
171
|
+
{
|
|
172
|
+
return unchecked((ulong)NextLong(unchecked((long)max)));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
public ulong NextUlong(ulong min, ulong max)
|
|
176
|
+
{
|
|
177
|
+
if (max <= min)
|
|
178
|
+
{
|
|
179
|
+
throw new ArgumentException($"Min {min} cannot be larger-than or equal-to max {max}");
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return unchecked((ulong)NextLong(unchecked((long)min), unchecked((long)max)));
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
public bool NextBool()
|
|
186
|
+
{
|
|
187
|
+
return NextUint() < HalfwayUint;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
public void NextBytes(byte[] buffer)
|
|
191
|
+
{
|
|
192
|
+
if (ReferenceEquals(buffer, null))
|
|
193
|
+
{
|
|
194
|
+
throw new ArgumentException(nameof(buffer));
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const byte sizeOfInt = 4; // May differ on some platforms
|
|
198
|
+
|
|
199
|
+
// See how many ints we can slap into it.
|
|
200
|
+
int chunks = buffer.Length / sizeOfInt;
|
|
201
|
+
byte spare = unchecked((byte)(buffer.Length - (chunks * sizeOfInt)));
|
|
202
|
+
for (int i = 0; i < chunks; ++i)
|
|
203
|
+
{
|
|
204
|
+
int offset = i * chunks;
|
|
205
|
+
int random = Next();
|
|
206
|
+
buffer[offset] = unchecked((byte)(random & 0xFF000000));
|
|
207
|
+
buffer[offset + 1] = unchecked((byte)(random & 0x00FF0000));
|
|
208
|
+
buffer[offset + 2] = unchecked((byte)(random & 0x0000FF00));
|
|
209
|
+
buffer[offset + 3] = unchecked((byte)(random & 0x000000FF));
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
{
|
|
213
|
+
/*
|
|
214
|
+
This could be implemented more optimally by generating a single int and
|
|
215
|
+
bit shifting along the position, but that is too much for me right now.
|
|
216
|
+
*/
|
|
217
|
+
for (byte i = 0; i < spare; ++i)
|
|
218
|
+
{
|
|
219
|
+
buffer[buffer.Length - 1 - i] = unchecked((byte)Next());
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
public virtual double NextDouble()
|
|
225
|
+
{
|
|
226
|
+
double value;
|
|
227
|
+
do
|
|
228
|
+
{
|
|
229
|
+
value = NextUint() * MagicDouble;
|
|
230
|
+
}
|
|
231
|
+
while (value < 0 || 1 <= value);
|
|
232
|
+
|
|
233
|
+
return value;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
public double NextDouble(double max)
|
|
237
|
+
{
|
|
238
|
+
if (max <= 0)
|
|
239
|
+
{
|
|
240
|
+
throw new ArgumentException($"Max {max} cannot be less-than or equal-to 0");
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return NextDouble() * max;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
public double NextDouble(double min, double max)
|
|
247
|
+
{
|
|
248
|
+
if (max <= min)
|
|
249
|
+
{
|
|
250
|
+
throw new ArgumentException($"Min {min} cannot be larger-than or equal-to max {max}");
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
double range = max - min;
|
|
254
|
+
return min + NextDouble(range);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
public double NextGaussian(double mean = 0, double stdDev = 1)
|
|
258
|
+
{
|
|
259
|
+
return mean + NextGaussianInternal() * stdDev;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
private double NextGaussianInternal()
|
|
263
|
+
{
|
|
264
|
+
if (_cachedGaussian != null)
|
|
265
|
+
{
|
|
266
|
+
double gaussian = _cachedGaussian.Value;
|
|
267
|
+
_cachedGaussian = null;
|
|
268
|
+
return gaussian;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// https://stackoverflow.com/q/7183229/1917135
|
|
272
|
+
double x;
|
|
273
|
+
double y;
|
|
274
|
+
double square;
|
|
275
|
+
do
|
|
276
|
+
{
|
|
277
|
+
x = 2 * NextDouble() - 1;
|
|
278
|
+
y = 2 * NextDouble() - 1;
|
|
279
|
+
square = x * x + y * y;
|
|
280
|
+
}
|
|
281
|
+
while (square > 1 || square == 0);
|
|
282
|
+
|
|
283
|
+
double fac = Math.Sqrt(-2 * Math.Log(square) / square);
|
|
284
|
+
_cachedGaussian = x * fac;
|
|
285
|
+
return y * fac;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
public virtual float NextFloat()
|
|
289
|
+
{
|
|
290
|
+
float value;
|
|
291
|
+
do
|
|
292
|
+
{
|
|
293
|
+
uint floatAsInt = NextUint();
|
|
294
|
+
value = (floatAsInt >> 8) * MagicFloat;
|
|
295
|
+
}
|
|
296
|
+
while (value < 0 || 1 <= value);
|
|
297
|
+
|
|
298
|
+
return value;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
public float NextFloat(float max)
|
|
302
|
+
{
|
|
303
|
+
if (max <= 0)
|
|
304
|
+
{
|
|
305
|
+
throw new ArgumentException($"{max} cannot be less-than or equal-to 0");
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
return NextFloat() * max;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
public float NextFloat(float min, float max)
|
|
312
|
+
{
|
|
313
|
+
if (max <= min)
|
|
314
|
+
{
|
|
315
|
+
throw new ArgumentException($"Min {min} cannot be larger-than or equal-to max {max}");
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
return min + NextFloat(max - min);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
public T Next<T>(IEnumerable<T> enumerable)
|
|
322
|
+
{
|
|
323
|
+
if (enumerable is ICollection<T> collection)
|
|
324
|
+
{
|
|
325
|
+
return Next(collection);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
return Next((IReadOnlyList<T>)enumerable.ToList());
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
public T Next<T>(ICollection<T> collection)
|
|
332
|
+
{
|
|
333
|
+
int count = collection.Count;
|
|
334
|
+
if (count <= 0)
|
|
335
|
+
{
|
|
336
|
+
throw new ArgumentException("Collection size cannot be less-than or equal-to 0");
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
switch (collection)
|
|
340
|
+
{
|
|
341
|
+
case IList<T> list:
|
|
342
|
+
return Next(list);
|
|
343
|
+
case IReadOnlyList<T> readOnlyList:
|
|
344
|
+
return Next(readOnlyList);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
int index = Next(count);
|
|
348
|
+
int i = 0;
|
|
349
|
+
foreach (T element in collection)
|
|
350
|
+
{
|
|
351
|
+
if (i++ == index)
|
|
352
|
+
{
|
|
353
|
+
return element;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// Should never happen
|
|
358
|
+
return default;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
public T Next<T>(IList<T> list)
|
|
362
|
+
{
|
|
363
|
+
if (ReferenceEquals(list, null))
|
|
364
|
+
{
|
|
365
|
+
throw new ArgumentNullException(nameof(list));
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/*
|
|
369
|
+
For small lists, it's much more efficient to simply return one of their elements
|
|
370
|
+
instead of trying to generate a random number within bounds (which is implemented as a while(true) loop)
|
|
371
|
+
*/
|
|
372
|
+
switch (list.Count)
|
|
373
|
+
{
|
|
374
|
+
case 1:
|
|
375
|
+
return list[0];
|
|
376
|
+
case 2:
|
|
377
|
+
return NextBool() ? list[0] : list[1];
|
|
378
|
+
default:
|
|
379
|
+
return list[Next(list.Count)];
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
private T Next<T>(IReadOnlyList<T> list)
|
|
384
|
+
{
|
|
385
|
+
/*
|
|
386
|
+
For small lists, it's much more efficient to simply return one of their elements
|
|
387
|
+
instead of trying to generate a random number within bounds (which is implemented as a while(true) loop)
|
|
388
|
+
*/
|
|
389
|
+
switch (list.Count)
|
|
390
|
+
{
|
|
391
|
+
case 1:
|
|
392
|
+
return list[0];
|
|
393
|
+
case 2:
|
|
394
|
+
return NextBool() ? list[0] : list[1];
|
|
395
|
+
default:
|
|
396
|
+
return list[Next(list.Count)];
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
public T Next<T>() where T : struct, Enum
|
|
401
|
+
{
|
|
402
|
+
Type enumType = typeof(T);
|
|
403
|
+
T[] enumValues;
|
|
404
|
+
if (EnumTypeCache.TryGetValue(enumType, out Array enumArray))
|
|
405
|
+
{
|
|
406
|
+
enumValues = (T[])enumArray;
|
|
407
|
+
}
|
|
408
|
+
else
|
|
409
|
+
{
|
|
410
|
+
enumValues = (T[])Enum.GetValues(enumType);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
return RandomOf(enumValues);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
public T NextCachedEnum<T>() where T : struct, Enum
|
|
417
|
+
{
|
|
418
|
+
Type enumType = typeof(T);
|
|
419
|
+
T[] enumValues = (T[])EnumTypeCache.GetOrAdd(enumType, Enum.GetValues);
|
|
420
|
+
|
|
421
|
+
return RandomOf(enumValues);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
public Guid NextGuid()
|
|
425
|
+
{
|
|
426
|
+
byte[] guidBytes = new byte[16];
|
|
427
|
+
NextBytes(guidBytes);
|
|
428
|
+
return new Guid(guidBytes);
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
public KGuid NextKGuid()
|
|
432
|
+
{
|
|
433
|
+
byte[] guidBytes = new byte[16];
|
|
434
|
+
NextBytes(guidBytes);
|
|
435
|
+
return new KGuid(guidBytes);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
// Advances the RNG
|
|
439
|
+
// https://code2d.wordpress.com/2020/07/21/perlin-noise/
|
|
440
|
+
public float[,] NextNoiseMap(int width, int height, float scale, int octaves)
|
|
441
|
+
{
|
|
442
|
+
if (width <= 0)
|
|
443
|
+
{
|
|
444
|
+
throw new ArgumentException(nameof(width));
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
if (height <= 0)
|
|
448
|
+
{
|
|
449
|
+
throw new ArgumentException(nameof(height));
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
if (scale <= 0)
|
|
453
|
+
{
|
|
454
|
+
throw new ArgumentException(nameof(scale));
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
if (octaves < 1)
|
|
458
|
+
{
|
|
459
|
+
throw new ArgumentException(nameof(octaves));
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
float[,] noiseMap = new float[width, height];
|
|
463
|
+
|
|
464
|
+
Vector2[] octaveOffsets = new Vector2[octaves];
|
|
465
|
+
for (int i = 0; i < octaves; i++)
|
|
466
|
+
{
|
|
467
|
+
float offsetX = Next(-100000, 100000);
|
|
468
|
+
float offsetY = Next(-100000, 100000);
|
|
469
|
+
octaveOffsets[i] = new Vector2(offsetX, offsetY);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
float maxNoiseHeight = float.MinValue;
|
|
473
|
+
float minNoiseHeight = float.MaxValue;
|
|
474
|
+
|
|
475
|
+
float halfWidth = width / 2f;
|
|
476
|
+
float halfHeight = height / 2f;
|
|
477
|
+
|
|
478
|
+
for (int x = 0; x < width; ++x)
|
|
479
|
+
{
|
|
480
|
+
for (int y = 0; y < height; ++y)
|
|
481
|
+
{
|
|
482
|
+
float amplitude = 1;
|
|
483
|
+
float frequency = 1;
|
|
484
|
+
float noiseHeight = 0;
|
|
485
|
+
for (int i = 0; i < octaves; i++)
|
|
486
|
+
{
|
|
487
|
+
float sampleX = (x - halfWidth) / scale * frequency + octaveOffsets[i].x;
|
|
488
|
+
float sampleY = (y - halfHeight) / scale * frequency + octaveOffsets[i].y;
|
|
489
|
+
|
|
490
|
+
// Use unity's implementation of perlin noise
|
|
491
|
+
float perlinValue = Mathf.PerlinNoise(sampleX, sampleY) * 2 - 1;
|
|
492
|
+
noiseHeight += perlinValue * amplitude;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
if (noiseHeight > maxNoiseHeight)
|
|
496
|
+
{
|
|
497
|
+
maxNoiseHeight = noiseHeight;
|
|
498
|
+
}
|
|
499
|
+
else if (noiseHeight < minNoiseHeight)
|
|
500
|
+
{
|
|
501
|
+
minNoiseHeight = noiseHeight;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
noiseMap[x, y] = noiseHeight;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
for (int x = 0; x < width; ++x)
|
|
509
|
+
{
|
|
510
|
+
for (int y = 0; y < height; ++y)
|
|
511
|
+
{
|
|
512
|
+
// Returns a value between 0f and 1f based on noiseMap value
|
|
513
|
+
// minNoiseHeight being 0f, and maxNoiseHeight being 1f
|
|
514
|
+
noiseMap[x, y] = Mathf.InverseLerp(minNoiseHeight, maxNoiseHeight, noiseMap[x, y]);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
return noiseMap;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
protected T RandomOf<T>(T[] values)
|
|
521
|
+
{
|
|
522
|
+
switch (values.Length)
|
|
523
|
+
{
|
|
524
|
+
case 0:
|
|
525
|
+
return default;
|
|
526
|
+
case 1:
|
|
527
|
+
return values[0];
|
|
528
|
+
case 2:
|
|
529
|
+
return NextBool() ? values[0] : values[1];
|
|
530
|
+
default:
|
|
531
|
+
return values[Next(values.Length)];
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
public abstract IRandom Copy();
|
|
536
|
+
}
|
|
537
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
namespace UnityHelpers.Core.Random
|
|
2
|
+
{
|
|
3
|
+
using System;
|
|
4
|
+
using System.Collections.Generic;
|
|
5
|
+
using DataStructure.Adapters;
|
|
6
|
+
|
|
7
|
+
public interface IRandom
|
|
8
|
+
{
|
|
9
|
+
RandomState InternalState { get; }
|
|
10
|
+
|
|
11
|
+
/// <summary>
|
|
12
|
+
/// </summary>
|
|
13
|
+
/// <returns>A number within the range [0, int.MaxValue).</returns>
|
|
14
|
+
int Next();
|
|
15
|
+
|
|
16
|
+
/// <summary>
|
|
17
|
+
/// </summary>
|
|
18
|
+
/// <returns>A number within the range [0, max).</returns>
|
|
19
|
+
int Next(int max);
|
|
20
|
+
|
|
21
|
+
/// <summary>
|
|
22
|
+
/// </summary>
|
|
23
|
+
/// <returns>A number within the range [min, max).</returns>
|
|
24
|
+
int Next(int min, int max);
|
|
25
|
+
|
|
26
|
+
/// <summary>
|
|
27
|
+
/// </summary>
|
|
28
|
+
/// <returns>A number within the range [0, uint.MaxValue].</returns>
|
|
29
|
+
uint NextUint();
|
|
30
|
+
/// <summary>
|
|
31
|
+
/// </summary>
|
|
32
|
+
/// <returns>A number within the range [0, max).</returns>
|
|
33
|
+
uint NextUint(uint max);
|
|
34
|
+
/// <summary>
|
|
35
|
+
/// </summary>
|
|
36
|
+
/// <returns>A number within the range [min, max).</returns>
|
|
37
|
+
uint NextUint(uint min, uint max);
|
|
38
|
+
|
|
39
|
+
/// <summary>
|
|
40
|
+
/// </summary>
|
|
41
|
+
/// <returns>A number within the range [0, short.MaxValue).</returns>
|
|
42
|
+
short NextShort();
|
|
43
|
+
|
|
44
|
+
/// <summary>
|
|
45
|
+
/// </summary>
|
|
46
|
+
/// <returns>A number within the range [0, max).</returns>
|
|
47
|
+
short NextShort(short max);
|
|
48
|
+
/// <summary>
|
|
49
|
+
/// </summary>
|
|
50
|
+
/// <returns>A number within the range [min, max).</returns>
|
|
51
|
+
short NextShort(short min, short max);
|
|
52
|
+
|
|
53
|
+
/// <summary>
|
|
54
|
+
/// </summary>
|
|
55
|
+
/// <returns>A number within the range [0, byte.MaxValue).</returns>
|
|
56
|
+
byte NextByte();
|
|
57
|
+
/// <summary>
|
|
58
|
+
/// </summary>
|
|
59
|
+
/// <returns>A number within the range [0, max).</returns>
|
|
60
|
+
byte NextByte(byte max);
|
|
61
|
+
/// <summary>
|
|
62
|
+
/// </summary>
|
|
63
|
+
/// <returns>A number within the range [min, max).</returns>
|
|
64
|
+
byte NextByte(byte min, byte max);
|
|
65
|
+
|
|
66
|
+
/// <summary>
|
|
67
|
+
/// </summary>
|
|
68
|
+
/// <returns>A number within the range [0, long.MaxValue).</returns>
|
|
69
|
+
long NextLong();
|
|
70
|
+
/// <summary>
|
|
71
|
+
/// </summary>
|
|
72
|
+
/// <returns>A number within the range [0, max).</returns>
|
|
73
|
+
long NextLong(long max);
|
|
74
|
+
/// <summary>
|
|
75
|
+
/// </summary>
|
|
76
|
+
/// <returns>A number within the range [min, max).</returns>
|
|
77
|
+
long NextLong(long min, long max);
|
|
78
|
+
|
|
79
|
+
/// <summary>
|
|
80
|
+
/// </summary>
|
|
81
|
+
/// <returns>A number within the range [0, ulong.MaxValue).</returns>
|
|
82
|
+
ulong NextUlong();
|
|
83
|
+
/// <summary>
|
|
84
|
+
/// </summary>
|
|
85
|
+
/// <returns>A number within the range [0, max).</returns>
|
|
86
|
+
ulong NextUlong(ulong max);
|
|
87
|
+
/// <summary>
|
|
88
|
+
/// </summary>
|
|
89
|
+
/// <returns>A number within the range [min, max).</returns>
|
|
90
|
+
ulong NextUlong(ulong min, ulong max);
|
|
91
|
+
|
|
92
|
+
/// <summary>
|
|
93
|
+
/// </summary>
|
|
94
|
+
/// <returns>50% chance of true or false.</returns>
|
|
95
|
+
bool NextBool();
|
|
96
|
+
|
|
97
|
+
void NextBytes(byte[] buffer);
|
|
98
|
+
|
|
99
|
+
/// <summary>
|
|
100
|
+
/// </summary>
|
|
101
|
+
/// <returns>A number within the range [0, 1).</returns>
|
|
102
|
+
float NextFloat();
|
|
103
|
+
/// <summary>
|
|
104
|
+
/// </summary>
|
|
105
|
+
/// <returns>A number within the range [0, max).</returns>
|
|
106
|
+
float NextFloat(float max);
|
|
107
|
+
/// <summary>
|
|
108
|
+
/// </summary>
|
|
109
|
+
/// <returns>A number within the range min, max).</returns>
|
|
110
|
+
float NextFloat(float min, float max);
|
|
111
|
+
|
|
112
|
+
/// <summary>
|
|
113
|
+
/// </summary>
|
|
114
|
+
/// <returns>A number within the range [0, 1).</returns>
|
|
115
|
+
double NextDouble();
|
|
116
|
+
/// <summary>
|
|
117
|
+
/// </summary>
|
|
118
|
+
/// <returns>A number within the range [0, max).</returns>
|
|
119
|
+
double NextDouble(double max);
|
|
120
|
+
/// <summary>
|
|
121
|
+
/// </summary>
|
|
122
|
+
/// <returns>A number within the range min, max).</returns>
|
|
123
|
+
double NextDouble(double min, double max);
|
|
124
|
+
|
|
125
|
+
double NextGaussian(double mean = 0, double stdDev = 1);
|
|
126
|
+
|
|
127
|
+
Guid NextGuid();
|
|
128
|
+
KGuid NextKGuid();
|
|
129
|
+
|
|
130
|
+
T Next<T>(IEnumerable<T> enumerable);
|
|
131
|
+
T Next<T>(ICollection<T> collection);
|
|
132
|
+
T Next<T>(IList<T> list);
|
|
133
|
+
|
|
134
|
+
T Next<T>() where T : struct, Enum;
|
|
135
|
+
T NextCachedEnum<T>() where T : struct, Enum;
|
|
136
|
+
|
|
137
|
+
float[,] NextNoiseMap(int width, int height, float scale = 2.5f, int octaves = 8);
|
|
138
|
+
|
|
139
|
+
IRandom Copy();
|
|
140
|
+
}
|
|
141
|
+
}
|