diff --git a/Modding/ModLoader.cs b/Modding/ModLoader.cs index 9ffe957..9396a5d 100644 --- a/Modding/ModLoader.cs +++ b/Modding/ModLoader.cs @@ -40,6 +40,7 @@ public static Mod LoadMod(string modDirectoryPath, bool executeAssemblies = true { // Load mod Mod mod = new(Mod.Metadata.Load(modDirectoryPath)); + ModLoader.loadedMods.Add(mod.Meta.Id, mod); // Cache XML data of loaded mods for repeat enumeration later XmlElement[] data = ModLoader.LoadedMods.Values @@ -57,9 +58,6 @@ public static Mod LoadMod(string modDirectoryPath, bool executeAssemblies = true ModLoader.StartupMod(mod); } - // Register mod as fully loaded - ModLoader.loadedMods.Add(mod.Meta.Id, mod); - return mod; } @@ -84,6 +82,7 @@ public static IEnumerable LoadMods(IEnumerable modDirectoryPaths, b // Load mod Mod mod = new(metadata); mods.Add(mod); + ModLoader.loadedMods.Add(mod.Meta.Id, mod); // Apply mod patches XmlElement? root = mod.Data?.DocumentElement; @@ -93,16 +92,10 @@ public static IEnumerable LoadMods(IEnumerable modDirectoryPaths, b } mod.Patches.ForEach(patch => data.ForEach(patch.Apply)); } - foreach (Mod mod in mods) + // Execute mod assemblies + if (executeAssemblies) { - // Execute mod assemblies - if (executeAssemblies) - { - ModLoader.StartupMod(mod); - } - - // Register mod as fully loaded - ModLoader.loadedMods.Add(mod.Meta.Id, mod); + mods.ForEach(ModLoader.StartupMod); } return mods; } diff --git a/Modot.csproj b/Modot.csproj index ead8a9b..0125df0 100644 --- a/Modot.csproj +++ b/Modot.csproj @@ -8,7 +8,7 @@ true true - 2.0.1 + 2.0.2 Modot Carnagion A mod loader and API for applications made using Godot, with the ability to load C# assemblies, XML data, and resource packs at runtime. diff --git a/README.md b/README.md index 4eef7fa..73e2e7a 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ A more detailed explanation of all features along with instructions on usage is Simply include the following lines in a Godot project's `.csproj` file (either by editing the file manually or letting an IDE install the package): ```xml - + ```