2015-03-01 00:24:29 -05:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using TrueCraft.API.World;
|
|
|
|
|
using TrueCraft.API;
|
|
|
|
|
using TrueCraft.Core.Logic.Blocks;
|
|
|
|
|
using TrueCraft.Core.World;
|
|
|
|
|
|
|
|
|
|
namespace TrueCraft.Core.TerrainGen.Decorations
|
|
|
|
|
{
|
|
|
|
|
public class BirchTree : Decoration
|
|
|
|
|
{
|
2015-04-26 18:08:56 -06:00
|
|
|
|
const int LeafRadius = 2;
|
2015-03-01 00:24:29 -05:00
|
|
|
|
|
|
|
|
|
public override bool ValidLocation(Coordinates3D location)
|
|
|
|
|
{
|
2015-04-26 18:08:56 -06:00
|
|
|
|
if (location.X - LeafRadius < 0
|
|
|
|
|
|| location.X + LeafRadius >= Chunk.Width
|
|
|
|
|
|| location.Z - LeafRadius < 0
|
|
|
|
|
|| location.Z + LeafRadius >= Chunk.Depth)
|
|
|
|
|
{
|
2015-03-01 00:24:29 -05:00
|
|
|
|
return false;
|
2015-04-26 18:08:56 -06:00
|
|
|
|
}
|
2015-03-01 00:24:29 -05:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool GenerateAt(IWorld world, IChunk chunk, Coordinates3D location)
|
|
|
|
|
{
|
|
|
|
|
if (!ValidLocation(location))
|
|
|
|
|
return false;
|
|
|
|
|
|
2015-04-26 18:08:56 -06:00
|
|
|
|
var random = new Random(world.Seed);
|
|
|
|
|
int height = random.Next(4, 5);
|
|
|
|
|
GenerateColumn(chunk, location, height, WoodBlock.BlockID, 0x2);
|
|
|
|
|
var leafLocation = location + new Coordinates3D(0, height, 0);
|
|
|
|
|
GenerateVanillaLeaves(chunk, leafLocation, LeafRadius, LeavesBlock.BlockID, 0x2);
|
2015-03-01 00:24:29 -05:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|