public bool Contains(GridPosition2D position) { var arrayPosition = (Point2D)position - Center; return(Utilities.IsInInterval(arrayPosition.X, 0, Grid.GetLength(0)) && Utilities.IsInInterval(arrayPosition.Y, 0, Grid.GetLength(1))); }
public BoundedGridField2D <TCell> GetWith(TCell cell, GridPosition2D position) { var newGrid = (TCell[, ])Grid.Clone(); position = (GridPosition2D)((Point2D)position - Center); newGrid[position.X, position.Y] = cell; return(new BoundedGridField2D <TCell>(newGrid, Center)); }
public TCell this[GridPosition2D position] { get { if (!Contains(position)) { throw new ArgumentException(nameof(position)); } var arrayPosition = (Point2D)position - Center; return(Grid[arrayPosition.X, arrayPosition.Y]); } }