diff --git a/CardOnly.csproj b/CardOnly.csproj index 28af8ed..d367503 100644 --- a/CardOnly.csproj +++ b/CardOnly.csproj @@ -4,7 +4,7 @@ netstandard2.1 CardOnly My first plugin - 1.0.0 + 1.1.0 true latest diff --git a/Plugin.cs b/Plugin.cs index 05d4996..b489647 100644 --- a/Plugin.cs +++ b/Plugin.cs @@ -1,18 +1,37 @@ using BepInEx; using HarmonyLib; +using MyBox; +using System; using UnityEngine; namespace CardOnly { [BepInPlugin(PluginInfo.PLUGIN_GUID, PluginInfo.PLUGIN_NAME, PluginInfo.PLUGIN_VERSION)] + [BepInIncompatibility("CashOnly")] 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.CardOnly"); - harmony.PatchAll(); + Logger.LogInfo($"Plugin {PluginInfo.PLUGIN_GUID} is loaded!"); + harmony = new Harmony("com.orpticon.CardOnly"); + } + 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