31 lines
677 B
C#
31 lines
677 B
C#
|
|
using Godot;
|
||
|
|
using System.Text;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using System.Linq;
|
||
|
|
|
||
|
|
namespace Rokojori
|
||
|
|
{
|
||
|
|
public static class ArrayExtensions
|
||
|
|
{
|
||
|
|
public static void ForEach<[MustBeVariant] T>( this Godot.Collections.Array<T> array, System.Action<T> action )
|
||
|
|
{
|
||
|
|
for (int i = 0; i < array.Count; i++)
|
||
|
|
{
|
||
|
|
action( array[i] );
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public static T Find<[MustBeVariant] T>( this Godot.Collections.Array<T> array, System.Func<T,bool> evaluater )
|
||
|
|
{
|
||
|
|
for ( int i = 0; i < array.Count; i++ )
|
||
|
|
{
|
||
|
|
if ( evaluater( array[ i ] ) )
|
||
|
|
{
|
||
|
|
return array[ i ];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return default(T);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|