Organize custom scripts and Shared under Assets/Scripts, and delete assembly definition files
This commit is contained in:
25
Assets/Scripts/Baba_yaga/GameSetup/Maze/Extensions.cs
Normal file
25
Assets/Scripts/Baba_yaga/GameSetup/Maze/Extensions.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Baba_yaga.GameSetup.Maze.Extensions
|
||||
{
|
||||
public static class ListExtensions
|
||||
{
|
||||
private static System.Random _rng = new System.Random();
|
||||
|
||||
/// <summary>
|
||||
/// Shuffles a list using the Fisher-Yates algorithm.
|
||||
/// </summary>
|
||||
public static void Shuffle<T>(this IList<T> list)
|
||||
{
|
||||
int n = list.Count;
|
||||
while (n > 1)
|
||||
{
|
||||
n--;
|
||||
int k = _rng.Next(n + 1);
|
||||
T value = list[k];
|
||||
list[k] = list[n];
|
||||
list[n] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user