From e9ea621b93fbb58d9edfca8375918791637bbd52 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 30 Dec 2020 20:59:04 +0800 Subject: +init --- Client/Assembly-CSharp/RandomFill.cs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Client/Assembly-CSharp/RandomFill.cs (limited to 'Client/Assembly-CSharp/RandomFill.cs') 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 +{ + private T[] values; + + private int idx; + + public void Set(IEnumerable values) + { + if (this.values == null) + { + this.values = values.ToArray(); + this.values.Shuffle(); + this.idx = this.values.Length - 1; + } + } + + public T Get() + { + if (this.idx < 0) + { + this.values.Shuffle(); + this.idx = this.values.Length - 1; + } + T[] array = this.values; + int num = this.idx; + this.idx = num - 1; + return array[num]; + } +} -- cgit v1.1-26-g67d0