private void NetGeneratorWorker() { NetPriorityChunk netPriorityChunk = DeNetGeneratorQueue(); if (netPriorityChunk != null) { Chunk chunk = netPriorityChunk.netChunk.chunk; if (!netPriorityChunk.netChunk.chunkData.isExist) { WorldPos pos = chunk.worldPos; if (World.world.GetChunk(pos.x, pos.y, pos.z) == null) { return; } if (!chunk.isTerrainDataPrepared) { _terrainControlGenerator.Generate(chunk); if (WorldConfig.Instance.CaveEnable) { _cavesGenerator.generate(chunk); } chunk.isTerrainDataPrepared = true; chunk.isUpdate = true; //这里是地形数据在本机上产生时,需要发送到服务器上 EventManager.SendEvent(EventMacro.CHUNK_DATA_GENERATE_FINISH, chunk); } } //如果服务器上已经有最新的数据,拿到最新的数据更改 if (netPriorityChunk.netChunk.chunkData.hasChangeData) { ClientChangedChunkData changedData = netPriorityChunk.netChunk.chunkData.changedData; chunk.UpdateSign(changedData.sign); if (changedData.list.Count > 0) { for (int i = 0; i < changedData.list.Count; i++) { ClientChangedBlock changedBlock = changedData.list[i]; chunk.UpdateClientChangedBlock(changedBlock); } ReculateChunkLightAndAround(chunk); } } CheckAroundChunkAndGeneratorPopulation(chunk, true); } //////////////////////////////////////////////////// //收到服务器同步的大块更改数据 refreshNetArea(); }
public override void ClientDo(ServerConnectionWorker connectionWork) { Chunk chunk = World.world.GetChunk(pos.x, pos.y, pos.z); chunk.UpdateClientChangedBlock(changedBlock, true); }