public void SetWallBit(int x, int y, CartesianGridDirectionBit directionBit) { if (new CartesianGridCoordinates { x = (short)x, y = (short)y }.OnGrid(RowCount, ColCount)) { Walls[y * WallRowStride + (x >> 1)] |= (byte)((byte)directionBit << (4 * (x & 1))); } }
public bool TestWallBit(int x, int y, CartesianGridDirectionBit directionBit) { if (!(new CartesianGridCoordinates { x = (short)x, y = (short)y }.OnGrid(RowCount, ColCount))) { return(false); } return(((Walls[y * WallRowStride + (x >> 1)] >> (4 * (x & 1))) & (byte)directionBit) == (byte)directionBit); }
public bool TestWallBit(int cellIndex, CartesianGridDirectionBit directionBit) { var cellPosition = CartesianGridOnCubeUtility.CellFaceCoordinates(cellIndex, RowCount); var faceIndex = CartesianGridOnCubeUtility.CellFaceIndex(cellIndex, RowCount); var rowStride = (RowCount + 1) / 2; var faceStride = RowCount * rowStride; var faceGridWallsOffset = faceIndex * faceStride; var x = cellPosition.x; var y = cellPosition.y; var gridWallsIndex = faceGridWallsOffset + ((y * ((RowCount + 1) / 2)) + (x / 2)); Assert.IsTrue(cellPosition.OnGrid(RowCount, RowCount)); return(((Walls[gridWallsIndex] >> (4 * (x & 1))) & (byte)directionBit) == (byte)directionBit); }