66using PatchManager . Core . Assets ;
77using PatchManager . Core . Cache ;
88using PatchManager . Core . Flow ;
9+ using PatchManager . SassyPatching . Execution ;
910using PatchManager . Shared ;
1011using PatchManager . Shared . Modules ;
1112using SpaceWarp . API . Configuration ;
@@ -42,24 +43,8 @@ private static bool ShouldLoad(string[] disabled, string modInfoLocation)
4243 /// <summary>
4344 /// Reads all patch files.
4445 /// </summary>
45- public override void Preload ( )
46+ public override void Init ( )
4647 {
47- // Go here instead so that the static constructor recognizes everything
48- PatchingManager . GenerateUniverse ( ) ;
49- var disabledPlugins = File . ReadAllText ( Path . Combine ( Paths . BepInExRootPath , "disabled_plugins.cfg" ) )
50- . Split ( new [ ] { '\n ' } , StringSplitOptions . RemoveEmptyEntries ) ;
51-
52- var modFolders = Directory . GetDirectories ( Paths . PluginPath , "*" , SearchOption . AllDirectories )
53- . Where ( dir => ShouldLoad ( disabledPlugins , Path . Combine ( dir , "swinfo.json" ) ) ) . Select ( x => ( Folder : x , Info : JsonConvert . DeserializeObject < ModInfo > ( File . ReadAllText ( Path . Combine ( x , "swinfo.json" ) ) ) ) ) ;
54-
55- foreach ( var modFolder in modFolders )
56- {
57- Logging . LogInfo ( $ "Loading patchers from { modFolder . Folder } ") ;
58- // var modName = Path.GetDirectoryName(modFolder);
59- PatchingManager . ImportModPatches ( modFolder . Info . ModID , modFolder . Folder ) ;
60- }
61-
62- PatchingManager . RegisterPatches ( ) ;
6348
6449 if ( _shouldAlwaysInvalidate . Value || SpaceWarp . API . Mods . PluginList . ModListChangedSinceLastRun )
6550 {
@@ -75,16 +60,33 @@ public override void Preload()
7560 SpaceWarp . API . Loading . Loading . GeneralLoadingActions . Insert ( 0 , ( ) => new GenericFlowAction ( "Patch Manager: Creating New Assets" , PatchingManager . CreateNewAssets ) ) ;
7661 SpaceWarp . API . Loading . Loading . GeneralLoadingActions . Insert ( 1 , ( ) => new GenericFlowAction ( "Patch Manager: Rebuilding Cache" , PatchingManager . RebuildAllCache ) ) ;
7762 SpaceWarp . API . Loading . Loading . GeneralLoadingActions . Insert ( 2 , ( ) => new GenericFlowAction ( "Patch Manager: Registering Resource Locator" , RegisterResourceLocator ) ) ;
78- // SpaceWarp.API.Loading.Loading.AddGeneralLoadingAction(
79- // () => new GenericFlowAction("Patch Manager: Creating New Assets", PatchingManager.CreateNewAssets));
80- // SpaceWarp.API.Loading.Loading.AddGeneralLoadingAction(
81- // () => new GenericFlowAction("Patch Manager: Rebuilding Cache", PatchingManager.RebuildAllCache));
8263 }
8364 else
8465 {
8566 SpaceWarp . API . Loading . Loading . GeneralLoadingActions . Insert ( 0 , ( ) => new GenericFlowAction ( "Patch Manager: Registering Resource Locator" , RegisterResourceLocator ) ) ;
8667 }
8768 }
69+
70+ /// <inheritdoc />
71+ public override void PreLoad ( )
72+ {
73+ // Go here instead so that the static constructor recognizes everything
74+ PatchingManager . GenerateUniverse ( ) ;
75+ var disabledPlugins = File . ReadAllText ( Path . Combine ( Paths . BepInExRootPath , "disabled_plugins.cfg" ) )
76+ . Split ( new [ ] { '\n ' } , StringSplitOptions . RemoveEmptyEntries ) ;
77+
78+ var modFolders = Directory . GetDirectories ( Paths . PluginPath , "*" , SearchOption . AllDirectories )
79+ . Where ( dir => ShouldLoad ( disabledPlugins , Path . Combine ( dir , "swinfo.json" ) ) ) . Select ( x => ( Folder : x , Info : JsonConvert . DeserializeObject < ModInfo > ( File . ReadAllText ( Path . Combine ( x , "swinfo.json" ) ) ) ) ) ;
80+
81+ foreach ( var modFolder in modFolders )
82+ {
83+ Logging . LogInfo ( $ "Loading patchers from { modFolder . Folder } ") ;
84+ // var modName = Path.GetDirectoryName(modFolder);
85+ PatchingManager . ImportModPatches ( modFolder . Info . ModID , modFolder . Folder ) ;
86+ }
87+ PatchingManager . RegisterPatches ( ) ;
88+ }
89+
8890 /// <summary>
8991 /// Registers the provider and locator for cached assets.
9092 /// </summary>
@@ -138,4 +140,9 @@ public override void BindConfiguration(IConfigFile modConfiguration)
138140 _shouldAlwaysInvalidate = new ( modConfiguration . Bind ( "Core" , "Always Invalidate Cache" , false ,
139141 "Should patch manager always invalidate its cache upon load" ) ) ;
140142 }
143+
144+ /// <summary>
145+ /// This is the current universe that patch manager is using (used for interop reasons)
146+ /// </summary>
147+ [ PublicAPI ] public Universe CurrentUniverse => PatchingManager . Universe ;
141148}
0 commit comments