AquaDX/AquaMai/Fix/BasicFix.cs

88 lines
2.4 KiB
C#
Raw Normal View History

using System.Net;
using HarmonyLib;
2024-07-09 18:11:06 +08:00
using Manager;
using Monitor.MusicSelect.ChainList;
2024-08-04 12:27:09 +08:00
using Net;
2024-07-27 05:47:45 +08:00
using UnityEngine;
2024-07-09 18:11:06 +08:00
namespace AquaMai.Fix;
public class BasicFix
{
[HarmonyPrefix]
2024-07-26 23:24:42 +08:00
[HarmonyPatch(typeof(MAI2System.IniFile), "clear")]
2024-07-09 18:11:06 +08:00
private static bool PreIniFileClear()
{
return false;
}
2024-07-27 05:47:45 +08:00
[HarmonyPrefix]
[HarmonyPatch(typeof(DebugInput), "GetKey")]
private static bool GetKey(ref bool __result, KeyCode name)
{
__result = UnityEngine.Input.GetKey(name);
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(DebugInput), "GetKeyDown")]
private static bool GetKeyDown(ref bool __result, KeyCode name)
{
__result = UnityEngine.Input.GetKeyDown(name);
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(DebugInput), "GetMouseButton")]
private static bool GetMouseButton(ref bool __result, int button)
{
__result = UnityEngine.Input.GetMouseButton(button);
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(DebugInput), "GetMouseButtonDown")]
private static bool GetMouseButtonDown(ref bool __result, int button)
{
__result = UnityEngine.Input.GetMouseButtonDown(button);
return false;
}
2024-08-04 12:27:09 +08:00
[HarmonyPostfix]
[HarmonyPatch(typeof(NetHttpClient), MethodType.Constructor)]
private static void OnNetHttpClientConstructor(NetHttpClient __instance)
2024-10-03 16:40:51 +08:00
{
// Bypass Cake.dll hash check
var tInstance = Traverse.Create(__instance).Field("isTrueDll");
if (tInstance.FieldExists())
{
tInstance.SetValue(true);
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(NetHttpClient), "Create")]
private static void OnNetHttpClientCreate()
{
// Unset the certificate validation callback (SSL pinning) to restore the default behavior
ServicePointManager.ServerCertificateValidationCallback = null;
2024-10-03 16:40:51 +08:00
}
2024-10-24 01:15:55 +08:00
public static void DoCustomPatch(HarmonyLib.Harmony h)
{
if (typeof(GameManager).GetMethod("CalcSpecialNum") is null) return;
h.PatchAll(typeof(CalcSpecialNumPatch));
}
private class CalcSpecialNumPatch
{
[HarmonyPrefix]
[HarmonyPatch(typeof(GameManager), "CalcSpecialNum")]
private static bool CalcSpecialNum(ref int __result)
{
__result = 1024;
return false;
}
}
2024-07-09 18:11:06 +08:00
}