public static List <T> TileRandomFill <T>(this T[,] tileArray, System.Random seed, TileAxis originAxis, Action <T> OnEachFill, Predicate <T> availableAxis, int fillCount) where T : class, ITileAxis { List <T> targetList = new List <T>(); T targetAdd = tileArray.Get(originAxis); OnEachFill(targetAdd); targetList.Add(targetAdd); for (int i = 0; i < fillCount; i++) { T temp = targetList[i]; m_EdgeDirections.TraversalRandomBreak((enum_TileDirection randomDirection) => { TileAxis axis = temp.m_Axis.DirectionAxis(randomDirection); if (axis.InRange(tileArray)) { targetAdd = tileArray.Get(axis); if (availableAxis(targetAdd)) { OnEachFill(targetAdd); targetList.Add(targetAdd); return(true); } } return(false); }, seed); } return(targetList); }
public static bool ArrayNearbyContains <T>(this T[,] tileArray, TileAxis origin, Predicate <T> predicate) where T : class, ITileAxis { TileAxis[] nearbyTiles = origin.nearbyFourTiles; for (int i = 0; i < nearbyTiles.Length; i++) { if (origin.InRange(tileArray) && !predicate(tileArray.Get(nearbyTiles[i]))) { return(false); } } return(true); }
public static T Get <T>(this T[,] tileArray, TileAxis axis) where T : class => axis.InRange(tileArray) ? tileArray[axis.X, axis.Y] : null;