Skip to content

Commit

Permalink
Include static methods when searching for mod startup methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Carnagion committed Aug 14, 2022
1 parent cf265df commit 5449979
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Modding/ModLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private static void StartupMod(Mod mod)
// Invoke all static methods annotated with [Startup] along with the supplied parameters (if any)
mod.Assemblies
.SelectMany(assembly => assembly.GetTypes())
.SelectMany(type => type.GetMethods(BindingFlags.NonPublic | BindingFlags.Public))
.SelectMany(type => type.GetMethods(BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Public))
.Select(method => (method, method.GetCustomAttribute<ModStartupAttribute>()))
.Where(pair => pair.Item2 is not null)
.ForEach(pair => pair.Item1.Invoke(null, pair.Item2.Parameters));
Expand Down

0 comments on commit 5449979

Please sign in to comment.