public static World GenerateWorld(float planetCoverage, string seedString, OverallRainfall overallRainfall, OverallTemperature overallTemperature) { DeepProfiler.Start("GenerateWorld"); Rand.PushState(); int seedFromSeedString = WorldGenerator.GetSeedFromSeedString(seedString); Rand.Seed = seedFromSeedString; World creatingWorld; try { Current.CreatingWorld = new World(); Current.CreatingWorld.info.seedString = seedString; Current.CreatingWorld.info.planetCoverage = planetCoverage; Current.CreatingWorld.info.overallRainfall = overallRainfall; Current.CreatingWorld.info.overallTemperature = overallTemperature; Current.CreatingWorld.info.name = NameGenerator.GenerateName(RulePackDefOf.NamerWorld, null, false, null, null); WorldGenerator.tmpGenSteps.Clear(); WorldGenerator.tmpGenSteps.AddRange(WorldGenerator.GenStepsInOrder); for (int i = 0; i < WorldGenerator.tmpGenSteps.Count; i++) { DeepProfiler.Start("WorldGenStep - " + WorldGenerator.tmpGenSteps[i]); try { Rand.Seed = Gen.HashCombineInt(seedFromSeedString, WorldGenerator.GetSeedPart(WorldGenerator.tmpGenSteps, i)); WorldGenerator.tmpGenSteps[i].worldGenStep.GenerateFresh(seedString); } catch (Exception arg) { Log.Error("Error in WorldGenStep: " + arg, false); } finally { DeepProfiler.End(); } } Rand.Seed = seedFromSeedString; Current.CreatingWorld.grid.StandardizeTileData(); Current.CreatingWorld.FinalizeInit(); Find.Scenario.PostWorldGenerate(); creatingWorld = Current.CreatingWorld; } finally { Rand.PopState(); DeepProfiler.End(); Current.CreatingWorld = null; } return(creatingWorld); }
public static void GenerateWithoutWorldData(string seedString) { int seedFromSeedString = WorldGenerator.GetSeedFromSeedString(seedString); WorldGenerator.tmpGenSteps.Clear(); WorldGenerator.tmpGenSteps.AddRange(WorldGenerator.GenStepsInOrder); Rand.PushState(); for (int i = 0; i < WorldGenerator.tmpGenSteps.Count; i++) { try { Rand.Seed = Gen.HashCombineInt(seedFromSeedString, WorldGenerator.GetSeedPart(WorldGenerator.tmpGenSteps, i)); WorldGenerator.tmpGenSteps[i].worldGenStep.GenerateWithoutWorldData(seedString); } catch (Exception arg) { Log.Error("Error in WorldGenStep: " + arg, false); } } Rand.PopState(); }