Unstable v0.9.707.0

This commit is contained in:
Juan Pablo Arce
2020-02-11 16:07:21 -03:00
parent 8324d20464
commit 2783125162
68 changed files with 1460 additions and 1219 deletions
@@ -17,9 +17,18 @@ namespace Barotrauma.Extensions
/// <summary>
/// Randomizes the list in place.
/// </summary>
public static void RandomizeList<T>(this List<T> source)
public static void RandomizeList<T>(this List<T> list)
{
source.Sort((x, y) => Rand.Value().CompareTo(Rand.Value()));
//Fisher-Yates shuffle
int n = list.Count;
while (n > 1)
{
n--;
int k = Rand.Int(n + 1);
T value = list[k];
list[k] = list[n];
list[n] = value;
}
}
public static T GetRandom<T>(this IEnumerable<T> source, Func<T, bool> predicate, Rand.RandSync randSync = Rand.RandSync.Unsynced)