Merge remote-tracking branch 'origin/feature/fight_system' into feature/showcase_kathi
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlTypes;
|
||||
using System.Linq;
|
||||
using System.Xml.Schema;
|
||||
namespace Babushka.scripts.CSharp.Common.Util;
|
||||
|
||||
public static class LinqExtras
|
||||
{
|
||||
public static void ForEach<T>(this IEnumerable<T> self, Action<T> action)
|
||||
{
|
||||
foreach (var t in self)
|
||||
{
|
||||
action.Invoke(t);
|
||||
}
|
||||
}
|
||||
|
||||
public static T? Random<T>(this IEnumerable<T> self)
|
||||
{
|
||||
var selfList = self.ToList();
|
||||
if (selfList.Count == 0) return default;
|
||||
if (selfList.Count == 1) return selfList[0];
|
||||
var randomIndex = new Random().Next(0, selfList.Count);
|
||||
return selfList[randomIndex];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
uid://clcirtaf47g5p
|
||||
Reference in New Issue
Block a user