@@ -9,18 +9,19 @@ namespace CommunityFixes.Fix.ExperimentBiomePauseFix;
99[ Fix ( "Fix experiments pausing when switching biome for scenarios where biome is irrelevant" ) ]
1010public class ExperimentBiomePauseFix : BaseFix
1111{
12- public static ExperimentBiomePauseFix Instance ;
12+ private static ExperimentBiomePauseFix _instance ;
1313
1414 // This fix makes assumptions about the game's code and reads/writes private state, which can end up in save files.
1515 // In order to avoid accidentally breaking anything, we only apply the patch to known-broken versions of the game.
16- public static readonly HashSet < string > KnownBrokenVersions = new ( ) { "0.2.0.0.30291" } ;
17- public static string GameVersion = typeof ( VersionID )
16+ private static readonly HashSet < string > KnownBrokenVersions = new ( ) { "0.2.0.0.30291" } ;
17+
18+ private static readonly string GameVersion = typeof ( VersionID )
1819 . GetField ( "VERSION_TEXT" , BindingFlags . Static | BindingFlags . Public )
1920 ? . GetValue ( null ) as string ;
2021
2122 public override void OnInitialized ( )
2223 {
23- Instance = this ;
24+ _instance = this ;
2425 if ( KnownBrokenVersions . Contains ( GameVersion ) )
2526 {
2627 HarmonyInstance . PatchAll ( typeof ( ExperimentBiomePauseFix ) ) ;
@@ -37,7 +38,10 @@ public override void OnInitialized()
3738 // of the experiment are unchanged.
3839 // To avoid breaking things when we skip RefreshLocationsValidity, we also update some private state that the method
3940 // is responsible for when skipping it.
40- [ HarmonyPatch ( typeof ( PartComponentModule_ScienceExperiment ) , "RefreshLocationsValidity" ) ]
41+ [ HarmonyPatch (
42+ typeof ( PartComponentModule_ScienceExperiment ) ,
43+ nameof ( PartComponentModule_ScienceExperiment . RefreshLocationsValidity )
44+ ) ]
4145 [ HarmonyPrefix ]
4246 public static bool RefreshLocationsValidityPrefix (
4347 // ReSharper disable once InconsistentNaming
@@ -74,12 +78,13 @@ ref Data_ScienceExperiment ___dataScienceExperiment
7478 newRegions . Add ( newLocation . ScienceRegion ) ;
7579 continue ;
7680 }
81+
7782 safeToSkip = false ;
7883 }
7984
8085 if ( safeToSkip )
8186 {
82- Instance . Logger . LogInfo (
87+ _instance . Logger . LogInfo (
8388 "Skipping PartComponentModule_ScienceExperiment.RefreshLocationsValidity - experiment is still valid."
8489 ) ;
8590
@@ -89,6 +94,7 @@ ref Data_ScienceExperiment ___dataScienceExperiment
8994 ___dataScienceExperiment . ExperimentStandings [ i ] . ExperimentLocation . SetScienceRegion ( newRegions [ i ] ) ;
9095 }
9196 }
97+
9298 return ! safeToSkip ;
9399 }
94- }
100+ }
0 commit comments