private void generateResourceRocks()
        {
            ThingDef resourceRockDef = speciality.ResourceRockSpeciality;

            if (resourceRockDef == null)
            {
                return;
            }
            if (resourceRockExtraSpawn <= 0)
            {
                return;
            }
            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;
            }
            num3 *= resourceRockExtraSpawn;
            genStep_ScatterLumpsMineable.forcedDefToScatter    = resourceRockDef;
            genStep_ScatterLumpsMineable.countPer10kCellsRange = new FloatRange(num3, num3);
            genStep_ScatterLumpsMineable.Generate(map);
        }
Beispiel #2
0
        // Token: 0x0600001C RID: 28 RVA: 0x00002B78 File Offset: 0x00000D78
        public override void Generate(Map map, GenStepParams parms)
        {
            map.regionAndRoomUpdater.Enabled = false;
            foreach (IntVec3 intVec in map.AllCells)
            {
                ThingDef def  = GenStep_RocksFromGrid.RockDefAt(intVec);
                bool     flag = ((UndergroundMapParent)map.info.parent).holeLocation.DistanceTo(intVec) > 5f;
                if (flag)
                {
                    GenSpawn.Spawn(def, intVec, map, WipeMode.Vanish);
                }
                map.roofGrid.SetRoof(intVec, RoofDefOf.RoofRockThick);
            }
            GenStep_ScatterLumpsMineable genStep_ScatterLumpsMineable = new GenStep_ScatterLumpsMineable();
            float num = 16f;

            genStep_ScatterLumpsMineable.countPer10kCellsRange = new FloatRange(num, num);
            genStep_ScatterLumpsMineable.Generate(map, default);
            map.regionAndRoomUpdater.Enabled = true;
        }
Beispiel #3
0
        public override void Generate(Map map, GenStepParams parms)
        {
            Log.Message("Generating cavern roofs");

            map.regionAndRoomUpdater.Enabled = false;
            float num = 0.7f;

            MapGenFloatGrid elevation = MapGenerator.Elevation;

            foreach (IntVec3 current in map.AllCells)
            {
                float num2 = elevation[current];
                if (num2 > num)
                {
                    ThingDef def = GenStep_RocksFromGrid.RockDefAt(current);
                    GenSpawn.Spawn(def, current, map, WipeMode.Vanish);
                }
                map.roofGrid.SetRoof(current, BiomesCoreDefOf.BMT_RockRoofStable);
            }
            //BoolGrid visited = new BoolGrid(map);
            //List<IntVec3> toRemove = new List<IntVec3>();
            //foreach (IntVec3 current2 in map.AllCells)
            //{
            //    if (!visited[current2])
            //    {
            //        toRemove.Clear();
            //        map.floodFiller.FloodFill(current2, (IntVec3 x) => true, 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();

            genStep_ScatterLumpsMineable.maxValue = this.maxMineableValue;
            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;
        }
Beispiel #4
0
        public override void Generate(Map map)
        {
            if (map.TileInfo.WaterCovered)
            {
                return;
            }
            map.regionAndRoomUpdater.Enabled = false;
            float num = 0.7f;
            List <RoofThreshold> list = new List <RoofThreshold>();

            list.Add(new RoofThreshold
            {
                roofDef    = RoofDefOf.RoofRockThick,
                minGridVal = num * 1.14f
            });
            list.Add(new RoofThreshold
            {
                roofDef    = RoofDefOf.RoofRockThin,
                minGridVal = num * 1.04f
            });
            MapGenFloatGrid elevation = MapGenerator.Elevation;

            foreach (IntVec3 current in map.AllCells)
            {
                float num2 = elevation[current];
                if (num2 > num)
                {
                    ThingDef def = GenStep_RocksFromGrid.RockDefAt(current);
                    GenSpawn.Spawn(def, current, map);
                    for (int i = 0; i < list.Count; i++)
                    {
                        if (num2 > list[i].minGridVal)
                        {
                            map.roofGrid.SetRoof(current, list[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);
                        }, false);
                        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;

            // Use RA values here
            var defExtension = def.GetModExtension <GenStepExtension>() ?? new GenStepExtension();

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

            case Hilliness.SmallHills:
                num3 = defExtension.SmallHillsMineablesPer10kCells;
                break;

            case Hilliness.LargeHills:
                num3 = defExtension.LargeHillsMineablesPer10kCells;
                break;

            case Hilliness.Mountainous:
                num3 = defExtension.MountainousMineablesPer10kCells;
                break;

            case Hilliness.Impassable:
                num3 = 16f;
                break;
            }
            genStep_ScatterLumpsMineable.countPer10kCellsRange = new FloatRange(num3, num3);
            genStep_ScatterLumpsMineable.Generate(map);
            map.regionAndRoomUpdater.Enabled = true;
        }
Beispiel #5
0
        public override void Generate(Map map, GenStepParams parms)
        {
            if (!map.Biome.HasModExtension <BiomesMap>())
            {
                return;
            }
            if (!map.Biome.GetModExtension <BiomesMap>().isIsland)
            {
                return;
            }
            if (!map.Biome.GetModExtension <BiomesMap>().addIslandHills)
            {
                return;
            }
            Log.Message("[Biomes Core] Generating island hills...");
            map.regionAndRoomUpdater.Enabled = false;
            float roofThreshhold = 0.7f;
            List <GenStep_IslandRocksFromGrid.RoofThreshold> list = new List <GenStep_IslandRocksFromGrid.RoofThreshold>();

            list.Add(new GenStep_IslandRocksFromGrid.RoofThreshold
            {
                roofDef    = RoofDefOf.RoofRockThick,
                minGridVal = roofThreshhold * 1.14f
            });
            list.Add(new GenStep_IslandRocksFromGrid.RoofThreshold
            {
                roofDef    = RoofDefOf.RoofRockThin,
                minGridVal = roofThreshhold * 1.04f
            });

            MapGenFloatGrid elevation = MapGenerator.Elevation;
            MapGenFloatGrid caves     = MapGenerator.Caves;

            foreach (IntVec3 current in map.AllCells)
            {
                float curElev = elevation[current];
                if (curElev > roofThreshhold)
                {
                    if (caves[current] <= 0f)
                    {
                        ThingDef def = GenStep_RocksFromGrid.RockDefAt(current);
                        GenSpawn.Spawn(def, current, map, WipeMode.Vanish);
                    }
                    for (int i = 0; i < list.Count; i++)
                    {
                        if (curElev > list[i].minGridVal)
                        {
                            map.roofGrid.SetRoof(current, list[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 < MinRoofedCellsPerGroup)
                        {
                            for (int j = 0; j < toRemove.Count; j++)
                            {
                                map.roofGrid.SetRoof(toRemove[j], null);
                            }
                        }
                    }
                }
            }

            GenStep_ScatterLumpsMineable genStep_ScatterLumpsMineable = new GenStep_ScatterLumpsMineable();

            genStep_ScatterLumpsMineable.maxValue = this.maxMineableValue;

            float oreTuning = 10f;

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

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

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

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

            case Hilliness.Impassable:
                oreTuning = 16f;
                break;
            }

            // This scales the amount of available ore for islands
            oreTuning *= 0.8f;

            genStep_ScatterLumpsMineable.countPer10kCellsRange = new FloatRange(oreTuning, oreTuning);
            genStep_ScatterLumpsMineable.Generate(map, parms);

            map.regionAndRoomUpdater.Enabled = true;
        }
        /// <summary>
        /// This is a customized copy of the vanilla version
        /// </summary>
        /// <param name="map"></param>
        /// <param name="parms"></param>
        public override void Generate(Map map, GenStepParams parms)
        {
            if (map.Biome.defName != "RockMoonBiome")
            {
                return;
            }

            mapRadiusSize = map.Size.x / 2;

            map.regionAndRoomUpdater.Enabled = false;
            float num = 0.7f;
            List <GenStep_MoonRocks.RoofThreshold> list = new List <GenStep_MoonRocks.RoofThreshold>();

            list.Add(new GenStep_MoonRocks.RoofThreshold
            {
                roofDef    = RoofDefOf.RoofRockThick,
                minGridVal = num * 1.14f
            });
            list.Add(new GenStep_MoonRocks.RoofThreshold
            {
                roofDef    = RoofDefOf.RoofRockThin,
                minGridVal = num * 1.04f
            });
            MapGenFloatGrid elevation = MapGenerator.Elevation;
            MapGenFloatGrid caves     = MapGenerator.Caves;
            MapGenFloatGrid fertility = MapGenerator.Fertility;

            foreach (IntVec3 current in map.AllCells)
            {
                if (IsInRadius(current))
                {
                    float num2 = elevation[current];
                    if (num2 > num)
                    {
                        if (caves[current] <= 0f)
                        {
                            ThingDef def = GenStep_MoonRocks.RockDefAt(fertility[current]);


                            GenSpawn.Spawn(def, current, map, WipeMode.Vanish);
                        }
                        for (int i = 0; i < list.Count; i++)
                        {
                            if (num2 > list[i].minGridVal)
                            {
                                map.roofGrid.SetRoof(current, list[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();

            genStep_ScatterLumpsMineable.maxValue = this.maxMineableValue;
            float num3 = 10f;

            genStep_ScatterLumpsMineable.countPer10kCellsRange = new FloatRange(num3, num3);
            genStep_ScatterLumpsMineable.Generate(map, parms);
            map.regionAndRoomUpdater.Enabled = true;
        }
Beispiel #7
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;
        }