private static void FindCover(int x, int y, PathfindingGrid flyable, List <ProjectileCover> result) { foreach (Vector2 direction in directions) { int adjX = (int)direction.x + x; int adjY = (int)direction.y + y; if (flyable.IsInside(adjX, adjY) && flyable.GetCell(adjX, adjY) == null) { Vector2 offset = new Vector2(-direction.y, direction.x); offset.x *= flyable.GetCellSize().x * 0.5f; offset.y *= flyable.GetCellSize().y * 0.5f; Vector2 center = (flyable.CellCenter(x, y) + flyable.CellCenter((int)direction.x + x, (int)direction.y + y)) * 0.5f; result.Add(new ProjectileCover(center + offset, center - offset)); } } }