示例#1
0
        public byte[] Save()
        {
            //Save world to memory
            MemoryStream bytesStream = new MemoryStream();
            BinaryWriter bw          = new BinaryWriter(bytesStream);

            Save(bw, false);
            tileManager.Save(bw);
            itemManager.Save(bw);
            avatarManager.Save(bw);
            sectorManager.Save(bw);
            dayCycleManager.Save(bw);

            bw.Flush();

            byte[] bytes = bytesStream.ToArray();

            //Write header
            MemoryStream bytesStreamFinal = new MemoryStream();
            BinaryWriter bwFinal          = new BinaryWriter(bytesStreamFinal);

            bwFinal.Write(VERSION_INFO);
            bwFinal.Write(bytes.Length);
            bwFinal.Flush();

            //Compress and write world
            GZipStream gzipStream = new GZipStream(bytesStreamFinal, CompressionMode.Compress, true);

            gzipStream.Write(bytes, 0, bytes.Length);
            gzipStream.Close();

            return(bytesStreamFinal.ToArray());
        }
示例#2
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            m_sectorManager.Load(new FileInfo(ofdLoadSandbox.FileName));
            bool changed = false;

            foreach (var ship in m_sectorManager.Sector.CubeGrids)
            {
                foreach (var cube in ship.CubeBlocks)
                {
                    Type cubeType = cube.GetType();

                    if (cubeType == typeof(CubeBlockEntity))
                    {
                        CubeBlockEntity cubeBlock = (CubeBlockEntity)cube;

                        if (cubeBlock.Name == "LargeBlockInteriorWall")
                        {
                            MyBlockOrientation orientation = cubeBlock.BlockOrientation;

                            if (orientation.Up == Base6Directions.Direction.Up)
                            {
                                orientation.Up = Base6Directions.Direction.Down;
                                changed        = true;
                            }
                            else if (orientation.Up == Base6Directions.Direction.Down)
                            {
                                orientation.Up = Base6Directions.Direction.Up;
                                changed        = true;
                            }
                            cubeBlock.BlockOrientation = orientation;
                        }
                    }
                }
            }

            if (changed)
            {
                m_sectorManager.Save();
                MessageBox.Show("Save completed!");
            }
            else
            {
                MessageBox.Show("Nothing needs to be changed (No Interior wall was found)");
            }
        }