fCraft.VanillaMapGenState.PlantFlowers C# (CSharp) Method

PlantFlowers() private method

private PlantFlowers ( ) : void
return void
        void PlantFlowers() {
            Random flowerRand = new Random( random.Next() );
            int maxFlowers = genParams.MapWidth*genParams.MapLength/genParams.FlowerClusterDensity;
            for( int cluster = 0; cluster < maxFlowers; cluster++ ) {
                int flowerType = flowerRand.Next( 2 );
                int clusterX = flowerRand.Next( genParams.MapWidth );
                int clusterY = flowerRand.Next( genParams.MapLength );
                for( int flower = 0; flower < genParams.FlowerChainsPerCluster; flower++ ) {
                    int x = clusterX;
                    int y = clusterY;
                    for( int hop = 0; hop < genParams.FlowersPerChain; hop++ ) {
                        x += flowerRand.Next( genParams.FlowerSpread ) - flowerRand.Next( genParams.FlowerSpread );
                        y += flowerRand.Next( genParams.FlowerSpread ) - flowerRand.Next( genParams.FlowerSpread );
                        if( (x < 0) || (y < 0) || (x >= genParams.MapWidth) || (y >= genParams.MapLength) )
                            continue;

                        int z = heightmap[(x + y*genParams.MapWidth)] + 1;
                        int index = Index( x, y, z );

                        Block blockAbove = (Block)blocks[index];
                        if( blockAbove != Block.Air )
                            continue;
                        Block blockUnder = (Block)blocks[Index( x, y, z - 1 )];
                        if( blockUnder != Block.Grass )
                            continue;

                        if( flowerType == 0 ) {
                            blocks[index] = (byte)Block.YellowFlower;
                        } else {
                            blocks[index] = (byte)Block.RedFlower;
                        }
                    }
                }
            }
        }