//如果当前本机客户端没有产生生物群落,而其他客户端产生生物群落时,将产生的生物群落更新到当前客户端上
        public void EnqueueUpdatePopulation(NetChunk netChunk)
        {
            NetPriorityChunk priorityChunk = new NetPriorityChunk(netChunk);

            priorityChunk.Priority = GetPriority(netChunk.chunkPos, netChunk.curPlayerInChunkPos);
            generatorWorker.EnNetGeneratorQueue(priorityChunk);
        }
        //将从服务器端获取的数据序列化成chunk数据(联机使用)
        public void EnqueueNetChunk(NetChunk netChunk)
        {
            NetPriorityChunk priorityChunk = new NetPriorityChunk(netChunk);

            priorityChunk.Priority = GetPriority(netChunk.chunkPos, netChunk.curPlayerInChunkPos);
            persistanceWorker.EnNetChunkLoadQueue(priorityChunk);
        }
        public void UpdatePopulationFromServer(NetChunkData data, WorldPos curInChunkPos)
        {
            WorldPos pos      = data.worldPos;
            Chunk    curChunk = _world.GetChunk(pos.x, pos.y, pos.z);

            if (curChunk != null)
            {
                NetChunk netChunk = new NetChunk(data);
                netChunk.chunk = curChunk;
                netChunk.curPlayerInChunkPos = curInChunkPos;
                _manager.EnqueueUpdatePopulation(netChunk);
            }
        }
        //(联机使用)
        public void GenerateNetChunk(NetChunkData data, WorldPos curInChunkPos)
        {
            WorldPos pos      = data.worldPos;
            Chunk    newChunk = _world.GetChunk(pos.x, pos.y, pos.z);

            if (newChunk != null)
            {
                NetChunk netChunk = new NetChunk(data);
                netChunk.chunk = newChunk;
                netChunk.curPlayerInChunkPos = curInChunkPos;
                _manager.EnqueueNetChunk(netChunk);
            }
        }
        public Chunk GetChunk(NetChunk netChunk)
        {
            Chunk chunk = netChunk.chunk;

            _ms.SetLength(0);
            _ms.Write(netChunk.chunkData.data.data, 0, netChunk.chunkData.data.data.Length);
            _ms.Position = 0;
            IMTBCompress compress = MTBCompressFactory.GetCompress(netChunk.chunkData.data.compressType);

            _ms          = (MemoryStream)compress.Decompress(_ms);
            _ms.Position = 0;
            chunk.Deserialize(_ms);
            return(chunk);
        }
        public NetChunkData GetNetChunkData(NetChunk netChunk)
        {
            Chunk chunk = netChunk.chunk;

            _ms.SetLength(0);
            chunk.Serialize(_ms);
            _ms.Position = 0;
            IMTBCompress compress = MTBCompressFactory.GetCompress(MTBCompressType.ZLib);

            _ms          = (MemoryStream)compress.Encompress(_ms);
            _ms.Position = 0;
            netChunk.chunkData.data.data         = _ms.ToArray();
            netChunk.chunkData.data.compressType = MTBCompressType.ZLib;
            return(netChunk.chunkData);
        }
 public NetPriorityChunk(NetChunk chunk)
 {
     this.netChunk = chunk;
 }
 public NetPriorityChunk(NetChunk chunk, double priority)
 {
     this.netChunk = chunk;
     Priority      = priority;
 }