-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHarmonyPatcher.cs
35 lines (28 loc) · 1.06 KB
/
HarmonyPatcher.cs
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
29
30
31
32
33
34
35
using HarmonyLib;
using System.Reflection;
namespace SALT
{
public static class HarmonyPatcher
{
private static Harmony _instance;
internal static Harmony Instance
{
get
{
if (HarmonyPatcher._instance == null)
HarmonyPatcher.InitializeInstance();
return HarmonyPatcher._instance;
}
}
private static void InitializeInstance() => HarmonyPatcher._instance = new Harmony("net.megapiggy.SALT");
internal static void PatchAll() => HarmonyPatcher.Instance.PatchAll(Assembly.GetExecutingAssembly());
public static Harmony SetInstance(string name)
{
Mod currentMod = Mod.GetCurrentMod();
currentMod.CreateHarmonyInstance(name);
return currentMod.HarmonyInstance;
}
public static Harmony GetInstance() => Mod.GetCurrentMod().HarmonyInstance;
public static Harmony GetInstance(Assembly assembly) => ModLoader.GetModForAssembly(assembly).HarmonyInstance;
}
}