public override IEnumerable Regenerate() { IEnumerator enumerator = base.Regenerate().GetEnumerator(); try { while (enumerator.MoveNext()) { object result = enumerator.Current; yield return(result); } } finally { IDisposable disposable; if ((disposable = (enumerator as IDisposable)) != null) { disposable.Dispose(); } } Rand.PushState(); Rand.Seed = Find.World.info.Seed; WorldGrid grid = Find.WorldGrid; int tilesCount = grid.TilesCount; for (int i = 0; i < tilesCount; i++) { Tile tile = grid[i]; BiomeWorkerSpecial specialWorker = tile.biome.WorkerSpecial(); if (specialWorker == null) { continue; } WLTileGraphicData tileData = specialWorker.GetWLTileGraphicData(grid, i); if (tileData == null) { continue; } // Draw mesh LayerSubMesh subMesh = GetSubMesh(tileData.material); if (tileData.drawAsQuad) { Vector3 tileCenter = grid.GetTileCenter(i); Vector3 drawPos = (tileCenter + Rand.UnitVector3 * tileData.posOffset * grid.averageTileSize).normalized * tileCenter.magnitude; WorldRendererUtility.PrintQuadTangentialToPlanetWithRodation(drawPos, tileCenter, tileData.sizeFactor * grid.averageTileSize, 0.005f, subMesh, tileData.rotVector); RimWorld.Planet.WorldRendererUtility.PrintTextureAtlasUVs(tileData.atlasX, tileData.atlasZ, tileData.texturesInAtlasX, tileData.texturesInAtlasZ, subMesh); } else { IntVec2 texturesInAtlas = new IntVec2(tileData.texturesInAtlasX, tileData.texturesInAtlasZ); WorldRendererUtility.DrawTileTangentialToPlanetWithRodation(grid, subMesh, i, tileData.atlasX, tileData.atlasZ, texturesInAtlas, tileData.rotDir); } } Rand.PopState(); FinalizeMesh(MeshParts.All); yield break; }
public override void GenerateFresh(string seed) { // Get list of biomes and filter for only ones with special worker List<BiomeDef> biomes = DefDatabase<BiomeDef>.AllDefsListForReading; List<BiomeDef> specialBiomes = new List<BiomeDef>(); for (int i = biomes.Count - 1; i >= 0; i--) { if (biomes[i].WorkerSpecial() != null) { specialBiomes.Add(biomes[i]); // Reset/init chance algorithm for world generation biomes[i].WorkerSpecial().ResetChance(); } } // Apply special biome workers to tiles WorldGrid grid = Find.WorldGrid; List<Tile> tiles = grid.tiles; int tilesCount = grid.TilesCount; for (int i = 0; i < tilesCount; i++) { // Skip this tile if it already contains a special biome if (specialBiomes.Contains(tiles[i].biome)) { continue; } // Check all special biome defs if this tiles biome should be converted into a new biome foreach (BiomeDef biome in specialBiomes) { BiomeWorkerSpecial worker = biome.WorkerSpecial(); Tile currTile = tiles[i]; if (worker.PreRequirements(currTile) && worker.TryGenerateByChance()) { // Update biome and biome data via mod extensions currTile.biome = biome; GenWorldGen.UpdateTileByBiomeModExts(currTile); // Apply post generation effects (e.g. change more surrounding tiles) worker.PostGeneration(i); } } } // Change hilliness around caves to make them appear deeper in mountains for (int i = 0; i < tilesCount; i++) { Tile currTile = tiles[i]; if (currTile.biome == BiomeDefOf.CaveOasis || currTile.biome == BiomeDefOf.TunnelworldCave) { List<BiomeDef> excludeBiomes = new List<BiomeDef>(specialBiomes); excludeBiomes.Add(RimWorld.BiomeDefOf.SeaIce); excludeBiomes.Add(RimWorld.BiomeDefOf.Lake); excludeBiomes.Add(RimWorld.BiomeDefOf.Ocean); MakeImpassableHillsAroundTile(grid, i, excludeBiomes, 1); } } }