示例#1
0
        public void LoadChunks()
        {
            int xWidth = WorldConfig.Instance.extendChunkWidth * Chunk.chunkWidth;
            int zWidth = WorldConfig.Instance.extendChunkWidth * Chunk.chunkDepth;

            for (int x = -xWidth; x <= xWidth; x += Chunk.chunkWidth)
            {
                for (int z = -zWidth; z <= zWidth; z += Chunk.chunkDepth)
                {
                    WorldPos chunkPos = new WorldPos(_curChunkPos.x + x, _curChunkPos.y, _curChunkPos.z + z);
                    if (!world.chunks.ContainsKey(chunkPos))
                    {
                        double dis = x * x + z * z;
                        if (dis <= loadPowWidth)
                        {
                            PriorityWorldPos priorityWorldPos = GetPriorityPos(chunkPos);
                            loadQueue.Enqueue(priorityWorldPos, priorityWorldPos.Priority);
                        }
                    }
                }
            }

            while (loadQueue.Count > 0)
            {
                PriorityWorldPos priorityPos = loadQueue.Dequeue();
                WorldPos         pos         = priorityPos.pos;
                world.WorldGenerator.GenerateFromServer(pos.x, pos.y, pos.z);
            }
        }
示例#2
0
        private PriorityWorldPos GetPriorityPos(WorldPos pos)
        {
            PriorityWorldPos priorityPos = new PriorityWorldPos(pos, GetPriority(pos, _curChunkPos));

            return(priorityPos);
        }