public EmberCell[] GetNeighbors(EmberCell cell) { int x = cell.Position.X; int y = cell.Position.Y; var points = new List <Point>(); if (!InBounds(x, y)) { return(Array.Empty <EmberCell>()); } if (InBounds(x + 1, y)) { points.Add(new Point(x + 1, y)); } if (InBounds(x - 1, y)) { points.Add(new Point(x - 1, y)); } if (InBounds(x, y + 1)) { points.Add(new Point(x, y + 1)); } if (InBounds(x, y - 1)) { points.Add(new Point(x, y - 1)); } if (InBounds(x + 1, y + 1)) { points.Add(new Point(x + 1, y + 1)); } if (InBounds(x - 1, y - 1)) { points.Add(new Point(x - 1, y - 1)); } if (InBounds(x + 1, y - 1)) { points.Add(new Point(x + 1, y - 1)); } if (InBounds(x - 1, y + 1)) { points.Add(new Point(x - 1, y + 1)); } return(points.Select(a => GetCell(a)).ToArray()); }
public void SetCell(EmberCell cell) { Cells[cell.Position.Y * GridSizeX + cell.Position.X] = cell; }