diff --git a/BepInExResoniteShim.cs b/BepInExResoniteShim.cs
index 36129fa..e8a7e9a 100644
--- a/BepInExResoniteShim.cs
+++ b/BepInExResoniteShim.cs
@@ -90,16 +90,29 @@ public override void Load()
Log.LogError($"Failed to register generic type converters (Last attempted = {lastAttempted?.ToString() ?? "NULL"}): " + e);
}
- RunPatches();
+ RunPatches(HarmonyInstance);
}
- void RunPatches()
+ internal static bool AnyPatchFailed { get; private set; }
+
+ ///
+ /// Apply all patches, incompatible patches are skipped gracefully.
+ ///
+ static void RunPatches(Harmony harmony)
{
- HarmonyInstance.PatchAllUncategorized();//core patches. if these fail everything fails.
- HarmonyInstance.SafePatchCategory(nameof(GraphicalClientPatch));
- HarmonyInstance.SafePatchCategory(nameof(WindowTitlePatcher));
- HarmonyInstance.SafePatchCategory(nameof(LogAlerter));
- HarmonyInstance.SafePatchCategory(nameof(RelativePathFixer));
+ var assembly = Assembly.GetExecutingAssembly();
+ foreach (var type in AccessTools.GetTypesFromAssembly(assembly))
+ {
+ try
+ {
+ harmony.CreateClassProcessor(type).Patch();
+ }
+ catch (Exception e)
+ {
+ Log.LogDebug($"Skipped patching {type.Name}: {e.Message}");
+ AnyPatchFailed = true;
+ }
+ }
}
[HarmonyPatch]
@@ -182,7 +195,6 @@ public static IEnumerable Transpiler(IEnumerable value)
{
- if(AnyPatchFailed) value($"[BepisLoader] BepInExResoniteShim partially loaded.");
- else value($"[BepisLoader] BepInExResoniteShim loaded successfully.");
+ Task.Run(async () =>
+ {
+ if (_logStreamField != null)
+ {
+ var timeout = DateTime.UtcNow.AddSeconds(10);
+ while (_logStreamField.GetValue(null) is null && DateTime.UtcNow < timeout)
+ await Task.Delay(1);
+ }
+
+ if (BepInExResoniteShim.AnyPatchFailed) value($"[BepisLoader] BepInExResoniteShim partially loaded.");
+ else value($"[BepisLoader] BepInExResoniteShim loaded successfully.");
+ });
}
}
diff --git a/RelativePathFixer.cs b/RelativePathFixer.cs
index 726877a..bfb8e15 100644
--- a/RelativePathFixer.cs
+++ b/RelativePathFixer.cs
@@ -8,7 +8,6 @@ namespace BepInExResoniteShim;
class RelativePathFixer
{
- [HarmonyPatchCategory(nameof(RelativePathFixer))]
[HarmonyPatch(typeof(Program), "$", MethodType.Async)]
class RenderiteHostPathFixes
{
@@ -45,7 +44,6 @@ public static void FileWriteInjected(string path, string? contents)
}
}
- [HarmonyPatchCategory(nameof(RelativePathFixer))]
[HarmonyPatch(typeof(RenderSystem), "StartRenderer", MethodType.Async)]
public class RenderiteWorkingDirectoryFix
{