public override void Generate(Map map) { if (!map.TileInfo.WaterCovered) { map.regionAndRoomUpdater.Enabled = false; float num = 0.7f; List <RoofThreshold> list = new List <RoofThreshold>(); RoofThreshold roofThreshold = new RoofThreshold(); roofThreshold.roofDef = RoofDefOf.RoofRockThick; roofThreshold.minGridVal = (float)(num * 1.1399999856948853); list.Add(roofThreshold); RoofThreshold roofThreshold2 = new RoofThreshold(); roofThreshold2.roofDef = RoofDefOf.RoofRockThin; roofThreshold2.minGridVal = (float)(num * 1.0399999618530273); list.Add(roofThreshold2); MapGenFloatGrid elevation = MapGenerator.Elevation; MapGenFloatGrid caves = MapGenerator.Caves; foreach (IntVec3 allCell in map.AllCells) { float num2 = elevation[allCell]; if (num2 > num) { if (caves[allCell] <= 0.0) { ThingDef def = GenStep_RocksFromGrid.RockDefAt(allCell); GenSpawn.Spawn(def, allCell, map); } int num3 = 0; while (num3 < list.Count) { if (!(num2 > list[num3].minGridVal)) { num3++; continue; } map.roofGrid.SetRoof(allCell, list[num3].roofDef); break; } } } BoolGrid visited = new BoolGrid(map); List <IntVec3> toRemove = new List <IntVec3>(); foreach (IntVec3 allCell2 in map.AllCells) { if (!visited[allCell2] && this.IsNaturalRoofAt(allCell2, map)) { toRemove.Clear(); map.floodFiller.FloodFill(allCell2, (IntVec3 x) => this.IsNaturalRoofAt(x, map), delegate(IntVec3 x) { visited[x] = true; toRemove.Add(x); }, 2147483647, false, null); if (toRemove.Count < 20) { for (int i = 0; i < toRemove.Count; i++) { map.roofGrid.SetRoof(toRemove[i], null); } } } } GenStep_ScatterLumpsMineable genStep_ScatterLumpsMineable = new GenStep_ScatterLumpsMineable(); float num4 = 10f; switch (Find.WorldGrid[map.Tile].hilliness) { case Hilliness.Flat: num4 = 4f; break; case Hilliness.SmallHills: num4 = 8f; break; case Hilliness.LargeHills: num4 = 11f; break; case Hilliness.Mountainous: num4 = 15f; break; case Hilliness.Impassable: num4 = 16f; break; } genStep_ScatterLumpsMineable.countPer10kCellsRange = new FloatRange(num4, num4); genStep_ScatterLumpsMineable.Generate(map); map.regionAndRoomUpdater.Enabled = true; } }
public override void Generate(Map map, GenStepParams parms) { if (!map.TileInfo.WaterCovered) { map.regionAndRoomUpdater.Enabled = false; float num = 0.7f; List <GenStep_RocksFromGrid.RoofThreshold> list = new List <GenStep_RocksFromGrid.RoofThreshold>(); list.Add(new GenStep_RocksFromGrid.RoofThreshold { roofDef = RoofDefOf.RoofRockThick, minGridVal = num * 1.14f }); list.Add(new GenStep_RocksFromGrid.RoofThreshold { roofDef = RoofDefOf.RoofRockThin, minGridVal = num * 1.04f }); MapGenFloatGrid elevation = MapGenerator.Elevation; MapGenFloatGrid caves = MapGenerator.Caves; foreach (IntVec3 intVec in map.AllCells) { float num2 = elevation[intVec]; if (num2 > num) { if (caves[intVec] <= 0f) { ThingDef def = GenStep_RocksFromGrid.RockDefAt(intVec); GenSpawn.Spawn(def, intVec, map, WipeMode.Vanish); } for (int i = 0; i < list.Count; i++) { if (num2 > list[i].minGridVal) { map.roofGrid.SetRoof(intVec, list[i].roofDef); break; } } } } BoolGrid visited = new BoolGrid(map); List <IntVec3> toRemove = new List <IntVec3>(); foreach (IntVec3 intVec2 in map.AllCells) { if (!visited[intVec2]) { if (this.IsNaturalRoofAt(intVec2, map)) { toRemove.Clear(); map.floodFiller.FloodFill(intVec2, (IntVec3 x) => this.IsNaturalRoofAt(x, map), delegate(IntVec3 x) { visited[x] = true; toRemove.Add(x); }, int.MaxValue, 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; } }
public override void Generate(Map map, GenStepParams parms) { if (map.TileInfo.WaterCovered) { return; } map.regionAndRoomUpdater.Enabled = false; float num = 0.7f; List <RoofThreshold> list = new List <RoofThreshold>(); RoofThreshold roofThreshold = new RoofThreshold(); roofThreshold.roofDef = RoofDefOf.RoofRockThick; roofThreshold.minGridVal = num * 1.14f; list.Add(roofThreshold); RoofThreshold roofThreshold2 = new RoofThreshold(); roofThreshold2.roofDef = RoofDefOf.RoofRockThin; roofThreshold2.minGridVal = num * 1.04f; list.Add(roofThreshold2); MapGenFloatGrid elevation = MapGenerator.Elevation; MapGenFloatGrid caves = MapGenerator.Caves; foreach (IntVec3 allCell in map.AllCells) { float num2 = elevation[allCell]; if (!(num2 > num)) { continue; } if (caves[allCell] <= 0f) { GenSpawn.Spawn(RockDefAt(allCell), allCell, map); } for (int i = 0; i < list.Count; i++) { if (num2 > list[i].minGridVal) { map.roofGrid.SetRoof(allCell, list[i].roofDef); break; } } } BoolGrid visited = new BoolGrid(map); List <IntVec3> toRemove = new List <IntVec3>(); foreach (IntVec3 allCell2 in map.AllCells) { if (visited[allCell2] || !IsNaturalRoofAt(allCell2, map)) { continue; } toRemove.Clear(); map.floodFiller.FloodFill(allCell2, (IntVec3 x) => IsNaturalRoofAt(x, map), delegate(IntVec3 x) { visited[x] = true; toRemove.Add(x); }); 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 = 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; }