/** * Add a TileIndexDiffC to a TileIndex and returns the new one. * * Returns tile + the diff given in diff. If the result tile would end up * outside of the map, INVALID_TILE is returned instead. * * @param tile The base tile to add the offset on * @param diff The offset to add on the tile * @return The resulting TileIndex */ //inline public static TileIndex AddTileIndexDiffCWrap(TileIndex tile, TileIndexDiffC diff) { var x = (uint)(TileX(tile) + diff.x); var y = (uint)(TileY(tile) + diff.y); /* Negative value will become big positive value after cast */ if (x >= MapSizeX() || y >= MapSizeY()) { return(TileConstants.INVALID_TILE); } return(TileXY(x, y)); }
/** * Return the offset between to tiles from a TileIndexDiffC struct. * * This function works like #TileDiffXY(int, int) and returns the * difference between two tiles. * * @param tidc The coordinate of the offset as TileIndexDiffC * @return The difference between two tiles. * @see TileDiffXY(int, int) */ //inline public static TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc) { return((tidc.y << (int)MapLogX()) + tidc.x); }