public IEnumerable<Cell> Find(CellList list, Point position) { var generator = new GeneratePointsAroundPoint(); IEnumerable<Point> points = generator.Generate(position); var cellFinder = new FindCellAtPosition(); return points.Select(p => cellFinder.Find(list, p)).Where(c => c != null); }
IEnumerable<Cell> FindOrGenerateNeighbourCells(CellList list, Cell cell) { IEnumerable<Point> points = new GeneratePointsAroundPoint().Generate(cell.Point); foreach (Point point in points) { Cell match = new FindCellAtPosition().Find(list, point); if (match != null) { yield return match; } else { yield return new AddNewCellToList(point, CellState.Dead).ToList(list); } } }