[WindowFocusCheckFix] iniyial push

This commit is contained in:
NotAKidoS 2025-04-12 04:05:48 -05:00
parent a6fa59d24c
commit 1f99312c22
5 changed files with 114 additions and 0 deletions

View file

@ -0,0 +1,39 @@
using System.Reflection;
using ABI_RC.Core;
using HarmonyLib;
using MelonLoader;
using UnityEngine;
namespace NAK.WindowFocusCheckFix;
public class WindowFocusCheckFixMod : MelonMod
{
#region Melon Events
public override void OnInitializeMelon()
{
#region WindowFocusManager Patches
HarmonyInstance.Patch(
typeof(WindowFocusManager).GetMethod(nameof(WindowFocusManager.IsWindowFocused),
BindingFlags.NonPublic | BindingFlags.Static),
prefix: new HarmonyMethod(typeof(WindowFocusCheckFixMod).GetMethod(nameof(OnPreWindowFocusManagerIsWindowFocused),
BindingFlags.NonPublic | BindingFlags.Static))
);
#endregion WindowFocusManager Patches
}
#endregion Melon Events
#region Harmony Patches
// ReSharper disable once RedundantAssignment
private static bool OnPreWindowFocusManagerIsWindowFocused(ref bool __result)
{
__result = Application.isFocused; // use Unity method instead
return false;
}
#endregion Harmony Patches
}