Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
Rand.cs
Go to the documentation of this file.
1using System;
2
3public static class Rand
4{
5 public static int MaxBytes = 1111;
6
7 public static Random _random = new Random();
8
9 public static byte[] bytes;
10
11 public static void InitBytes(int a)
12 {
13 SetSeed(a);
14 bytes = new byte[MaxBytes];
15 for (int i = 0; i < MaxBytes; i++)
16 {
17 bytes[i] = (byte)_random.Next(256);
18 }
19 SetSeed();
20 }
21
22 public static void UseSeed(int seed, Action action)
23 {
25 action();
26 SetSeed();
27 }
28
29 public static int rndSeed(int a, int seed)
30 {
32 int result = rnd(a);
33 SetSeed();
34 return result;
35 }
36
37 public static void SetSeed(int a = -1)
38 {
39 _random = ((a == -1) ? new Random() : new Random(a));
40 }
41
42 public static int Range(int min, int max)
43 {
44 return _random.Next(max - min) + min;
45 }
46
47 public static float Range(float min, float max)
48 {
49 return (float)(_random.NextDouble() * (double)(max - min) + (double)min);
50 }
51
52 public static int rnd(int max)
53 {
54 if (max > 0)
55 {
56 return _random.Next(max);
57 }
58 return 0;
59 }
60
61 public static float rndf(float max)
62 {
63 return Range(0f, max);
64 }
65
66 public static int rndSqrt(int max)
67 {
68 return _random.Next(_random.Next(max) + 1);
69 }
70
71 public static int rndNormal2(int max)
72 {
73 int num = max / 2;
74 return num + rnd(rnd(rnd(num) + 1) + 1) - rnd(rnd(rnd(num) + 1) + 1);
75 }
76
77 public static int rndNormal(int max)
78 {
79 int num = max / 2;
80 return num + rnd(rnd(num) + 1) - rnd(rnd(num) + 1);
81 }
82}
@ seed
Definition: Rand.cs:4
static float Range(float min, float max)
Definition: Rand.cs:47
static int MaxBytes
Definition: Rand.cs:5
static int rndNormal2(int max)
Definition: Rand.cs:71
static float rndf(float max)
Definition: Rand.cs:61
static Random _random
Definition: Rand.cs:7
static byte[] bytes
Definition: Rand.cs:9
static int rndSeed(int a, int seed)
Definition: Rand.cs:29
static int Range(int min, int max)
Definition: Rand.cs:42
static void InitBytes(int a)
Definition: Rand.cs:11
static void UseSeed(int seed, Action action)
Definition: Rand.cs:22
static int rndNormal(int max)
Definition: Rand.cs:77
static int rndSqrt(int max)
Definition: Rand.cs:66
static void SetSeed(int a=-1)
Definition: Rand.cs:37
static int rnd(int max)
Definition: Rand.cs:52