private TerrainDef TerrainFrom(IntVec3 current, float fertility) { TerrainDef terrainDef = DefDatabase <TerrainDef> .GetNamed("OpenSpace", true); // if the tile is within radius of the center, get the rock terrain if (Math.Sqrt(Math.Pow(current.x - mapRadiusSize, 2) + Math.Pow(current.z - mapRadiusSize, 2)) < mapRadiusSize) { ThingDef rock = GenStep_MoonRocks.RockDefAt(fertility); terrainDef = rock.building.naturalTerrain; } return(terrainDef); }
/// <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; }