Example #1
0
        public void UpdateClientChangedBlock(ClientChangedBlock changedBlock, bool refresh = false)
        {
            WorldPos pos = ClientChangedChunk.GetChunkPos(changedBlock.index);
            //			Debug.Log("updateClientChangedBlock:" + pos.ToString());
            Section s = GetSection(pos.y);
            Block   b = new Block((BlockType)changedBlock.blockType, changedBlock.extendId);

            s.SetBlock(pos.x, pos.y - s.chunkOffsetY, pos.z, b, true);
            if (refresh)
            {
                this.world.CheckAndRecalculateMesh(this, pos.x, pos.y, pos.z, b);
            }
        }
Example #2
0
 //初始化玩家所持有的chunk信息
 public void AddPlayerInChunks(ClientPlayer player, WorldPos pos, int sign)
 {
     lock (_chunkMap)
     {
         ClientChangedChunk changedChunk;
         _chunkMap.TryGetValue(pos, out changedChunk);
         if (changedChunk == null)
         {
             changedChunk = new ClientChangedChunk(pos);
             changedChunk.ChangeSign(sign);
             _chunkMap.Add(pos, changedChunk);
         }
         //				UnityEngine.Debug.Log("添加区块:" + pos.ToString() + " playerId:" + player.id);
         changedChunk.AddPlayer(player.id);
         player.AddChunkPos(pos);
     }
 }
Example #3
0
 public void Collection(WorldPos pos, int x, int y, int z, Block block)
 {
     if (canCollection)
     {
         List <ClientChangedBlock> list;
         _map.TryGetValue(pos, out list);
         if (list == null)
         {
             list = new List <ClientChangedBlock>();
             _map.Add(pos, list);
         }
         Int16 index     = ClientChangedChunk.GetChunkIndex(x, y, z);
         byte  blockType = (byte)block.BlockType;
         byte  extendId  = block.ExtendId;
         ClientChangedBlock changedBlock = new ClientChangedBlock(index, blockType, extendId);
         list.Add(changedBlock);
     }
 }
Example #4
0
 public void ChangedArea(RefreshChunkArea area)
 {
     lock (_chunkMap)
     {
         for (int i = 0; i < area.chunkList.Count; i++)
         {
             ClientChangedChunk changedChunk;
             _chunkMap.TryGetValue(area.chunkList[i].chunk.worldPos, out changedChunk);
             if (changedChunk != null)
             {
                 for (int j = 0; j < area.chunkList[i].refreshList.Count; j++)
                 {
                     Int16 index = ClientChangedChunk.GetChunkIndex(area.chunkList[i].refreshList[j].Pos.x, area.chunkList[i].refreshList[j].Pos.y, area.chunkList[i].refreshList[j].Pos.z);
                     ClientChangedBlock block = new ClientChangedBlock(index, (byte)area.chunkList[i].refreshList[j].type, area.chunkList[i].refreshList[j].exid);
                     changedChunk.ChangeBlock(block);
                 }
             }
         }
     }
 }