/// <summary> Potentially generates meshes for several pending chunks. </summary>
 public void Update(double deltaTime)
 {
     if (chunks == null)
     {
         return;
     }
     ChunkSorter.UpdateSortOrder(game, updater);
     updater.UpdateChunks(deltaTime);
 }
        public void AdjChunks(int oldChunkX, int oldChunkZ)
        {
            int  length    = game.World.ChunkHandler.ChunkArray.GetLength(0);
            bool xNeg      = false;
            bool zNeg      = false;
            int  curChunkX = game.World.ChunkHandler.curChunkX;
            int  curChunkZ = game.World.ChunkHandler.curChunkY;

            if (oldChunkX > curChunkX)
            {
                xNeg = true;
            }
            if (oldChunkZ > curChunkZ)
            {
                zNeg = true;
            }
            int adjX = curChunkX - oldChunkX;
            int adjZ = curChunkZ - oldChunkZ;
            int curX = 0;

            if (xNeg)
            {
                curX = length - 1;
            }
            int curZ = 0;

            if (zNeg)
            {
                curZ = length - 1;
            }
            for (int x = 0; x < length; x++)
            {
                for (int z = 0; z < length; z++)
                {
                    int newX = curX - adjX;
                    Console.WriteLine(adjX);
                    int newZ = curZ - adjZ;
                    if (newX >= 0 && newZ >= 0 && newX < length && newZ < length)
                    {
                        for (int y = 0; y < 8; y++)
                        {
                            ChunkInfo info = GetChunk(curX, y, curZ);
                            if (info == null)
                            {
                                continue;
                            }
                            info.CentreX += (ushort)(16 * adjX);
                            info.CentreZ += (ushort)(16 * adjZ);
                            info.Reset(newX * 16, y * 16, newZ * 16);
                            SetChunk(newX, y, newZ, info);
                            //SetChunk(curX, y, curZ, null);
                            MarkDeleteChunk(curX, y, curZ);
                        }
                    }
                    else
                    {
                        for (int y = 0; y < 8; y++)
                        {
                            //SetChunk(curX, y, curZ, null);
                            MarkDeleteChunk(curX, y, curZ);
                        }
                    }
                    if (zNeg)
                    {
                        curZ -= 1;
                    }
                    else
                    {
                        curZ += 1;
                    }
                }
                if (xNeg)
                {
                    curX -= 1;
                }
                else
                {
                    curX += 1;
                }
                curZ = 0;
                if (zNeg)
                {
                    curZ = length - 1;
                }
            }
            updater.chunkPos = new Vector3I(0, 0, 0);
            ChunkSorter.UpdateSortOrder(game, updater);
        }