Created
May 3, 2012 17:30
-
-
Save TinkerWorX/2587445 to your computer and use it in GitHub Desktop.
An example message from Legeria.Networking.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[NetworkMessageData(0x0005, NetworkMessageTransport.TCP)] | |
public class NetworkMessageRealmSector : INetworkMessage | |
{ | |
public SectorPoint SectorPoint; | |
public Tile[,] Tiles; | |
public void Write(BinaryWriter writer) | |
{ | |
if (this.Tiles == null) throw new Exception("this.Tiles must be initialized with Tile data."); | |
writer.Write(this.SectorPoint.PackedValue); | |
for (var x = 0; x < TileWorX.SECTOR_TILE_SIZE; x += 1) | |
{ | |
for (var y = 0; y < TileWorX.SECTOR_TILE_SIZE; y += 1) | |
{ | |
writer.Write(this.Tiles[x, y].BackType.Id); | |
writer.Write(this.Tiles[x, y].BaseType.Id); | |
} | |
} | |
} | |
public void Read(BinaryReader reader) | |
{ | |
this.Tiles = new Tile[TileWorX.SECTOR_TILE_SIZE, TileWorX.SECTOR_TILE_SIZE]; | |
this.SectorPoint = new SectorPoint(reader.ReadUInt16()); | |
for (var x = 0; x < TileWorX.SECTOR_TILE_SIZE; x += 1) | |
{ | |
for (var y = 0; y < TileWorX.SECTOR_TILE_SIZE; y += 1) | |
{ | |
this.Tiles[x, y] = new Tile( | |
reader.ReadByte(), // BackType.Id | |
reader.ReadByte()); // BaseType.Id | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment