Exemplo n.º 1
0
        public static void TestAddChunkToUnloadedChunks(GameSave gameSave, Header header)
        {
            ChunkTable oldChunkTable = header.SaveIndex.ChunkTable;

            var octree         = new Octree(gameSave, new BitArray(new[] { false, false }), new byte[] { 1 });
            var blockTypeTable = new BlockTypeTable(gameSave,
                                                    new[]
            {
                new StringBlock(gameSave, "Block 0"),
                new StringBlock(gameSave, "Block 1"),
                new StringBlock(gameSave, "Block 2"),
                new StringBlock(gameSave, "Block 2")
            },
                                                    new[] { 0, 0, 0, 1 });
            var chunk = new Chunk(gameSave, blockTypeTable, new[] { octree });

            var r = new Random();

            int x = r.Next();
            int z = r.Next();

            List <Tuple <int, int, Chunk> > chunks =
                oldChunkTable.GetChunks().Where(c => c.Item1 != x || c.Item2 != z).ToList();

            chunks.Add(new Tuple <int, int, Chunk>(x, z, chunk));

            var chunkTable = new ChunkTable(gameSave, chunks.ToArray());
            var mainIndex  = new SavedStateIndex(gameSave, DateTime.UtcNow.Ticks,
                                                 new StringBlock(gameSave, "ChunkTable Length: " + chunkTable.Length),
                                                 chunkTable);
            var newHeader = new Header(gameSave, mainIndex);

            newHeader.Write(true);
        }
Exemplo n.º 2
0
        public static void TestAddChunkToUnloadedChunks(GameSave gameSave, Header header)
        {
            ChunkTable oldChunkTable = header.SaveIndex.ChunkTable;

            var octree = new Octree(gameSave, new BitArray(new[] { false, false }), new byte[] { 1 });
            var blockTypeTable = new BlockTypeTable(gameSave,
                                                    new[]
                                                        {
                                                            new StringBlock(gameSave, "Block 0"),
                                                            new StringBlock(gameSave, "Block 1"),
                                                            new StringBlock(gameSave, "Block 2"),
                                                            new StringBlock(gameSave, "Block 2")
                                                        },
                                                    new[] { 0, 0, 0, 1 });
            var chunk = new Chunk(gameSave, blockTypeTable, new[] { octree });

            var r = new Random();

            int x = r.Next();
            int z = r.Next();

            List<Tuple<int, int, Chunk>> chunks =
                oldChunkTable.GetChunks().Where(c => c.Item1 != x || c.Item2 != z).ToList();
            chunks.Add(new Tuple<int, int, Chunk>(x, z, chunk));

            var chunkTable = new ChunkTable(gameSave, chunks.ToArray());
            var mainIndex = new SavedStateIndex(gameSave, DateTime.UtcNow.Ticks,
                                                new StringBlock(gameSave, "ChunkTable Length: " + chunkTable.Length),
                                                chunkTable);
            var newHeader = new Header(gameSave, mainIndex);

            newHeader.Write(true);
        }
Exemplo n.º 3
0
        public Chunk(GameSave gameSave, BlockTypeTable blockTypeTable, Octree[] octrees)
            : base(gameSave)
        {
            _blockTypeTable = blockTypeTable;
            _octrees = octrees;

            UpdateLength();
        }
Exemplo n.º 4
0
        public static void TestSaving(GameSave gameSave, string saveName)
        {
            var octree         = new Octree(gameSave, new BitArray(new[] { false, false }), new byte[] { 1 });
            var blockTypeTable = new BlockTypeTable(gameSave,
                                                    new[]
            {
                new StringBlock(gameSave, "Block 0"),
                new StringBlock(gameSave, "Block 1"),
                new StringBlock(gameSave, "Block 2"),
                new StringBlock(gameSave, "Block 2")
            },
                                                    new[] { 0, 0, 0, 1 });
            var chunk      = new Chunk(gameSave, blockTypeTable, new[] { octree });
            var chunkTable = new ChunkTable(gameSave, new[] { 0 }, new[] { 0 }, new[] { chunk });
            var mainIndex  = new SavedStateIndex(gameSave, DateTime.UtcNow.Ticks, new StringBlock(gameSave, saveName),
                                                 chunkTable);
            var header = new Header(gameSave, mainIndex);

            header.Write(true);
        }
Exemplo n.º 5
0
        protected override void ReadData(BinaryReader reader)
        {
            _blockTypeTable = BlockTypeTable.FromSave(GameSave, ReadAddress(reader));

            byte octreeCount = reader.ReadByte();
            _octrees = new Octree[octreeCount];

            for (int i = 0; i < octreeCount; i++)
            {
                _octrees[i] = Octree.FromSave(GameSave, ReadAddress(reader));
            }
        }
Exemplo n.º 6
0
 protected override void ForgetData()
 {
     _blockTypeTable = null;
     _octrees = null;
 }
Exemplo n.º 7
0
        public static void TestSaving(GameSave gameSave, string saveName)
        {
            var octree = new Octree(gameSave, new BitArray(new[] { false, false }), new byte[] { 1 });
            var blockTypeTable = new BlockTypeTable(gameSave,
                                                    new[]
                                                        {
                                                            new StringBlock(gameSave, "Block 0"),
                                                            new StringBlock(gameSave, "Block 1"),
                                                            new StringBlock(gameSave, "Block 2"),
                                                            new StringBlock(gameSave, "Block 2")
                                                        },
                                                    new[] { 0, 0, 0, 1 });
            var chunk = new Chunk(gameSave, blockTypeTable, new[] { octree });
            var chunkTable = new ChunkTable(gameSave, new[] { 0 }, new[] { 0 }, new[] { chunk });
            var mainIndex = new SavedStateIndex(gameSave, DateTime.UtcNow.Ticks, new StringBlock(gameSave, saveName),
                                                chunkTable);
            var header = new Header(gameSave, mainIndex);

            header.Write(true);
        }