Ejemplo n.º 1
0
        public void MapSerializer()
        {
            var map = new Map2D <float>();

            map[0, 0]   = 1.0f;     // Chunk: (0,0,0)
            map[16, 16] = 2.0f;     // Chunk: (1,1,1)
            map[32, 32] = 4.0f;     // Chunk: (2,2,2)

            var list = new List <ChunkSpace>();

            map.RegisterWriter((xyz, items) =>
            {
                Console.WriteLine("Writing: ({0},{1},{2})", xyz.X, xyz.Y, xyz.Z);
                list.Add(xyz);
            });

            map.UnloadArea(new WorldSpace2D(0, 0), new WorldSpace2D(32, 32));

            Assert.AreEqual(3, list.Count);

            Assert.That(list.Contains(new ChunkSpace(0L, 0L, 0L)));
            Assert.That(list.Contains(new ChunkSpace(1L, 1L, 0L)));
            Assert.That(list.Contains(new ChunkSpace(2L, 2L, 0L)));

            map.UnregisterWriter();
            map[48, 48] = 4.0f;

            map.UnloadArea((0, 0), (48, 48));
            Assert.AreEqual(3, list.Count);
        }