public Cell GetCell(CellCoordinate coord) { if (IsValidCoordinate(coord) == false) { throw CellCoordException.Invalid(coord); } Cell output = default(Cell); if (_world.TryGetValue(coord, out output) == false) { throw CellCoordException.NoData(coord); } return(output); }
public bool SetCell(CellCoordinate coord, Cell cell) { if (IsValidCoordinate(coord) == false) { throw CellCoordException.Invalid(coord); } var existingCell = default(Cell); if (_world.TryGetValue(coord, out existingCell) == false) { throw CellCoordException.NoData(coord); } // TODO perhaps validate the new cell? _world[coord] = cell; Events.Emit <IWorldEventHandler>(h => h.OnCellChanged(coord, existingCell, cell)); return(true); }