diff options
author | chai <chaifix@163.com> | 2020-12-30 20:59:04 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2020-12-30 20:59:04 +0800 |
commit | e9ea621b93fbb58d9edfca8375918791637bbd52 (patch) | |
tree | 19ce3b1c1f2d51eda6878c9d0f2c9edc27f13650 /Client/Assembly-CSharp/IntRange.cs |
+init
Diffstat (limited to 'Client/Assembly-CSharp/IntRange.cs')
-rw-r--r-- | Client/Assembly-CSharp/IntRange.cs | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/IntRange.cs b/Client/Assembly-CSharp/IntRange.cs new file mode 100644 index 0000000..1989b3b --- /dev/null +++ b/Client/Assembly-CSharp/IntRange.cs @@ -0,0 +1,71 @@ +using System; +using UnityEngine; + +[Serializable] +public class IntRange +{ + public int min; + + public int max; + + public IntRange() + { + } + + public IntRange(int min, int max) + { + this.min = min; + this.max = max; + } + + public int Next() + { + return UnityEngine.Random.Range(this.min, this.max); + } + + public bool Contains(int value) + { + return this.min <= value && this.max >= value; + } + + public static int Next(int max) + { + return (int)(UnityEngine.Random.value * (float)max); + } + + internal static int Next(int min, int max) + { + return UnityEngine.Random.Range(min, max); + } + + internal static byte NextByte(byte max) + { + return (byte)UnityEngine.Random.Range(0, (int)max); + } + + public static void FillRandom(sbyte min, sbyte max, sbyte[] array) + { + for (int i = 0; i < array.Length; i++) + { + array[i] = (sbyte)IntRange.Next((int)min, (int)max); + } + } + + public static int RandomSign() + { + if (!BoolRange.Next(0.5f)) + { + return -1; + } + return 1; + } + + public static void FillRandomRange(sbyte[] array) + { + for (int i = 0; i < array.Length; i++) + { + array[i] = (sbyte)i; + } + array.Shuffle<sbyte>(); + } +} |