2021-10-16 13:12:28 +00:00
|
|
|
|
using HarmonyLib;
|
2022-03-23 20:51:37 +00:00
|
|
|
|
using QSB.Utility;
|
2022-03-22 17:56:41 +00:00
|
|
|
|
using System;
|
2021-06-18 20:54:32 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
namespace QSB.Patches;
|
|
|
|
|
|
|
|
|
|
public abstract class QSBPatch
|
2020-11-03 21:11:10 +00:00
|
|
|
|
{
|
2022-03-03 03:46:33 +00:00
|
|
|
|
public abstract QSBPatchTypes Type { get; }
|
2021-06-18 20:54:32 +00:00
|
|
|
|
|
2022-03-03 03:46:33 +00:00
|
|
|
|
public void DoPatches(Harmony instance) => instance.PatchAll(GetType());
|
2022-03-22 17:56:41 +00:00
|
|
|
|
|
|
|
|
|
#region remote calls
|
|
|
|
|
|
|
|
|
|
protected static bool Remote { get; private set; }
|
|
|
|
|
protected static object RemoteData { get; private set; }
|
|
|
|
|
|
|
|
|
|
public static void RemoteCall(Action call, object data = null)
|
|
|
|
|
{
|
|
|
|
|
Remote = true;
|
2022-03-23 21:19:54 +00:00
|
|
|
|
RemoteData = data;
|
2022-03-23 20:51:37 +00:00
|
|
|
|
nameof(QSBPatch).Try("doing remote call", call);
|
2022-03-22 17:56:41 +00:00
|
|
|
|
Remote = false;
|
|
|
|
|
RemoteData = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static T RemoteCall<T>(Func<T> call, object data = null)
|
|
|
|
|
{
|
|
|
|
|
Remote = true;
|
2022-03-23 21:19:54 +00:00
|
|
|
|
RemoteData = data;
|
2022-03-23 20:51:37 +00:00
|
|
|
|
var t = default(T);
|
|
|
|
|
nameof(QSBPatch).Try("doing remote call", () => t = call());
|
2022-03-22 17:56:41 +00:00
|
|
|
|
Remote = false;
|
|
|
|
|
RemoteData = null;
|
|
|
|
|
return t;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
}
|