Update 07.12.2022
This commit is contained in:
17
C#/FiveM/TaxiJob/TaxiJob.Shared/ArrayExtensions.cs
Normal file
17
C#/FiveM/TaxiJob/TaxiJob.Shared/ArrayExtensions.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace TaxiJob.Shared {
|
||||
public static class ArrayExtensions {
|
||||
|
||||
public static T Random<T>(this IEnumerable<T> enumerable, [Optional] int seed) {
|
||||
var random = new Random(seed != 0 ? seed : Environment.TickCount);
|
||||
var array = enumerable.ToArray();
|
||||
var index = random.Next(array.Length);
|
||||
return array[index];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user