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>
27 lines
778 B
C#
27 lines
778 B
C#
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)];
|
|
}
|
|
}
|