Replace selectable name sets with a country that owns names and climate presets.
Create picks a country; climate is rolled from the school seed and stored. Old Slavic saves lift as Russia. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
namespace HSchool.People;
|
||||
|
||||
/// <summary>
|
||||
/// A country lists climate presets; the school rolls one at birth from the school seed.
|
||||
/// Reloads without a stored pick take the first listed preset so old saves stay put.
|
||||
/// </summary>
|
||||
public static class CountryClimate
|
||||
{
|
||||
public static string? Pick(CountryDef country, int schoolSeed, bool rollIfOmitted)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(country);
|
||||
var presets = country.ClimatePresets;
|
||||
if (presets.Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!rollIfOmitted || presets.Count == 1)
|
||||
{
|
||||
return presets[0];
|
||||
}
|
||||
|
||||
var rng = new Random(Seed.ForSchool(schoolSeed, Seed.ClimatePresetSalt));
|
||||
return presets[rng.Next(presets.Count)];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user