fix random puzzle order
This commit is contained in:
@@ -86,8 +86,7 @@ namespace EscapeRoomEngine.Engine.Runtime
|
||||
Space space;
|
||||
Passage exit = null;
|
||||
|
||||
var puzzle = _puzzles[0];
|
||||
_puzzles.RemoveAt(0);
|
||||
var puzzle = _puzzles.PopRandomElement();
|
||||
|
||||
do
|
||||
{
|
||||
|
||||
@@ -27,7 +27,14 @@ namespace EscapeRoomEngine.Engine.Runtime.Utilities
|
||||
public static int RandomInclusive(int from, int to) => Random.Range(from, to + 1);
|
||||
|
||||
public static T RandomElement<T>(this List<T> list) => list[Random.Range(0, list.Count)];
|
||||
public static T RandomElement<T>(this HashSet<T> set) => set.ElementAt(Random.Range(0, set.Count));
|
||||
|
||||
public static T PopRandomElement<T>(this List<T> list)
|
||||
{
|
||||
var index = Random.Range(0, list.Count);
|
||||
var element = list[index];
|
||||
list.RemoveAt(index);
|
||||
return element;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user