private int SerializeHeader(WorldData world) { WorldHeader header = world.GetHeader(); writer.Write(header.name); writer.Write(header.width); writer.Write(header.height); writer.Write(header.spawnArea.X); writer.Write(header.spawnArea.Y); return((int)writer.BaseStream.Position); }
private void SerializeSectionPointers(WorldData world, int[] pointers) { writer.BaseStream.Position = 0L; WorldHeader header = world.GetHeader(); writer.Write(world.GetVersion()); writer.Write((byte)pointers.Length); for (int i = 0; i < pointers.Length; i++) { writer.Write(pointers[i]); } }
public void Serialize(WorldData world) { WorldHeader header = world.GetHeader(); string dir = Path.Combine(Config.WorldSaveDirectory, header.name); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } fileStream = new FileStream(Path.Combine(dir, header.name + fileExtension), FileMode.Create, FileAccess.Write); writer = new BinaryWriter(fileStream); int[] sectionPointers = new int[numSections]; sectionPointers[0] = BlockOutSectionPointer(world); sectionPointers[1] = SerializeHeader(world); sectionPointers[2] = SerializeChunks(world); SerializeSectionPointers(world, sectionPointers); writer.Close(); fileStream.Close(); }
public WorldHeader GetWorldHeader() { return(worldData.GetHeader()); }