Exemple #1
0
        /// <summary>
        ///  Re-centers the world on the given chunk, loading neighboring chunks when needed.
        /// </summary>
        /// <param name="position"> The position to recenter on. </param>
        public void Recenter(WorldPosition position)
        {
            TileCoordinate  _1;
            ChunkCoordinate chunkCoordinate;

            position.CalculateCoordinates(out chunkCoordinate, out _1);
            Recenter(chunkCoordinate);
        }
Exemple #2
0
        public void RoundTrip()
        {
            var values = new EntryList()
            {
                {
                    new WorldPosition(5, 5),
                    new ChunkCoordinate(0, 0),
                    new TileCoordinate(5, 5)
                },
                {
                    new WorldPosition(Chunk.Length + 5, 5),
                    new ChunkCoordinate(1, 0),
                    new TileCoordinate(5, 5)
                },
                {
                    new WorldPosition(-5, 5),
                    new ChunkCoordinate(-1, 0),
                    new TileCoordinate(Chunk.Length - 5, 5)
                },
            };

            int i = 0;

            foreach (var value in values)
            {
                var actualWorld = new WorldPosition(value.ChunkCoordinate, value.TileCoordinate);
                Assert.AreEqual(value.WorldPosition, actualWorld);

                ChunkCoordinate actualChunk;
                TileCoordinate  actualTile;

                actualWorld.CalculateCoordinates(out actualChunk, out actualTile);
                Assert.AreEqual(value.ChunkCoordinate, actualChunk);
                Assert.AreEqual(value.TileCoordinate, actualTile);
                i++;
            }
        }