diff --git a/Runtime/Math/Hexagon/HexagonCoord.cs b/Runtime/Math/Hexagon/HexagonCoord.cs index 6e38e92..159cb64 100644 --- a/Runtime/Math/Hexagon/HexagonCoord.cs +++ b/Runtime/Math/Hexagon/HexagonCoord.cs @@ -51,6 +51,7 @@ public struct HexagonCoord public static HexagonCoord Direction( int direction ) { + RJLog.Log( direction ); return directions[ direction ]; } @@ -60,6 +61,14 @@ public struct HexagonCoord return this + directions[ direction ]; } + public void ForEachNeighbor( System.Action callback ) + { + for ( int i = 0; i < directions.Length; i++ ) + { + callback( Neighbor( i ) ); + } + } + public Vector3 ToWorldPosition( float size ) { var x = size * 1.5f * q; @@ -138,6 +147,8 @@ public struct HexagonCoord return Ring( HexagonCoord.Center, radius ); } + + public static List Ring( HexagonCoord center, int radius ) { var results = new List(); diff --git a/Runtime/Random/RandomEngine.cs b/Runtime/Random/RandomEngine.cs index aa73869..be658a9 100644 --- a/Runtime/Random/RandomEngine.cs +++ b/Runtime/Random/RandomEngine.cs @@ -237,6 +237,25 @@ namespace Rokojori } #if !ROKOJORI_ACTION_CORE_GD + + public T From( HashSet set ) + { + var count = set.Count; + + var index = IntegerExclusivePositive( count ); + + foreach ( T item in set) + { + if ( index-- == 0 ) + { + return item; + } + } + + return default(T); + + } + public T From( List list ) { if ( list.Count == 0 )