diff --git a/CashOnly.csproj b/CashOnly.csproj index 0a49224..cc561ab 100644 --- a/CashOnly.csproj +++ b/CashOnly.csproj @@ -4,7 +4,7 @@ netstandard2.1 CashOnly My first plugin - 1.0.0 + 1.1.0 true latest diff --git a/Plugin.cs b/Plugin.cs index 3f47b7e..d7981a9 100644 --- a/Plugin.cs +++ b/Plugin.cs @@ -1,17 +1,35 @@ using BepInEx; using HarmonyLib; +using MyBox; namespace CashOnly { [BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)] + [BepInIncompatibility("CardOnly")] public class Plugin : BaseUnityPlugin { + bool patched = false; + Harmony harmony; private void Awake() { - // Plugin startup logic - Logger.LogInfo($"Plugin {PluginInfo.PLUGIN_GUID} is loaded! Applying patch..."); - Harmony harmony = new Harmony("com.orpticon.CashOnly"); - harmony.PatchAll(); + Logger.LogInfo($"Plugin {PluginInfo.PLUGIN_GUID} is loaded!"); + harmony = new Harmony("com.orpticon.CashOnly"); + } + private void Update() + { + if (Singleton.Instance != null && Singleton.Instance.Completed && !patched) + { + patched = true; + Logger.LogInfo("Patching..."); + // Plugin startup logic + harmony.PatchAll(); + } + if (Singleton.Instance != null && !Singleton.Instance.Completed && patched) + { + patched = false; + Logger.LogInfo("Unpatching..."); + harmony.UnpatchSelf(); + } } } public static class PaymentFixerPatch