diff --git a/src/RealTime/Core/RealTimeCore.cs b/src/RealTime/Core/RealTimeCore.cs
index f9d0395c5c69f2ed8277e94a92bc55cdb74d42e7..b4a207340fa9d5207ec0e25175b4189be4d932bb 100644
--- a/src/RealTime/Core/RealTimeCore.cs
+++ b/src/RealTime/Core/RealTimeCore.cs
@@ -187,7 +187,7 @@ namespace RealTime.Core
if (appliedPatches.Contains(CitizenManagerPatch.CreateCitizenPatch1))
{
- CitizenManagerPatch.NewCitizenBehavior = new NewCitizenBehavior(randomizer);
+ CitizenManagerPatch.NewCitizenBehavior = new NewCitizenBehavior(randomizer, configProvider.Configuration);
}
if (appliedPatches.Contains(BuildingAIPatches.GetColor))
diff --git a/src/RealTime/CustomAI/INewCitizenBehavior.cs b/src/RealTime/CustomAI/INewCitizenBehavior.cs
index 637b96892e1b85f9c1dcdabe656a5798989996ed..ac12a4145f58fb762baf136986e16b2917eafd4e 100644
--- a/src/RealTime/CustomAI/INewCitizenBehavior.cs
+++ b/src/RealTime/CustomAI/INewCitizenBehavior.cs
@@ -14,9 +14,10 @@ namespace RealTime.CustomAI
///
///
/// The citizen's age as raw value (0-255).
+ /// The current value of the citizen's education.
///
/// The education level of the new citizen with the specified age.
- Citizen.Education GetEducation(int age);
+ Citizen.Education GetEducation(int age, Citizen.Education currentEducation);
///
/// Adjusts the age of the new citizen based on their current .
diff --git a/src/RealTime/CustomAI/NewCitizenBehavior.cs b/src/RealTime/CustomAI/NewCitizenBehavior.cs
index f84fd278dbfbc2a946d3796fe08eeeecdfc2b88a..d0979252f90e430cbb63be26230ebd2f31412e94 100644
--- a/src/RealTime/CustomAI/NewCitizenBehavior.cs
+++ b/src/RealTime/CustomAI/NewCitizenBehavior.cs
@@ -4,6 +4,8 @@
namespace RealTime.CustomAI
{
+ using System;
+ using RealTime.Config;
using RealTime.Simulation;
///
@@ -12,23 +14,33 @@ namespace RealTime.CustomAI
internal sealed class NewCitizenBehavior : INewCitizenBehavior
{
private readonly IRandomizer randomizer;
+ private readonly RealTimeConfig config;
///
/// Initializes a new instance of the class.
///
/// The randomizer to use for random decisions.
- public NewCitizenBehavior(IRandomizer randomizer)
+ /// The configuration to run with.
+ /// Thrown when any argument is null.
+ public NewCitizenBehavior(IRandomizer randomizer, RealTimeConfig config)
{
- this.randomizer = randomizer;
+ this.randomizer = randomizer ?? throw new ArgumentNullException(nameof(randomizer));
+ this.config = config ?? throw new ArgumentNullException(nameof(config));
}
///
/// Gets the education level of the new citizen based on their .
///
/// The citizen's age as raw value (0-255).
+ /// The current value of the citizen's education.
/// The education level of the new citizen with the specified age.
- public Citizen.Education GetEducation(int age)
+ public Citizen.Education GetEducation(int age, Citizen.Education currentEducation)
{
+ if (!config.UseSlowAging)
+ {
+ return currentEducation;
+ }
+
var randomValue = randomizer.GetRandomValue(100u);
// Age:
@@ -118,7 +130,7 @@ namespace RealTime.CustomAI
// 45-89 -> young
// 90-179 -> adult
// 180-255 -> senior
- if (age <= 1)
+ if (!config.UseSlowAging || age <= 1)
{
return age;
}
diff --git a/src/RealTime/GameConnection/Patches/CitizenManagerPatch.cs b/src/RealTime/GameConnection/Patches/CitizenManagerPatch.cs
index e8d9a96e170930d517ffb05418b3e45dbc9f8dc0..93d87b174932be35640d08d64641001cf6ab32e8 100644
--- a/src/RealTime/GameConnection/Patches/CitizenManagerPatch.cs
+++ b/src/RealTime/GameConnection/Patches/CitizenManagerPatch.cs
@@ -34,7 +34,7 @@ namespace RealTime.GameConnection.Patches
private static void UpdateCitizenEducation(uint citizenId)
{
ref var citizen = ref CitizenManager.instance.m_citizens.m_buffer[citizenId];
- var newEducation = NewCitizenBehavior.GetEducation(citizen.Age);
+ var newEducation = NewCitizenBehavior.GetEducation(citizen.Age, citizen.EducationLevel);
citizen.Education3 = newEducation == Citizen.Education.ThreeSchools;
citizen.Education2 = newEducation == Citizen.Education.TwoSchools || newEducation == Citizen.Education.ThreeSchools;
citizen.Education1 = newEducation != Citizen.Education.Uneducated;