1
0
mirror of https://github.com/misternebula/quantum-space-buddies.git synced 2025-02-21 18:40:03 +00:00

40 lines
826 B
C#
Raw Normal View History

using HarmonyLib;
using QSB.Utility;
2022-03-22 10:56:41 -07:00
using System;
2021-06-18 21:54:32 +01:00
2022-03-02 19:46:33 -08:00
namespace QSB.Patches;
public abstract class QSBPatch
2020-11-03 21:11:10 +00:00
{
2022-03-02 19:46:33 -08:00
public abstract QSBPatchTypes Type { get; }
2021-06-18 21:54:32 +01:00
2022-03-02 19:46:33 -08:00
public void DoPatches(Harmony instance) => instance.PatchAll(GetType());
2022-03-22 10:56:41 -07: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;
RemoteData = data;
nameof(QSBPatch).Try("doing remote call", call);
2022-03-22 10:56:41 -07:00
Remote = false;
RemoteData = null;
}
public static T RemoteCall<T>(Func<T> call, object data = null)
{
Remote = true;
RemoteData = data;
var t = default(T);
nameof(QSBPatch).Try("doing remote call", () => t = call());
2022-03-22 10:56:41 -07:00
Remote = false;
RemoteData = null;
return t;
}
#endregion
}