Hex Update
This commit is contained in:
parent
1d37c3a6cf
commit
68105b2275
|
|
@ -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<HexagonCoord> 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<HexagonCoord> Ring( HexagonCoord center, int radius )
|
||||
{
|
||||
var results = new List<HexagonCoord>();
|
||||
|
|
|
|||
|
|
@ -237,6 +237,25 @@ namespace Rokojori
|
|||
}
|
||||
|
||||
#if !ROKOJORI_ACTION_CORE_GD
|
||||
|
||||
public T From<T>( HashSet<T> 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<T>( List<T> list )
|
||||
{
|
||||
if ( list.Count == 0 )
|
||||
|
|
|
|||
Loading…
Reference in New Issue