summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/IntRange.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Client/Assembly-CSharp/IntRange.cs')
-rw-r--r--Client/Assembly-CSharp/IntRange.cs71
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>();
+ }
+}