@@ -36,6 +36,30 @@ public WorldBoxMod() : base(ClassInjector.DerivedConstructorPointer<WorldBoxMod>
3636 /// </summary>
3737 public static List < IMod > LoadedMods = new ( ) ;
3838
39+ /// <summary>
40+ /// Tries to get a loaded mod by declaration UID.
41+ /// </summary>
42+ /// <param name="pModDeclare">The target mod declaration.</param>
43+ /// <param name="pLoadedMod">The loaded mod instance when found.</param>
44+ /// <returns><see langword="true"/> when the mod is loaded; otherwise <see langword="false"/>.</returns>
45+ public static bool TryGetLoadedMod ( ModDeclare pModDeclare , out IMod pLoadedMod )
46+ {
47+ if ( pModDeclare != null )
48+ {
49+ foreach ( var mod in LoadedMods )
50+ {
51+ if ( mod . GetDeclaration ( ) . UID == pModDeclare . UID )
52+ {
53+ pLoadedMod = mod ;
54+ return true ;
55+ }
56+ }
57+ }
58+
59+ pLoadedMod = null ;
60+ return false ;
61+ }
62+
3963 internal static Dictionary < ModDeclare , ModState > AllRecognizedMods = new ( ) ;
4064 internal static Transform Transform ;
4165 internal static Transform InactiveTransform ;
@@ -110,13 +134,19 @@ private void Update()
110134 } ) , "Initialize NeoModLoader" ) ;
111135
112136 List < ModDependencyNode > mod_nodes = new ( ) ;
137+ < << << << HEAD
113138 SmoothLoader . add ( C < MapLoaderAction > ( ( ) =>
139+ = == == ==
140+ ModEnablePlan startup_enable_plan = null ;
141+ SmoothLoader . add ( ( ) =>
142+ > >>> >>> upstream / master
114143 {
115144 ModCompileLoadService . loadInfoOfBepInExPlugins ( ) ;
116145
117- var mods = ModInfoUtils . findAndPrepareMods ( ) ;
118-
119- mod_nodes . AddRange ( ModDepenSolveService . SolveModDependencies ( mods ) ) ;
146+ ModInfoUtils. findAndPrepareMods ( ) ;
147+ ModDepenSolveService. InitializeGraph ( AllRecognizedMods . Keys ) ;
148+ startup_enable_plan = ModDepenSolveService. BuildStartupEnablePlan ( ) ;
149+ mod_nodes. AddRange ( startup_enable_plan . LoadOrder ) ;
120150
121151 ModCompileLoadService. prepareCompile ( mod_nodes ) ;
122152 } ) , "Load Mods Info And Prepare Mods" ) ;
@@ -157,7 +187,23 @@ private void Update()
157187 SmoothLoader . add ( C < MapLoaderAction > ( ( ) =>
158188 {
159189 ModCompileLoadService . loadMods ( mods_to_load ) ;
190+ < << << << HEAD
160191 Linker . AddAssets( ) ;
192+ = == == ==
193+ Builder . BuildAll ( ) ;
194+ if ( startup_enable_plan != null )
195+ {
196+ if ( startup_enable_plan . RequestedRoots . All ( ModCompileLoadService . IsModLoaded ) )
197+ {
198+ ModDepenSolveService . CommitEnablePlan ( startup_enable_plan ) ;
199+ }
200+ else
201+ {
202+ ModDepenSolveService . RollbackEnablePlan ( startup_enable_plan ) ;
203+ }
204+ }
205+
206+ > >>> >>> upstream / master
161207 ModInfoUtils. SaveModRecords ( ) ;
162208 NCMSCompatibleLayer . Init ( ) ;
163209 var successfulInit = new Dictionary < IMod , bool > ( ) ;
@@ -356,4 +402,4 @@ void extractAssemblies()
356402 }
357403
358404 }
359- }
405+ }
0 commit comments