diff --git a/Changelog.txt b/Changelog.txt
index 7ad3361..c62ebbe 100644
--- a/Changelog.txt
+++ b/Changelog.txt
@@ -1,6 +1,7 @@
Version 2.0.1 -
- Add option to display units in US customary measures (does not apply to legacy calculations)
+- Enabling/disabling custom school population counts no longer requires a restart
- Implement caching of visitor count calculations
- Automatically refresh options panel on language or measurement unit change
diff --git a/Code/GUI/UIModCalcs.cs b/Code/GUI/UIModCalcs.cs
index 900964e..3208893 100644
--- a/Code/GUI/UIModCalcs.cs
+++ b/Code/GUI/UIModCalcs.cs
@@ -316,6 +316,9 @@ internal void SelectionChanged(BuildingInfo building)
// Yes - school building. Set current pack.
currentSchoolPack = (SchoolDataPack)SchoolData.instance.ActivePack(building);
+ // Hide vanilla panel.
+ vanillaPanel.Hide();
+
// Are we using custom school settings?
if (ModSettings.enableSchoolProperties)
{
diff --git a/Code/Patches/StudentCount.cs b/Code/Patches/StudentCount.cs
index 1c5794d..c66c7fb 100644
--- a/Code/Patches/StudentCount.cs
+++ b/Code/Patches/StudentCount.cs
@@ -17,15 +17,22 @@ public static class StudentCountPatch
///
public static bool Prefix(SchoolAI __instance, ref int __result)
{
- // Check to see if we're using realistic school populations, and school level is elementary or high school.
- if (ModSettings.EnableSchoolPop && __instance.m_info.GetClassLevel() <= ItemClass.Level.Level2)
+ // Check to see if school level is elementary or high school.
+ BuildingInfo thisInfo = __instance.m_info;
+ if (thisInfo.GetClassLevel() <= ItemClass.Level.Level2)
{
- // We are - set the result to our realistic population lookup.
- BuildingInfo thisInfo = __instance.m_info;
- __result = PopData.instance.Students(thisInfo);
+ // It's a school - check to see if we're using custom school calculations.
+ if (ModSettings.EnableSchoolPop)
+ {
+ // Custom calcs enabled - set the result to our realistic population lookup.
+ __result = PopData.instance.Students(thisInfo);
- // Don't continue on to original method.
- return false;
+ // Don't continue on to original method.
+ return false;
+ }
+
+ // Not using custom calcs - ensure default is set.
+ __instance.m_studentCount = SchoolData.instance.OriginalStudentCount(thisInfo);
}
// Not using realistic school populations - continue on to original method.
diff --git a/Code/VolumetricData/CalcPacks.cs b/Code/VolumetricData/CalcPacks.cs
index 11f660c..683ef11 100644
--- a/Code/VolumetricData/CalcPacks.cs
+++ b/Code/VolumetricData/CalcPacks.cs
@@ -81,15 +81,33 @@ public class PopDataPack : DataPack
/// Building prefab record
/// Building level
/// Workplace breakdowns and visitor count
- public virtual WorkplaceLevels Workplaces(BuildingInfo buildingPrefab, int level) => new WorkplaceLevels { level0 = 1, level1 = 0, level2 = 0, level3 = 0};
+ public virtual WorkplaceLevels Workplaces(BuildingInfo buildingPrefab, int level) => new WorkplaceLevels { level0 = 1, level1 = 0, level2 = 0, level3 = 0 };
///
- /// Returns the student count for the given building prefab and level.
+ /// Returns the student count for the given building prefab.
///
/// Building prefab record
/// Student count (0 if not a school building)
- public virtual int Students(BuildingInfo buildingPrefab) => buildingPrefab.m_buildingAI is SchoolAI ? Population(buildingPrefab, (int)buildingPrefab.m_class.m_level, Multipliers.instance.ActiveMultiplier(buildingPrefab)) : 0;
+ public virtual int Students(BuildingInfo buildingPrefab)
+ {
+ // Check for school.
+ if (buildingPrefab.m_buildingAI is SchoolAI)
+ {
+ // It's a school; are custom school calcs enabled?
+ if (ModSettings.EnableSchoolPop)
+ {
+ // Custom calcs enabled - use pack.
+ return Population(buildingPrefab, (int)buildingPrefab.m_class.m_level, Multipliers.instance.ActiveMultiplier(buildingPrefab));
+ }
+
+ // Custom school settings not enabled; use default.
+ return SchoolData.instance.OriginalStudentCount(buildingPrefab);
+ }
+
+ // If we got here, it's not a school building; return 0.
+ return 0;
+ }
}
diff --git a/Translations/en.csv b/Translations/en.csv
index 1e7195f..824d608 100644
--- a/Translations/en.csv
+++ b/Translations/en.csv
@@ -230,7 +230,7 @@ RPR_OPT_RTD,Reset to defaults
RPR_OPT_RTS,Revert to saved
RPR_OPT_SAA,Save and apply
RPR_OPT_SCH,Schools
-RPR_OPT_SEN,Enable realistic school student capacities - requires restart
+RPR_OPT_SEN,Enable realistic school student capacities
RPR_OPT_SEJ,"Enable realistic school properties (jobs, costs) - requires restart"
RPR_OPT_SDM,Default school capacity multiplier
RPR_OPT_JB0,Uneducated jobs