private unsafe Tile[] ReadLandBlock(int x, int y) { if (_mapStream == null) return _invalidLandBlock; _mapStream.Seek(((x * _blockHeight) + y) * 196 + 4, SeekOrigin.Begin); Tile[] tiles = new Tile[64]; fixed (Tile* pTiles = tiles) { byte[] buffer = new byte[192]; _mapStream.Read(buffer, 0, buffer.Length); using (MemoryStream stream = new MemoryStream(buffer)) using (BinaryReader reader = new BinaryReader(stream)) { Tile* ptr = pTiles; for (int i = 0; i < 64; i++) { ptr->_id = reader.ReadInt16(); ptr->_z = reader.ReadSByte(); ptr++; } } } return tiles; }
public Tile[] GetLandBlock(int x, int y) { if (x < 0 || y < 0 || x >= _blockWidth || y >= _blockHeight || _mapStream == null) return _invalidLandBlock; if (_landTiles[x] == null) _landTiles[x] = new Tile[_blockHeight][]; Tile[] tiles = _landTiles[x][y] ?? (_landTiles[x][y] = ReadLandBlock(x, y)); return tiles; }