//
void AddTree(Map Lvl, ushort x, ushort z, ushort y, Random Rand)
{
byte height = (byte)Rand.Next(4, 7);
for (ushort zz = 0; zz < height; zz++)
{
if (Lvl.GetTile(x, (ushort)(z + zz), y) == Block.air) //Not likly to trigger anyway
{
Lvl.Blockchange(x, (ushort)(z + zz), y, Block.trunk);
}
else
{
height = (byte)zz;
}
}
short top = (short)(height - 3);
for (short xx = (short)-top; xx <= top; ++xx)
{
for (short yy = (short)-top; yy <= top; ++yy)
{
for (short zz = (short)-top; zz <= top; ++zz)
{
if (Lvl.GetTile((ushort)(x + xx), (ushort)(z + zz + height), (ushort)(y + yy)) == Block.air) //Not likly to trigger anyway
{
//short Dist = (short)(Math.Abs(xx) + Math.Abs(yy) + Math.Abs(zz));
short Dist = (short)(Math.Sqrt(xx * xx + yy * yy + zz * zz));
if (Dist < top + 1)
{
if (Rand.Next((int)(Dist)) < 2)
{
Lvl.Blockchange((ushort)(x + xx), (ushort)(z + zz + height), (ushort)(y + yy), Block.leaf);
}
}
}
}
}
}
}