public void read(Reader reader) { title = reader.readRSDKString(); activeLayer0 = (ActiveLayers)reader.ReadByte(); activeLayer1 = (ActiveLayers)reader.ReadByte(); activeLayer2 = (ActiveLayers)reader.ReadByte(); activeLayer3 = (ActiveLayers)reader.ReadByte(); layerMidpoint = (LayerMidpoints)reader.ReadByte(); // Map width/height in 128 pixel units // In RSDKv2 it's one byte long width = reader.ReadByte(); height = reader.ReadByte(); layout = new ushort[height][]; for (int i = 0; i < height; i++) { layout[i] = new ushort[width]; } for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { // 128x128 Block number is 16-bit // Big-Endian in RSDKv2 layout[y][x] = (ushort)(reader.ReadByte() << 8); layout[y][x] |= reader.ReadByte(); } } // Read number of object types int objectTypeCount = reader.ReadByte(); objectTypeNames.Clear(); for (int n = 0; n < objectTypeCount; n++) { objectTypeNames.Add(reader.readRSDKString()); } // Read entities // 2 bytes, big-endian, unsigned int entityCount = reader.ReadByte() << 8; entityCount |= reader.ReadByte(); entities.Clear(); for (int n = 0; n < entityCount; n++) { entities.Add(new Entity(reader)); } reader.Close(); }
public void read(Reader reader) { title = reader.readRSDKString(); activeLayer0 = (ActiveLayers)reader.ReadByte(); activeLayer1 = (ActiveLayers)reader.ReadByte(); activeLayer2 = (ActiveLayers)reader.ReadByte(); activeLayer3 = (ActiveLayers)reader.ReadByte(); layerMidpoint = (LayerMidpoints)reader.ReadByte(); // Map width in 128 pixel units // In RSDKv4 it's one byte long (with an unused byte after each one), little-endian width = reader.ReadByte(); reader.ReadByte(); // Unused height = reader.ReadByte(); reader.ReadByte(); // Unused layout = new ushort[height][]; for (int i = 0; i < height; i++) { layout[i] = new ushort[width]; } for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { // 128x128 Block number is 16-bit // Little-Endian in RSDKv4 layout[y][x] = reader.ReadByte(); layout[y][x] |= (ushort)(reader.ReadByte() << 8); } } // Read entities // 2 bytes, little-endian, unsigned int entityCount = reader.ReadByte(); entityCount |= reader.ReadByte() << 8; entities.Clear(); for (int o = 0; o < entityCount; o++) { entities.Add(new Entity(reader)); } reader.Close(); }