private unsafe int PatchLand( TileMatrix matrix, string dataPath, string indexPath ) { using ( FileStream fsData = new FileStream( dataPath, FileMode.Open, FileAccess.Read, FileShare.Read ) ) { using ( FileStream fsIndex = new FileStream( indexPath, FileMode.Open, FileAccess.Read, FileShare.Read ) ) { BinaryReader indexReader = new BinaryReader( fsIndex ); int count = (int)(indexReader.BaseStream.Length / 4); for ( int i = 0; i < count; ++i ) { int blockID = indexReader.ReadInt32(); int x = blockID / matrix.BlockHeight; int y = blockID % matrix.BlockHeight; fsData.Seek( 4, SeekOrigin.Current ); Tile[] tiles = new Tile[64]; fixed ( Tile *pTiles = tiles ) { _lread( fsData.Handle, pTiles, 192 ); } matrix.SetLandBlock( x, y, tiles ); } return count; } } }
public MultiComponentList( BinaryReader reader, int count ) { m_Min = m_Max = Point.Empty; MultiTileEntry[] allTiles = new MultiTileEntry[count]; for ( int i = 0; i < count; ++i ) { allTiles[i].m_ItemID = reader.ReadInt16(); allTiles[i].m_OffsetX = reader.ReadInt16(); allTiles[i].m_OffsetY = reader.ReadInt16(); allTiles[i].m_OffsetZ = reader.ReadInt16(); allTiles[i].m_Flags = reader.ReadInt32(); MultiTileEntry e = allTiles[i]; if ( e.m_OffsetX < m_Min.X ) m_Min.X = e.m_OffsetX; if ( e.m_OffsetY < m_Min.Y ) m_Min.Y = e.m_OffsetY; if ( e.m_OffsetX > m_Max.X ) m_Max.X = e.m_OffsetX; if ( e.m_OffsetY > m_Max.Y ) m_Max.Y = e.m_OffsetY; } m_Center = new Point( -m_Min.X, -m_Min.Y ); m_Width = (m_Max.X - m_Min.X) + 1; m_Height = (m_Max.Y - m_Min.Y) + 1; TileList[][] tiles = new TileList[m_Width][]; m_Tiles = new Tile[m_Width][][]; for ( int x = 0; x < m_Width; ++x ) { tiles[x] = new TileList[m_Height]; m_Tiles[x] = new Tile[m_Height][]; for ( int y = 0; y < m_Height; ++y ) tiles[x][y] = new TileList(); } for ( int i = 0; i < allTiles.Length; ++i ) { int xOffset = allTiles[i].m_OffsetX + m_Center.X; int yOffset = allTiles[i].m_OffsetY + m_Center.Y; tiles[xOffset][yOffset].Add( (short)((allTiles[i].m_ItemID & 0x3FFF) + 0x4000), (sbyte)allTiles[i].m_OffsetZ ); } for ( int x = 0; x < m_Width; ++x ) { for ( int y = 0; y < m_Height; ++y ) { m_Tiles[x][y] = tiles[x][y].ToArray(); if ( m_Tiles[x][y].Length > 1 ) Array.Sort( m_Tiles[x][y] ); } } }
private unsafe Tile[] ReadLandBlock( int x, int y ) { m_Map.Seek( ((x * m_BlockHeight) + y) * 196 + 4, SeekOrigin.Begin ); Tile[] tiles = new Tile[64]; fixed ( Tile *pTiles = tiles ) { _lread( m_Map.Handle, pTiles, 192 ); } return tiles; }
public void SetLandBlock( int x, int y, Tile[] value ) { if ( x < 0 || y < 0 || x >= m_BlockWidth || y >= m_BlockHeight ) return; if ( m_LandTiles[x] == null ) m_LandTiles[x] = new Tile[m_BlockHeight][]; m_LandTiles[x][y] = value; }
public Tile[] GetLandBlock( int x, int y ) { if ( x < 0 || y < 0 || x >= m_BlockWidth || y >= m_BlockHeight || m_Map == null ) return m_InvalidLandBlock; if ( m_LandTiles[x] == null ) m_LandTiles[x] = new Tile[m_BlockHeight][]; Tile[] tiles = m_LandTiles[x][y]; if ( tiles == null ) tiles = m_LandTiles[x][y] = ReadLandBlock( x, y ); return tiles; }
public Tile[] ToArray() { Tile[] tiles = new Tile[m_Count]; for ( int i = 0; i < m_Count; ++i ) tiles[i] = m_Tiles[i]; m_Count = 0; return tiles; }