diff --git a/QSB/Patches/QSBPatchManager.cs b/QSB/Patches/QSBPatchManager.cs index e49f88f3..5c678ab8 100644 --- a/QSB/Patches/QSBPatchManager.cs +++ b/QSB/Patches/QSBPatchManager.cs @@ -17,8 +17,25 @@ public static class QSBPatchManager public static Dictionary TypeToInstance = new(); + private static bool _inited; + public static void Init() { + if (_inited) + { + var count = _patchList.Count; + foreach (var type in typeof(QSBPatch).GetDerivedTypes()) + { + if (!_patchList.Any(x => x.GetType() == type)) + { + _patchList.Add((QSBPatch)Activator.CreateInstance(type)); + } + } + + DebugLog.DebugWrite($"Registered {_patchList.Count - count} addon patches.", MessageType.Success); + return; + } + foreach (var type in typeof(QSBPatch).GetDerivedTypes()) { _patchList.Add((QSBPatch)Activator.CreateInstance(type)); @@ -29,6 +46,7 @@ public static class QSBPatchManager TypeToInstance.Add(type, new Harmony(type.ToString())); } + _inited = true; DebugLog.DebugWrite("Patch Manager ready.", MessageType.Success); } diff --git a/QSB/QSBCore.cs b/QSB/QSBCore.cs index 48e9137c..538d0a39 100644 --- a/QSB/QSBCore.cs +++ b/QSB/QSBCore.cs @@ -163,6 +163,9 @@ public class QSBCore : ModBehaviour InitAssemblies(); + // init again to get addon patches + QSBPatchManager.Init(); + MenuApi = ModHelper.Interaction.TryGetModApi(ModHelper.Manifest.Dependencies[0]); DebugLog.DebugWrite("loading qsb_network_big bundle", MessageType.Info); @@ -215,6 +218,7 @@ public class QSBCore : ModBehaviour var addons = GetDependants(); foreach (var addon in addons) { + DebugLog.DebugWrite($"Registering addon {addon.ModHelper.Manifest.UniqueName}"); Addons.Add(addon.ModHelper.Manifest.UniqueName, addon); } }