Exemple #1
0
 /// <summary>
 /// Cange the block at location in a chunk
 /// </summary>
 /// <param name="newBlock">The block to replace the current one in the chunk with</param>
 /// <param name="updateNeighbors">Whether or not to update this block and all it's neighbors as well</param>
 public void updateBlock(Block newBlock)
 {
     if (newBlock.isValid)
     {
         // first, see if this chunk is still empty
         isEmpty = !isEmpty ? isEmpty : BlockTypes.isEmpty(newBlock.type);
         newBlock.setParent(this);
         setBlock(newBlock);
     }
 }
 /// <summary>
 /// Generate mesh and uvs etc for the attached chunk
 /// </summary>
 void generateMesh()
 {
     if (chunk == null)
     {
         Debug.Log("No Chunk Provided For Render");
         return;
     }
     chunk.forEach(
         (Block block) => {
         if (!block.isEmpty)
         {
             if (BlockTypes.isEmpty(block.toThe(Directions.north, chunk).type))
             {
                 CubeNorth(block.location.x, block.location.y, block.location.z, block);
             }
             if (BlockTypes.isEmpty(block.toThe(Directions.east, chunk).type))
             {
                 CubeEast(block.location.x, block.location.y, block.location.z, block);
             }
             if (BlockTypes.isEmpty(block.toThe(Directions.south, chunk).type))
             {
                 CubeSouth(block.location.x, block.location.y, block.location.z, block);
             }
             if (BlockTypes.isEmpty(block.toThe(Directions.west, chunk).type))
             {
                 CubeWest(block.location.x, block.location.y, block.location.z, block);
             }
             if (BlockTypes.isEmpty(block.toThe(Directions.up, chunk).type))
             {
                 CubeTop(block.location.x, block.location.y, block.location.z, block);
             }
             if (BlockTypes.isEmpty(block.toThe(Directions.down, chunk).type))
             {
                 CubeBottom(block.location.x, block.location.y, block.location.z, block);
             }
         }
     }
         );
 }