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, 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_TerrainFarcasterSigmaAlcyon.RoofThreshold> list2 = new List <GenStep_TerrainFarcasterSigmaAlcyon.RoofThreshold>(); list2.Add(new GenStep_TerrainFarcasterSigmaAlcyon.RoofThreshold { roofDef = RoofDefOf.RoofRockThick, minGridVal = num * 1.14f }); list2.Add(new GenStep_TerrainFarcasterSigmaAlcyon.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); } } } } } //Here I modified the GenStep_ScatterLumpsMineable class so I can choose the minerals spawning GenStep_ScatterLumpsMineableFarcaster genStep_ScatterLumpsMineable = new GenStep_ScatterLumpsMineableFarcaster(); float num3 = 1f; switch (Find.WorldGrid[map.Tile].hilliness) { case Hilliness.Flat: num3 = 1f; break; case Hilliness.SmallHills: num3 = 3f; break; case Hilliness.LargeHills: num3 = 5f; break; case Hilliness.Mountainous: num3 = 7f; break; case Hilliness.Impassable: num3 = 8f; break; } genStep_ScatterLumpsMineable.countPer10kCellsRange = new FloatRange(num3, num3); genStep_ScatterLumpsMineable.forcedDefToScatter = theMinerals; genStep_ScatterLumpsMineable.Generate(map, parms); map.regionAndRoomUpdater.Enabled = true; //Rock gen ends here float currentPlantDensity = biome1.plantDensity; float currentWholeMapNumDesiredPlants = map.wildPlantSpawner.CurrentWholeMapNumDesiredPlants; foreach (IntVec3 current in map.cellsInRandomOrder.GetAll()) { if (!Rand.Chance(0.001f)) { map.wildPlantSpawner.CheckSpawnWildPlantAt(current, currentPlantDensity, currentWholeMapNumDesiredPlants, true); } } map.regionAndRoomUpdater.Enabled = true; // Plant gen ends here /*int num7 = 0; * while (!map.wildSpawner.AnimalEcosystemFull) * { * num7++; * if (num7 >= 10000) * { * Log.Error("Too many iterations."); * break; * } * IntVec3 loc = RCellFinder.RandomAnimalSpawnCell_MapGen(map); * * if (!SpawnRandomWildAnimalAt(map,loc)) * { * break; * } * }*/ // Animal gen removed 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; }