fCraft.FloatingIslandMapGenState.PlantFlowers C# (CSharp) Method

PlantFlowers() public method

public PlantFlowers ( ) : void
return void
        void PlantFlowers() {
            if( genParams.FlowerClusterDensity <= 0 ) return;
            Random flowerRand = new Random( rand.Next() );
            int maxFlowers =
                (int)(map.Width * map.Length * genParams.FlowerClusterDensity / BaseFlowerDensity);
            for( int cluster = 0; cluster < maxFlowers; cluster++ ) {
                int flowerType = flowerRand.Next( 2 );
                int clusterX = flowerRand.Next( map.Width );
                int clusterY = flowerRand.Next( map.Length );
                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 >= map.Width) || (y >= map.Length) )
                            continue;
                        for( int z = map.Height - 1; z > 0; z-- ) {
                            if( map.GetBlock( x, y, z - 1 ) == Block.Grass ) {
                                if( flowerType == 0 ) {
                                    map.SetBlock( x, y, z, Block.YellowFlower );
                                } else {
                                    map.SetBlock( x, y, z, Block.RedFlower );
                                }
                            }
                        }
                    }
                }
            }
        }