summaryrefslogtreecommitdiff
path: root/Client/Assembly-CSharp/RandomFill.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Client/Assembly-CSharp/RandomFill.cs')
-rw-r--r--Client/Assembly-CSharp/RandomFill.cs33
1 files changed, 33 insertions, 0 deletions
diff --git a/Client/Assembly-CSharp/RandomFill.cs b/Client/Assembly-CSharp/RandomFill.cs
new file mode 100644
index 0000000..352eafd
--- /dev/null
+++ b/Client/Assembly-CSharp/RandomFill.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+public class RandomFill<T>
+{
+ private T[] values;
+
+ private int idx;
+
+ public void Set(IEnumerable<T> values)
+ {
+ if (this.values == null)
+ {
+ this.values = values.ToArray<T>();
+ this.values.Shuffle<T>();
+ this.idx = this.values.Length - 1;
+ }
+ }
+
+ public T Get()
+ {
+ if (this.idx < 0)
+ {
+ this.values.Shuffle<T>();
+ this.idx = this.values.Length - 1;
+ }
+ T[] array = this.values;
+ int num = this.idx;
+ this.idx = num - 1;
+ return array[num];
+ }
+}