Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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]);
            }
        }
Esempio n. 3
0
        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();
        }
Esempio n. 4
0
 public WorldHeader GetWorldHeader()
 {
     return(worldData.GetHeader());
 }