Exemplo n.º 1
0
    protected override void GenerateColumn(int wX, int wZ, int offset)
    {
        int terrainHeight = Mathf.Max(GetTerrainHeight(wX, wZ) - offset, 1);
        int islandHeight  = Mathf.Max(GetIslandHeight(wX, wZ) - offset, 1);

        bool forest = Voronoi.GetValue(wX, wZ, 0.005f, 1.0f) <= 0.0f;

        for (int y = 0; y < Map.Height; y++)
        {
            if (y <= Map.SeaLevel)
            {
                Map.SetBlock(wX, y, wZ, new Block(BlockID.Water, FluidSimulator.MaxFluidLevel));
            }

            if (y <= terrainHeight)
            {
                GenerateBase(wX, y, wZ);
                continue;
            }

            if (y <= islandHeight)
            {
                GenerateIsland(wX, y, wZ, islandHeight - y, islandHeight);
                continue;
            }
        }

        double val = rand.NextDouble();

        if (forest)
        {
            if (val <= 0.05)
            {
                TreeGenerator.BoxyTreeTerrain(wX, islandHeight, wZ);
            }
        }
        else
        {
            if (Map.GetBlock(wX, islandHeight, wZ).ID == BlockID.Grass && !Map.GetBlock(wX, islandHeight + 1, wZ).IsFluid())
            {
                if (val <= 0.2)
                {
                    Map.SetBlock(wX, islandHeight + 1, wZ, new Block(BlockID.TallGrass));
                }
            }
        }
    }