Advertisement
Placido_GDD

Structure

Mar 4th, 2022
773
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public static class Structure
  6. {
  7.     public static Queue MakeTree(Vector3 position,int minTrunkHeight,int MaxTrunkHeight)
  8.     {
  9.         Queue<VoxelMod> queue = new Queue<VoxelMod>();
  10.         int height = (int)(MaxTrunkHeight * Noise.Get2DPerlin(new Vector3(position.x, position.z), 250f, 3f));
  11.         if (height < minTrunkHeight)
  12.             height = minTrunkHeight;
  13.  
  14.         for (int i = 1; i < height; i++)
  15.             queue.Enqueue(new VoxelMod(new Vector3(position.x, position.y + i, position.z), 6));
  16.  
  17.        for (int x = -3; x < 4; x++)
  18.         {
  19.             for (int y = 0; y < 7; y++)
  20.             {
  21.                 for (int z = -3; z < 4; z++)
  22.                 {
  23.                     queue.Enqueue(new VoxelMod(new Vector3(position.x + x, position.y + height + y, position.z + z), 11));
  24.                 }
  25.             }                
  26.         }
  27.         return queue;
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement