mirror of
https://github.com/misternebula/quantum-space-buddies.git
synced 2024-12-29 03:28:26 +00:00
fix addon patches
This commit is contained in:
parent
cda630ada6
commit
262d32c7f3
@ -17,8 +17,25 @@ public static class QSBPatchManager
|
||||
|
||||
public static Dictionary<QSBPatchTypes, Harmony> 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);
|
||||
}
|
||||
|
||||
|
@ -163,6 +163,9 @@ public class QSBCore : ModBehaviour
|
||||
|
||||
InitAssemblies();
|
||||
|
||||
// init again to get addon patches
|
||||
QSBPatchManager.Init();
|
||||
|
||||
MenuApi = ModHelper.Interaction.TryGetModApi<IMenuAPI>(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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user