protected override void ChangeTileAfterSuccessfulDig(Tile tile, bool end) { if (Rand.Value < BiomeChangeChance) { tile.biome = BiomeDefOf.Archipelago; GenWorldGen.UpdateTileByBiomeModExts(tile); } }
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); } } }
protected void DigTilesForBiomeChange(int startTileID, int digLengthMin, int digLengthMax, int maxDirChange, bool digBothDirections = true) { WorldGrid worldGrid = Find.WorldGrid; bool goOtherWay = false; int currTileID = startTileID; int dirBase = Rand.RangeInclusive(0, 5); for (int i = 0; i < digLengthMax; i++) { // Get good neighbor tile for next step int dir = GenWorldGen.NextRandomDigDir(dirBase, maxDirChange); currTileID = worldGrid.GetTileNeighborByDirection6WayInt(currTileID, dir); Tile tile = worldGrid[currTileID]; // Check if prerequirements for the biome are still met if (!((i < digLengthMin && MinPreRequirements(tile)) || PreRequirements(tile))) { // Try to dig in the other way from the start first, otherwise abort if (goOtherWay) { break; } else { currTileID = startTileID; dirBase = GenWorldGen.InvertDigDir(dirBase); i = -1; goOtherWay = true; continue; } } // Set new biome (only when there is no special biome on the tile) if (tile.biome.WorkerSpecial() == null) { bool endTile = (i == digLengthMax - 1); ChangeTileAfterSuccessfulDig(tile, endTile); } // Go the other way if end is reached if (digBothDirections && i == digLengthMax - 1 && !goOtherWay) { currTileID = startTileID; dirBase = GenWorldGen.InvertDigDir(dirBase); i = -1; goOtherWay = true; } } }
protected override void ChangeTileAfterSuccessfulDig(Tile tile, bool end) { float randVal = Rand.Value; if (randVal < OasisBiomeChance || end) { tile.biome = BiomeDefOf.CaveOasis; } else if (randVal < TunnelBiomeChance) { tile.biome = BiomeDefOf.TunnelworldCave; } else { tile.biome = BiomeDefOf.CaveEntrance; } GenWorldGen.UpdateTileByBiomeModExts(tile); }
public static void Postfix(ref Tile __result) { GenWorldGen.UpdateTileByBiomeModExts(__result); }
protected override void ChangeTileAfterSuccessfulDig(Tile tile, bool end) { tile.biome = BiomeDefOf.InfestedMountains; GenWorldGen.UpdateTileByBiomeModExts(tile); }
protected override void ChangeTileAfterSuccessfulDig(Tile tile, bool end) { tile.biome = BiomeDefOf.DeepRavine; GenWorldGen.UpdateTileByBiomeModExts(tile); }