Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeTwentyThree committed Jul 31, 2023
1 parent 6d9e7ef commit 3131c8d
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions Nautilus/Patchers/SMLHelperCompatibilityPatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ internal class SMLHelperCompatibilityPatcher
public const string SMLHarmonyInstance = "com.ahk1221.smlhelper"; // This string is both the harmony instance & plugin GUID.
public const string QModManagerGUID = "QModManager.QMMLoader";
private const string SMLAssemblyName = "SMLHelper";
private const string SMLHelperModJsonID = "SMLHelper";

private static Assembly _smlHelperAssembly;

Expand All @@ -41,18 +42,14 @@ private static bool GetSMLHelperExists()
if (!BepInEx.Bootstrap.Chainloader.PluginInfos.TryGetValue(QModManagerGUID, out var qmodManager))
return false;
var qmodServices = Assembly.GetAssembly(qmodManager.Instance.GetType()).GetType("QModManager.API.QModServices");
if (qmodServices == null)
return false;
return (bool)AccessTools.Method(qmodServices, "ModPresent").Invoke(null, new object[] { SMLHarmonyInstance });
var qmodServicesInstance = AccessTools.PropertyGetter(qmodServices, "Main").Invoke(null, new object[0]);
return (bool)AccessTools.Method(qmodServices, "ModPresent").Invoke(qmodServicesInstance, new object[] { SMLHelperModJsonID });
#endif
}

internal static void Patch(Harmony harmony)
{
if (SMLHelperInstalled)
{
CoroutineHost.StartCoroutine(WaitOnSMLHelperForPatches(harmony));
}
CoroutineHost.StartCoroutine(WaitOnSMLHelperForPatches(harmony));
}

private static IEnumerator WaitOnSMLHelperForPatches(Harmony harmony)
Expand All @@ -73,6 +70,11 @@ private static IEnumerator WaitOnSMLHelperForPatches(Harmony harmony)

yield return null;

if (!SMLHelperInstalled)
{
yield break;
}

InternalLogger.Log("Patching SMLHelper compatibility fixes", BepInEx.Logging.LogLevel.Info);

// Finally apply the patches:
Expand Down

0 comments on commit 3131c8d

Please sign in to comment.