Example #1
0
        public void MapDeserializer()
        {
            var map = new Map2D <float>(16, 16);
            int i   = 0;

            // Assert that the Reader function is called for each new chunk loaded into memory
            map.RegisterReader(tuple =>
            {
                i++;
                return(new Chunk <float>(16, 16));
            });

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

            Assert.AreEqual(3, i);

            map.UnregisterReader();
            map[48, 48] = 8.0f;

            // Assert that after unregistering, the callback is not invoked.
            Assert.AreEqual(3, i);
        }