Exemplo n.º 1
0
 public override void GenerateFromScribe(string seed)
 {
     Find.World.pathGrid = new WorldPathGrid();
     NoiseDebugUI.ClearPlanetNoises();
 }
Exemplo n.º 2
0
        private void SetupRainfallNoise()
        {
            float      freqMultiplier = FreqMultiplier;
            ModuleBase input          = new Perlin(0.015f * freqMultiplier, 2.0, 0.5, 6, Rand.Range(0, int.MaxValue), QualityMode.High);

            input = new ScaleBias(0.5, 0.5, input);
            NoiseDebugUI.StorePlanetNoise(input, "basePerlin");
            ModuleBase moduleBase = new AbsLatitudeCurve(new SimpleCurve
            {
                {
                    0f,
                    1.12f
                },
                {
                    25f,
                    0.94f
                },
                {
                    45f,
                    0.7f
                },
                {
                    70f,
                    0.3f
                },
                {
                    80f,
                    0.05f
                },
                {
                    90f,
                    0.05f
                }
            }, 100f);

            NoiseDebugUI.StorePlanetNoise(moduleBase, "latCurve");
            noiseRainfall = new Multiply(input, moduleBase);
            float      num    = 0.000222222225f;
            float      num2   = -500f * num;
            ModuleBase input2 = new ScaleBias(num, num2, noiseElevation);

            input2 = new ScaleBias(-1.0, 1.0, input2);
            input2 = new Clamp(0.0, 1.0, input2);
            NoiseDebugUI.StorePlanetNoise(input2, "elevationRainfallEffect");
            noiseRainfall = new Multiply(noiseRainfall, input2);
            Func <double, double> processor = delegate(double val)
            {
                if (val < 0.0)
                {
                    val = 0.0;
                }
                if (val < 0.12)
                {
                    val = (val + 0.12) / 2.0;
                    if (val < 0.03)
                    {
                        val = (val + 0.03) / 2.0;
                    }
                }
                return(val);
            };

            noiseRainfall = new Arbitrary(noiseRainfall, processor);
            noiseRainfall = new Power(noiseRainfall, new Const(1.5));
            noiseRainfall = new Clamp(0.0, 999.0, noiseRainfall);
            NoiseDebugUI.StorePlanetNoise(noiseRainfall, "noiseRainfall before mm");
            noiseRainfall = new ScaleBias(4000.0, 0.0, noiseRainfall);
            SimpleCurve rainfallCurve = Find.World.info.overallRainfall.GetRainfallCurve();

            if (rainfallCurve != null)
            {
                noiseRainfall = new CurveSimple(noiseRainfall, rainfallCurve);
            }
        }
Exemplo n.º 3
0
        public static void WorkOnMapGenerator(Map map)
        {
            ModExt_Biome_GenStep_Ravine extRavine = map.Biome.GetModExtension <ModExt_Biome_GenStep_Ravine>();

            if (extRavine == null)
            {
                return;
            }

            string noiseLabel = "ravine " + map.Biome.defName;
            double xOffset    = map.Size.x / 2;
            double zOffset    = map.Size.z / 2;
            float  baseWidth  = Rand.Range(extRavine.ravineWidthMin, extRavine.ravineWidthMax);
            double modA       = Rand.Range(extRavine.modAMin, extRavine.modAMax);
            double modB       = Rand.Range(extRavine.modBMin, extRavine.modBMax);
            double modC       = Rand.Range(extRavine.modCMin, extRavine.modCMax);
            // Base noise
            ModuleBase moduleBase = new DistFromAxis((float)map.Size.x * baseWidth);

            //NoiseDebugUI.StoreNoiseRender(moduleBase, noiseLabel + " base core");
            moduleBase = new CurveAxis(modA, modB, modC, moduleBase);
            //NoiseDebugUI.StoreNoiseRender(moduleBase, noiseLabel + " base curved");
            moduleBase = new ScaleBias(extRavine.slopeFactor, -1.0, moduleBase);
            //NoiseDebugUI.StoreNoiseRender(moduleBase, noiseLabel + " base scale");
            if (extRavine.invert)
            {
                moduleBase = new Invert(moduleBase);
            }
            //NoiseDebugUI.StoreNoiseRender(moduleBase, noiseLabel + " base invert");
            moduleBase = new Clamp(0.0, 999, moduleBase);
            //NoiseDebugUI.StoreNoiseRender(moduleBase, noiseLabel + " base clamp");
            NoiseDebugUI.StoreNoiseRender(moduleBase, noiseLabel + " base");
            // Add offset variance
            float offsetVariance = (Rand.Value - 0.5f) * extRavine.relativeOffsetVariance + extRavine.relativeOffsetFixed;

            xOffset += map.Size.x * offsetVariance;
            zOffset += map.Size.z * offsetVariance;
            // Add random rotation variance
            double rotVariance = (Rand.Value - 0.5f) * extRavine.rotationVariance;
            // Get overall ravine direction
            Rot4 random;

            do
            {
                random = Rot4.Random;
            }while (random == Find.World.CoastDirectionAt(map.Tile));
            if (random == Rot4.North)
            {
                moduleBase = new Rotate(0.0, 270.0 + rotVariance, 0.0, moduleBase);
                moduleBase = new Translate(0.0, 0.0, zOffset, moduleBase);
            }
            else if (random == Rot4.West)
            {
                moduleBase = new Rotate(0.0, 180.0 + rotVariance, 0.0, moduleBase);
                moduleBase = new Translate(xOffset, 0.0, 0.0, moduleBase);
            }
            else if (random == Rot4.South)
            {
                moduleBase = new Rotate(0.0, 90.0 + rotVariance, 0.0, moduleBase);
                moduleBase = new Translate(0.0, 0.0, (-zOffset), moduleBase);
            }
            else if (random == Rot4.East)
            {
                moduleBase = new Rotate(0.0, 0.0 + rotVariance, 0.0, moduleBase);
                moduleBase = new Translate((-xOffset), 0.0, 0.0, moduleBase);
            }
            // Elevation noise scaling
            ModuleBase noiseElevation = new ScaleBias(extRavine.noiseElevationPreScale, extRavine.noiseElevationPreOffset, moduleBase);

            NoiseDebugUI.StoreNoiseRender(noiseElevation, noiseLabel + " elevation");
            // Fertility noise scaling
            ModuleBase noiseFertility = new ScaleBias(extRavine.noiseFertilityPreScale, extRavine.noiseFertilityPreOffset, moduleBase);

            NoiseDebugUI.StoreNoiseRender(noiseFertility, noiseLabel + " fertility");

            // Work on MapGenerator grid
            MapGenFloatGrid elevation = MapGenerator.Elevation;
            MapGenFloatGrid fertility = MapGenerator.Fertility;

            foreach (IntVec3 cell in map.AllCells)
            {
                // Set elevation
                if (extRavine.calcElevationType == GenStepCalculationType.Set)
                {
                    elevation[cell] = noiseElevation.GetValue(cell) + extRavine.elevationPostOffset;
                }
                else if (extRavine.calcElevationType == GenStepCalculationType.Add)
                {
                    elevation[cell] += noiseElevation.GetValue(cell) + extRavine.elevationPostOffset;
                }
                // Set fertility
                if (extRavine.calcFertilityType == GenStepCalculationType.Set)
                {
                    fertility[cell] = noiseFertility.GetValue(cell) + extRavine.fertilityPostOffset;
                }
                else if (extRavine.calcFertilityType == GenStepCalculationType.Add)
                {
                    fertility[cell] += noiseFertility.GetValue(cell) + extRavine.fertilityPostOffset;
                }
            }
        }
        public static bool Prefix(Map map)
        {
            //if (!DefsUtil.Enable)
            //    return true;
            //if (!DefsUtil.EnableMountainSettings)
            //    return true;
            if (Settings.detectedImpassableMaps && map.TileInfo.hilliness == Hilliness.Impassable)
            {
                return(true);
            }

            NoiseRenderer.renderSize = new IntVec2(map.Size.x, map.Size.z);
            ModuleBase input = new Perlin(0.020999999716877937, 2.0, 0.5, 6, Rand.Range(0, int.MaxValue), QualityMode.High);

            input = new ScaleBias(0.5, 0.5, input);
            NoiseDebugUI.StoreNoiseRender(input, "elev base");
            float num = 1f;

            switch (map.TileInfo.hilliness)
            {
            case Hilliness.Flat:
                num = MapGenTuning.ElevationFactorFlat;
                break;

            case Hilliness.SmallHills:
                num = MapGenTuning.ElevationFactorSmallHills;
                break;

            case Hilliness.LargeHills:
                num = MapGenTuning.ElevationFactorLargeHills;
                break;

            case Hilliness.Mountainous:
                num = MapGenTuning.ElevationFactorMountains;
                break;

            case Hilliness.Impassable:
                num = MapGenTuning.ElevationFactorImpassableMountains;
                break;
            }
            input = new Multiply(input, new Const(num + MapSettings.Mountain.GetMultiplier()));
            NoiseDebugUI.StoreNoiseRender(input, "elev world-factored");
            if (map.TileInfo.hilliness == Hilliness.Mountainous || map.TileInfo.hilliness == Hilliness.Impassable)
            {
                ModuleBase input2 = new DistFromAxis((float)map.Size.x * 0.42f);
                input2 = new Clamp(0.0, 1.0, input2);
                input2 = new Invert(input2);
                input2 = new ScaleBias(1.0, 1.0, input2);
                Rot4 random;
                do
                {
                    random = Rot4.Random;
                }while (random == Find.World.CoastDirectionAt(map.Tile));
                if (random == Rot4.North)
                {
                    input2 = new Rotate(0.0, 90.0, 0.0, input2);
                    input2 = new Translate(0.0, 0.0, -map.Size.z, input2);
                }
                else if (random == Rot4.East)
                {
                    input2 = new Translate(-map.Size.x, 0.0, 0.0, input2);
                }
                else if (random == Rot4.South)
                {
                    input2 = new Rotate(0.0, 90.0, 0.0, input2);
                }
                else
                {
                    _ = random == Rot4.West;
                }
                NoiseDebugUI.StoreNoiseRender(input2, "mountain");
                input = new Add(input, input2);
                NoiseDebugUI.StoreNoiseRender(input, "elev + mountain");
            }
            float           b         = (map.TileInfo.WaterCovered ? 0f : float.MaxValue);
            MapGenFloatGrid elevation = MapGenerator.Elevation;

            foreach (IntVec3 allCell in map.AllCells)
            {
                elevation[allCell] = Mathf.Min(input.GetValue(allCell), b);
            }
            ModuleBase input3 = new Perlin(0.020999999716877937, 2.0, 0.5, 6, Rand.Range(0, int.MaxValue), QualityMode.High);

            input3 = new ScaleBias(0.5, 0.5, input3);
            NoiseDebugUI.StoreNoiseRender(input3, "noiseFert base");
            MapGenFloatGrid fertility = MapGenerator.Fertility;

            foreach (IntVec3 allCell2 in map.AllCells)
            {
                fertility[allCell2] = input3.GetValue(allCell2);
            }
            return(false);
        }
        public override void Generate(Map map)
        {
            NoiseRenderer.renderSize = new IntVec2(map.Size.x, map.Size.z);
            ModuleBase moduleBase = new Perlin(0.020999999716877937, 2.0, 0.5, 6, Rand.Range(0, 2147483647), QualityMode.High);

            moduleBase = new ScaleBias(0.5, 0.5, moduleBase);
            NoiseDebugUI.StoreNoiseRender(moduleBase, "elev base");
            float num = 1f;

            switch (map.TileInfo.hilliness)
            {
            case Hilliness.Flat:
                num = MapGenTuning.ElevationFactorFlat;
                break;

            case Hilliness.SmallHills:
                num = MapGenTuning.ElevationFactorSmallHills;
                break;

            case Hilliness.LargeHills:
                num = MapGenTuning.ElevationFactorLargeHills;
                break;

            case Hilliness.Mountainous:
                num = MapGenTuning.ElevationFactorMountains;
                break;

            case Hilliness.Impassable:
                num = MapGenTuning.ElevationFactorImpassableMountains;
                break;
            }
            moduleBase = new Multiply(moduleBase, new Const((double)num));
            NoiseDebugUI.StoreNoiseRender(moduleBase, "elev world-factored");
            if (map.TileInfo.hilliness == Hilliness.Mountainous || map.TileInfo.hilliness == Hilliness.Impassable)
            {
                ModuleBase moduleBase2 = new DistFromAxis((float)map.Size.x * 0.42f);
                moduleBase2 = new Clamp(0.0, 1.0, moduleBase2);
                moduleBase2 = new Invert(moduleBase2);
                moduleBase2 = new ScaleBias(1.0, 1.0, moduleBase2);
                Rot4 random;
                do
                {
                    random = Rot4.Random;
                }while (random == Find.World.CoastDirectionAt(map.Tile));
                if (random == Rot4.North)
                {
                    moduleBase2 = new Rotate(0.0, 90.0, 0.0, moduleBase2);
                    moduleBase2 = new Translate(0.0, 0.0, (double)(-(double)map.Size.z), moduleBase2);
                }
                else if (random == Rot4.East)
                {
                    moduleBase2 = new Translate((double)(-(double)map.Size.x), 0.0, 0.0, moduleBase2);
                }
                else if (random == Rot4.South)
                {
                    moduleBase2 = new Rotate(0.0, 90.0, 0.0, moduleBase2);
                }
                else if (random == Rot4.West)
                {
                }
                NoiseDebugUI.StoreNoiseRender(moduleBase2, "mountain");
                moduleBase = new Add(moduleBase, moduleBase2);
                NoiseDebugUI.StoreNoiseRender(moduleBase, "elev + mountain");
            }
            float           b         = (!map.TileInfo.WaterCovered) ? 3.40282347E+38f : 0f;
            MapGenFloatGrid elevation = MapGenerator.Elevation;

            foreach (IntVec3 current in map.AllCells)
            {
                elevation[current] = Mathf.Min(moduleBase.GetValue(current), b);
            }
            ModuleBase moduleBase3 = new Perlin(0.020999999716877937, 2.0, 0.5, 6, Rand.Range(0, 2147483647), QualityMode.High);

            moduleBase3 = new ScaleBias(0.5, 0.5, moduleBase3);
            NoiseDebugUI.StoreNoiseRender(moduleBase3, "noiseFert base");
            MapGenFloatGrid fertility = MapGenerator.Fertility;

            foreach (IntVec3 current2 in map.AllCells)
            {
                fertility[current2] = moduleBase3.GetValue(current2);
            }
        }
Exemplo n.º 6
0
        private void SetupRainfallNoise()
        {
            float      freqMultiplier = WorldGenStep_Terrain.FreqMultiplier;
            ModuleBase moduleBase     = new Perlin((double)(0.015f * freqMultiplier), 2.0, 0.5, 6, Rand.Range(0, 2147483647), QualityMode.High);

            moduleBase = new ScaleBias(0.5, 0.5, moduleBase);
            NoiseDebugUI.StorePlanetNoise(moduleBase, "basePerlin");
            ModuleBase moduleBase2 = new AbsLatitudeCurve(new SimpleCurve
            {
                {
                    0f,
                    1.12f,
                    true
                },
                {
                    25f,
                    0.94f,
                    true
                },
                {
                    45f,
                    0.7f,
                    true
                },
                {
                    70f,
                    0.3f,
                    true
                },
                {
                    80f,
                    0.05f,
                    true
                },
                {
                    90f,
                    0.05f,
                    true
                }
            }, 100f);

            NoiseDebugUI.StorePlanetNoise(moduleBase2, "latCurve");
            this.noiseRainfall = new Multiply(moduleBase, moduleBase2);
            float      num         = 0.000222222225f;
            float      num2        = -500f * num;
            ModuleBase moduleBase3 = new ScaleBias((double)num, (double)num2, this.noiseElevation);

            moduleBase3 = new ScaleBias(-1.0, 1.0, moduleBase3);
            moduleBase3 = new Clamp(0.0, 1.0, moduleBase3);
            NoiseDebugUI.StorePlanetNoise(moduleBase3, "elevationRainfallEffect");
            this.noiseRainfall = new Multiply(this.noiseRainfall, moduleBase3);
            Func <double, double> processor = delegate(double val)
            {
                if (val < 0.0)
                {
                    val = 0.0;
                }
                if (val < 0.12)
                {
                    val = (val + 0.12) / 2.0;
                    if (val < 0.03)
                    {
                        val = (val + 0.03) / 2.0;
                    }
                }
                return(val);
            };

            this.noiseRainfall = new Arbitrary(this.noiseRainfall, processor);
            this.noiseRainfall = new Power(this.noiseRainfall, new Const(1.5));
            this.noiseRainfall = new Clamp(0.0, 999.0, this.noiseRainfall);
            NoiseDebugUI.StorePlanetNoise(this.noiseRainfall, "noiseRainfall before mm");
            this.noiseRainfall = new ScaleBias(4000.0, 0.0, this.noiseRainfall);
            SimpleCurve rainfallCurve = Find.World.info.overallRainfall.GetRainfallCurve();

            if (rainfallCurve != null)
            {
                this.noiseRainfall = new CurveSimple(this.noiseRainfall, rainfallCurve);
            }
        }
        public override void Generate(Map map)
        {
            IntVec3 size  = map.Size;
            int     x     = size.x;
            IntVec3 size2 = map.Size;

            NoiseRenderer.renderSize = new IntVec2(x, size2.z);
            ModuleBase input = new Perlin(0.020999999716877937, 2.0, 0.5, 6, Rand.Range(0, 2147483647), QualityMode.High);

            input = new ScaleBias(0.5, 0.5, input);
            NoiseDebugUI.StoreNoiseRender(input, "elev base");
            float num = 1f;

            switch (map.TileInfo.hilliness)
            {
            case Hilliness.Flat:
                num = MapGenTuning.ElevationFactorFlat;
                break;

            case Hilliness.SmallHills:
                num = MapGenTuning.ElevationFactorSmallHills;
                break;

            case Hilliness.LargeHills:
                num = MapGenTuning.ElevationFactorLargeHills;
                break;

            case Hilliness.Mountainous:
                num = MapGenTuning.ElevationFactorMountains;
                break;

            case Hilliness.Impassable:
                num = MapGenTuning.ElevationFactorImpassableMountains;
                break;
            }
            input = new Multiply(input, new Const((double)num));
            NoiseDebugUI.StoreNoiseRender(input, "elev world-factored");
            if (map.TileInfo.hilliness != Hilliness.Mountainous && map.TileInfo.hilliness != Hilliness.Impassable)
            {
                goto IL_02b1;
            }
            IntVec3    size3  = map.Size;
            ModuleBase input2 = new DistFromAxis((float)((float)size3.x * 0.41999998688697815));

            input2 = new Clamp(0.0, 1.0, input2);
            input2 = new Invert(input2);
            input2 = new ScaleBias(1.0, 1.0, input2);
            Rot4 random;

            while (true)
            {
                random = Rot4.Random;
                if (!(random == Find.World.CoastDirectionAt(map.Tile)))
                {
                    break;
                }
            }
            if (random == Rot4.North)
            {
                input2 = new Rotate(0.0, 90.0, 0.0, input2);
                IntVec3 size4 = map.Size;
                input2 = new Translate(0.0, 0.0, (double)(-size4.z), input2);
            }
            else if (random == Rot4.East)
            {
                IntVec3 size5 = map.Size;
                input2 = new Translate((double)(-size5.x), 0.0, 0.0, input2);
            }
            else if (random == Rot4.South)
            {
                input2 = new Rotate(0.0, 90.0, 0.0, input2);
            }
            else if (!(random == Rot4.West))
            {
                goto IL_0291;
            }
            goto IL_0291;
IL_0291:
            NoiseDebugUI.StoreNoiseRender(input2, "mountain");
            input = new Add(input, input2);
            NoiseDebugUI.StoreNoiseRender(input, "elev + mountain");
            goto IL_02b1;
IL_02b1:
            float b = (float)((!map.TileInfo.WaterCovered) ? 3.4028234663852886E+38 : 0.0);
            MapGenFloatGrid elevation = MapGenerator.Elevation;

            foreach (IntVec3 allCell in map.AllCells)
            {
                elevation[allCell] = Mathf.Min(input.GetValue(allCell), b);
            }
            ModuleBase input3 = new Perlin(0.020999999716877937, 2.0, 0.5, 6, Rand.Range(0, 2147483647), QualityMode.High);

            input3 = new ScaleBias(0.5, 0.5, input3);
            NoiseDebugUI.StoreNoiseRender(input3, "noiseFert base");
            MapGenFloatGrid fertility = MapGenerator.Fertility;

            foreach (IntVec3 allCell2 in map.AllCells)
            {
                fertility[allCell2] = input3.GetValue(allCell2);
            }
        }
Exemplo n.º 8
0
        // Token: 0x0600003D RID: 61 RVA: 0x000033A0 File Offset: 0x000015A0
        public override void Generate(Map map, GenStepParams parms)
        {
            NoiseRenderer.renderSize = new IntVec2(map.Size.x, map.Size.z);
            ModuleBase moduleBase = new Perlin(0.0209999997168779, 2.0, 0.5, 6, Rand.Range(0, int.MaxValue), QualityMode.High);

            moduleBase = new ScaleBias(0.5, 0.5, moduleBase);
            NoiseDebugUI.StoreNoiseRender(moduleBase, "elev base");
            float num = 1.8f;

            moduleBase = new Multiply(moduleBase, new Const((double)num));
            NoiseDebugUI.StoreNoiseRender(moduleBase, "elev world-factored");
            ModuleBase moduleBase2 = new DistFromAxis((float)map.Size.x * 0.42f);

            moduleBase2 = new Clamp(0.0, 1.0, moduleBase2);
            moduleBase2 = new Invert(moduleBase2);
            moduleBase2 = new ScaleBias(1.0, 1.0, moduleBase2);
            Rot4 random;

            do
            {
                random = Rot4.Random;
            }while (random == Find.World.CoastDirectionAt(map.Tile));
            bool flag = random == Rot4.North;

            if (flag)
            {
                moduleBase2 = new Rotate(0.0, 90.0, 0.0, moduleBase2);
                moduleBase2 = new Translate(0.0, 0.0, -(double)map.Size.z, moduleBase2);
            }
            else
            {
                bool flag2 = random == Rot4.East;
                if (flag2)
                {
                    moduleBase2 = new Translate(-(double)map.Size.x, 0.0, 0.0, moduleBase2);
                }
                else
                {
                    bool flag3 = random == Rot4.South;
                    if (flag3)
                    {
                        moduleBase2 = new Rotate(0.0, 90.0, 0.0, moduleBase2);
                    }
                    else
                    {
                        bool flag4 = random == Rot4.West;
                        if (flag4)
                        {
                        }
                    }
                }
            }
            NoiseDebugUI.StoreNoiseRender(moduleBase2, "mountain");
            moduleBase = new Add(moduleBase, moduleBase2);
            NoiseDebugUI.StoreNoiseRender(moduleBase, "elev + mountain");
            float           num2      = (!map.TileInfo.WaterCovered) ? 3.402823E+38f : 0f;
            MapGenFloatGrid elevation = MapGenerator.Elevation;

            foreach (IntVec3 intVec in map.AllCells)
            {
                elevation[intVec] = Mathf.Min(moduleBase.GetValue(intVec), num2);
            }
            MapGenFloatGrid fertility = MapGenerator.Fertility;

            foreach (IntVec3 c in map.AllCells)
            {
                fertility[c] = 0f;
            }
        }
Exemplo n.º 9
0
        public override void Generate(Map map, GenStepParams parms)
        {
            List <IntVec3>  list        = new List <IntVec3>();
            MapGenFloatGrid elevation   = MapGenerator.Elevation;
            MapGenFloatGrid fertility   = MapGenerator.Fertility;
            MapGenFloatGrid caves       = MapGenerator.Caves;
            TerrainGrid     terrainGrid = map.terrainGrid;

            biome1 = chooseABiome();
            foreach (IntVec3 current in map.AllCells)
            {
                Building   edifice = current.GetEdifice(map);
                TerrainDef terrainDef;
                if ((edifice != null && edifice.def.Fillage == FillCategory.Full) || caves[current] > 0f)
                {
                    terrainDef = this.TerrainFrom(current, map, elevation[current], fertility[current], true);
                }
                else
                {
                    terrainDef = this.TerrainFrom(current, map, elevation[current], fertility[current], false);
                }
                if ((terrainDef == TerrainDefOf.WaterMovingShallow || terrainDef == TerrainDefOf.WaterMovingChestDeep) && edifice != null)
                {
                    list.Add(edifice.Position);
                    edifice.Destroy(DestroyMode.Vanish);
                }
                terrainGrid.SetTerrain(current, terrainDef);
            }

            RoofCollapseCellsFinder.RemoveBulkCollapsingRoofs(list, map);
            //BeachMaker.Cleanup();
            foreach (TerrainPatchMaker current2 in biome1.terrainPatchMakers)
            {
                current2.Cleanup();
            }


            //Basic terrain gen ends here



            if (map.TileInfo.WaterCovered)
            {
                return;
            }
            map.regionAndRoomUpdater.Enabled = false;
            float num = 0.7f;
            List <GenStep_TerrainFarcasterDeltaServitus.RoofThreshold> list2 = new List <GenStep_TerrainFarcasterDeltaServitus.RoofThreshold>();

            list2.Add(new GenStep_TerrainFarcasterDeltaServitus.RoofThreshold
            {
                roofDef    = RoofDefOf.RoofRockThick,
                minGridVal = num * 1.14f
            });
            list2.Add(new GenStep_TerrainFarcasterDeltaServitus.RoofThreshold
            {
                roofDef    = RoofDefOf.RoofRockThin,
                minGridVal = num * 1.04f
            });
            //MapGenFloatGrid elevation3 = MapGenerator.Elevation;
            //MapGenFloatGrid caves2 = MapGenerator.Caves;
            foreach (IntVec3 current in map.AllCells)
            {
                float num2 = elevation[current];
                if (num2 > num)
                {
                    if (caves[current] <= 0f)
                    {
                        ThingDef def = RockDefAt(current);
                        if (map.Center.DistanceTo(current) > 5f)
                        {
                            GenSpawn.Spawn(def, current, map);
                        }
                    }
                    for (int i = 0; i < list.Count; i++)
                    {
                        if (num2 > list2[i].minGridVal)
                        {
                            map.roofGrid.SetRoof(current, list2[i].roofDef);
                            break;
                        }
                    }
                }
            }
            BoolGrid       visited  = new BoolGrid(map);
            List <IntVec3> toRemove = new List <IntVec3>();

            foreach (IntVec3 current2 in map.AllCells)
            {
                if (!visited[current2])
                {
                    if (this.IsNaturalRoofAt(current2, map))
                    {
                        toRemove.Clear();
                        map.floodFiller.FloodFill(current2, (IntVec3 x) => this.IsNaturalRoofAt(x, map), delegate(IntVec3 x)
                        {
                            visited[x] = true;
                            toRemove.Add(x);
                        }, 2147483647, false, null);
                        if (toRemove.Count < 20)
                        {
                            for (int j = 0; j < toRemove.Count; j++)
                            {
                                map.roofGrid.SetRoof(toRemove[j], null);
                            }
                        }
                    }
                }
            }
            GenStep_ScatterLumpsMineable genStep_ScatterLumpsMineable = new GenStep_ScatterLumpsMineable();
            float num3 = 10f;

            switch (Find.WorldGrid[map.Tile].hilliness)
            {
            case Hilliness.Flat:
                num3 = 4f;
                break;

            case Hilliness.SmallHills:
                num3 = 8f;
                break;

            case Hilliness.LargeHills:
                num3 = 11f;
                break;

            case Hilliness.Mountainous:
                num3 = 15f;
                break;

            case Hilliness.Impassable:
                num3 = 16f;
                break;
            }
            genStep_ScatterLumpsMineable.countPer10kCellsRange = new FloatRange(num3, num3);
            genStep_ScatterLumpsMineable.Generate(map, parms);
            map.regionAndRoomUpdater.Enabled = true;


            //Rock gen ends here



            // Plant gen ends here

            int num7 = 0;

            while (!map.wildAnimalSpawner.AnimalEcosystemFull)
            {
                num7++;
                if (num7 >= 10)
                {
                    //Log.Error("Too many iterations.");
                    break;
                }
                IntVec3 loc = RCellFinder.RandomAnimalSpawnCell_MapGen(map);
                if (!SpawnRandomWildAnimalAt(map, loc))
                {
                    break;
                }
            }

            if (map.TileInfo.WaterCovered)
            {
                return;
            }
            this.freqFactorNoise = new Perlin(0.014999999664723873, 2.0, 0.5, 6, Rand.Range(0, 999999), QualityMode.Medium);
            this.freqFactorNoise = new ScaleBias(1.0, 1.0, this.freqFactorNoise);
            NoiseDebugUI.StoreNoiseRender(this.freqFactorNoise, "rock_chunks_freq_factor");
            MapGenFloatGrid elevation2 = MapGenerator.Elevation;

            foreach (IntVec3 current in map.AllCells)
            {
                float num2 = 0.006f * this.freqFactorNoise.GetValue(current);
                if (elevation2[current] < 0.55f && Rand.Value < num2)
                {
                    this.GrowLowRockFormationFrom(current, map);
                }
            }
            this.freqFactorNoise = null;
        }