From 5dbb884417fed1e36bf9ef235f9a8a9604f1c42d Mon Sep 17 00:00:00 2001 From: Auros Date: Mon, 4 May 2020 18:11:26 -0400 Subject: [PATCH] Added recursive plugin loading Can be controlled through the config --- IPA.Loader/Config/SelfConfig.cs | 2 ++ IPA.Loader/Loader/PluginLoader.cs | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/IPA.Loader/Config/SelfConfig.cs b/IPA.Loader/Config/SelfConfig.cs index 2611a6cb..7d21a35e 100644 --- a/IPA.Loader/Config/SelfConfig.cs +++ b/IPA.Loader/Config/SelfConfig.cs @@ -161,5 +161,7 @@ namespace IPA.Config public virtual string LastGameVersion { get; set; } = null; // LINE: ignore public static string LastGameVersion_ => Instance?.LastGameVersion; + + public virtual bool RecursivePluginLoading { get; set; } = false; } } \ No newline at end of file diff --git a/IPA.Loader/Loader/PluginLoader.cs b/IPA.Loader/Loader/PluginLoader.cs index 98e377e8..ffea4205 100644 --- a/IPA.Loader/Loader/PluginLoader.cs +++ b/IPA.Loader/Loader/PluginLoader.cs @@ -70,9 +70,24 @@ namespace IPA.Loader private static readonly Regex embeddedTextDescriptionPattern = new Regex(@"#!\[(.+)\]", RegexOptions.Compiled | RegexOptions.Singleline); + internal static List FindPluginsRecursively(string directory) + { + List dirs = new List(); + foreach (var dir in Directory.GetDirectories(directory)) + { + dirs.AddRange(FindPluginsRecursively(dir)); + } + foreach (var file in Directory.GetFiles(directory, "*.dll")) + { + dirs.Add(file); + } + return dirs; + } + internal static void LoadMetadata() { - string[] plugins = Directory.GetFiles(UnityGame.PluginsPath, "*.dll"); + + string[] plugins = !SelfConfig.Instance.RecursivePluginLoading ? Directory.GetFiles(UnityGame.PluginsPath, "*.dll") : FindPluginsRecursively(UnityGame.PluginsPath).ToArray(); try {