sorted code around mod disabling

This commit is contained in:
Alex
2025-05-27 13:37:31 +01:00
parent 41530b32a6
commit f679dea8d2
+14 -11
View File
@@ -21,22 +21,22 @@ public static class Program
// Initialize the program variables // Initialize the program variables
ProgramStatics.Initialize(); ProgramStatics.Initialize();
// Search for mod dlls
var mods = ModDllLoader.LoadAllMods();
// Create web builder and logger // Create web builder and logger
var builder = CreateNewHostBuilder(args); var builder = CreateNewHostBuilder(args);
// validate and sort mods, this will also discard any mods that are invalid
var sortedLoadedMods = ValidateMods(mods);
var diHandler = new DependencyInjectionHandler(builder.Services); var diHandler = new DependencyInjectionHandler(builder.Services);
// register SPT components // register SPT components
diHandler.AddInjectableTypesFromTypeAssembly(typeof(Program)); diHandler.AddInjectableTypesFromTypeAssembly(typeof(Program));
diHandler.AddInjectableTypesFromTypeAssembly(typeof(App)); diHandler.AddInjectableTypesFromTypeAssembly(typeof(App));
List<SptMod> loadedMods = null;
if (ProgramStatics.MODS()) if (ProgramStatics.MODS())
{ {
// Search for mod dlls
loadedMods = ModDllLoader.LoadAllMods();
// validate and sort mods, this will also discard any mods that are invalid
var sortedLoadedMods = ValidateMods(loadedMods);
diHandler.AddInjectableTypesFromAssemblies(sortedLoadedMods.SelectMany(a => a.Assemblies)); diHandler.AddInjectableTypesFromAssemblies(sortedLoadedMods.SelectMany(a => a.Assemblies));
} }
diHandler.InjectAll(); diHandler.InjectAll();
@@ -53,15 +53,18 @@ public static class Program
var appContext = serviceProvider.GetService<ApplicationContext>(); var appContext = serviceProvider.GetService<ApplicationContext>();
appContext?.AddValue(ContextVariableType.SERVICE_PROVIDER, serviceProvider); appContext?.AddValue(ContextVariableType.SERVICE_PROVIDER, serviceProvider);
// Initialize PreSptMods if (ProgramStatics.MODS())
var preSptLoadMods = serviceProvider.GetServices<IPreSptLoadMod>();
foreach (var preSptLoadMod in preSptLoadMods)
{ {
preSptLoadMod.PreSptLoad(); // Initialize PreSptMods
var preSptLoadMods = serviceProvider.GetServices<IPreSptLoadMod>();
foreach (var preSptLoadMod in preSptLoadMods)
{
preSptLoadMod.PreSptLoad();
}
} }
// Add the Loaded Mod Assemblies for later // Add the Loaded Mod Assemblies for later
appContext?.AddValue(ContextVariableType.LOADED_MOD_ASSEMBLIES, mods); appContext?.AddValue(ContextVariableType.LOADED_MOD_ASSEMBLIES, loadedMods);
// This is the builder that will get use by the HttpServer to start up the web application // This is the builder that will get use by the HttpServer to start up the web application
appContext?.AddValue(ContextVariableType.APP_BUILDER, builder); appContext?.AddValue(ContextVariableType.APP_BUILDER, builder);