fCraft.FloatingIslandMapGenState.Generate C# (CSharp) Method

Generate() public method

public Generate ( ) : Map
return Map
        public override Map Generate() {
            if( Finished ) return Result;
            try {
                ReportProgress( 0, "Clumping spheres..." );
                rand = new Random( genParams.Seed );
                map = new Map( null, genParams.MapWidth, genParams.MapLength, genParams.MapHeight, true );

                int numIslands = Math.Max( 1, (int)(map.Volume * genParams.IslandDensity / (96 * 96 * 64)) );
                Random islandCoordRand = new Random( rand.Next() );

                List<Island> islands = new List<Island>();

                for( int i = 0; i < numIslands; i++ ) {
                    Vector3I offset = new Vector3I( islandCoordRand.Next( 16, genParams.MapWidth - 16 ),
                                                    islandCoordRand.Next( 16, genParams.MapLength - 16 ),
                                                    islandCoordRand.Next( 16, genParams.MapHeight - 16 ) );
                    islands.Add( CreateIsland( offset ) );
                }
                if( Canceled ) return null;
                
                ReportProgress( 10, "Smoothing (0%)..." );
                SmoothEdges();
                if( Canceled ) return null;
                
                ReportProgress( 15, "Smoothing (50%)..." );
                SmoothEdges();
                if( Canceled ) return null;
                
                ReportProgress( 20, "Expanding..." );
                ExpandGround();
                if( Canceled ) return null;

                ReportProgress( 70, "Adding stone..." );
                for( int i = 0; i < numIslands; i++ ) {
                    MakeIslandBase( islands[i] );
                }

                ReportProgress( 75, "Planting grass..." );
                PlantGrass();
                if( Canceled ) return null;
                
                ReportProgress( 80, "Watering..." );
                for( int x = 0; x < map.Width; x++ ) {
                    for( int y = 0; y < map.Length; y++ ) {
                        map.SetBlock( x, y, 0, Block.Admincrete );
                        map.SetBlock( x, y, 1, Block.Water );
                    }
                }
                MakeWater();
                if( Canceled ) return null;
                
                ReportProgress( 85, "Planting trees..." );
                PlantGiantTrees();
                PlantTrees();
                if( Canceled ) return null;

                ReportProgress( 88, "Planting flowers..." );
                PlantFlowers();
                if( Canceled ) return null;
                
                ReportProgress( 90, "Eroding (0%)..." );
                Erode();
                if( Canceled ) return null;
                ReportProgress( 95, "Eroding (50%)..." );
                Erode();
                if( Canceled ) return null;
                
                Result = map;
                return Result;
            } finally {
                Finished = true;
                Progress = 100;
                StatusString = (Canceled ? "Canceled" : "Finished");
            }
        }