public static List <Vector3Int> FilterInvalidTiles(List <Vector3Int> tiles, RangeDefined.IsTileValidDel IsTileValid) { List <Vector3Int> temp = new List <Vector3Int>(tiles); foreach (var tile in temp) { if (IsTileValid != null && IsTileValid != CanAttackThrough && !IsTileValid(tile)) //Can Attack through only makes sense if it is accounted for while making the range, doesnt make sense just to exclude it { tiles.Remove(tile); } } return(tiles); }
public static List <Vector3Int> TilesInDirection(Vector3Int start, int dir, int dist, bool pierce, RangeDefined.IsTileValidDel IsTileValid) { if (IsTileValid == null) { IsTileValid = CanStandOn; } List <Vector3Int> tiles = new List <Vector3Int>(); Vector3Int current = start; for (int i = 0; i < dist; ++i) { Vector3Int next = GetTileInDirection(current, dir); if (IsTileValid == CanAttackThrough) { tiles.Add(next); } if (!IsTileValid(next) && !pierce) { break; } if (IsTileValid != CanAttackThrough) { tiles.Add(next); } current = next; } return(tiles); }