-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathLogAlerter.cs
More file actions
28 lines (24 loc) · 884 Bytes
/
LogAlerter.cs
File metadata and controls
28 lines (24 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System.Reflection;
using Elements.Core;
using HarmonyLib;
namespace BepInExResoniteShim;
[HarmonyPatch(typeof(UniLog), "add_OnLog")]
class LogAlerter
{
static readonly FieldInfo? _logStreamField = AccessTools.Field(
Type.GetType("FrooxEngine.Headless.Program, Resonite"), "logStream");
static void Postfix(Action<string> value)
{
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.");
});
}
}