using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem.Collections.Generic; using Mirror; using OneClickCheckout.Localization; using UnityEngine; using UnityEngine.Localization.Settings; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("OneClickCheckout")] [assembly: AssemblyDescription("One Click Checkout mod for Island Market Simulator by Ice Box Studio")] [assembly: AssemblyCompany("Ice Box Studio")] [assembly: AssemblyProduct("OneClickCheckout")] [assembly: AssemblyCopyright("Copyright © 2026 Ice Box Studio All rights reserved.")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("6346E2B9-86AF-44AA-8201-FB1D3B77669A")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyVersion("1.0.0.0")] namespace OneClickCheckout { [BepInPlugin("IceBoxStudio.IslandMarketSimulator.OneClickCheckout", "OneClickCheckout", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class OneClickCheckout : BasePlugin { public static OneClickCheckout _Instance; private const string ModConfigManagerApiTypeName = "ModConfigManager.Api.ModConfigManagerAPI"; private const string ModConfigManagerRegisterMethodName = "RegisterPluginInfo"; private Harmony _harmony; private bool patchesApplied; public static OneClickCheckout Instance => _Instance; internal static ManualLogSource Logger { get; private set; } public override void Load() { //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown _Instance = this; Logger = ((BasePlugin)this).Log; bool flag = default(bool); try { Logger.LogInfo((object)"============================================="); ManualLogSource logger = Logger; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(1, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("OneClickCheckout"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(LocalizationManager.Instance.GetLocalizedText("plugin.initializing")); } logger.LogInfo(val); ManualLogSource logger2 = Logger; val = new BepInExInfoLogInterpolatedStringHandler(54, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(LocalizationManager.Instance.GetLocalizedText("plugin.author_prefix")); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Ice Box Studio(https://steamcommunity.com/id/ibox666/)"); } logger2.LogInfo(val); RegisterToModConfigManager(); ApplyPatches(); ManualLogSource logger3 = Logger; val = new BepInExInfoLogInterpolatedStringHandler(1, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("OneClickCheckout"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(LocalizationManager.Instance.GetLocalizedText("plugin.initialized")); } logger3.LogInfo(val); Logger.LogInfo((object)"============================================="); } catch (Exception ex) { ManualLogSource logger4 = Logger; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(9, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted("OneClickCheckout"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" 初始化错误: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("\n"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.StackTrace); } logger4.LogError(val2); } } private void ApplyPatches() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown if (!patchesApplied) { try { _harmony = new Harmony("IceBoxStudio.IslandMarketSimulator.OneClickCheckout"); _harmony.PatchAll(); patchesApplied = true; return; } catch (Exception ex) { ManualLogSource logger = Logger; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(10, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("OneClickCheckout"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" 应用补丁错误: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\n"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.StackTrace); } logger.LogError(val); return; } } Logger.LogInfo((object)LocalizationManager.Instance.GetLocalizedText("plugin.patches_skipped")); } private void RegisterToModConfigManager() { Type type = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly assembly) => assembly.GetType("ModConfigManager.Api.ModConfigManagerAPI") != null)?.GetType("ModConfigManager.Api.ModConfigManagerAPI"); if (!(type == null)) { MethodInfo method = type.GetMethod("RegisterPluginInfo", BindingFlags.Static | BindingFlags.Public); if (!(method == null)) { method.Invoke(null, new object[5] { "IceBoxStudio.IslandMarketSimulator.OneClickCheckout", LocalizationManager.Instance.GetLocalizedText("plugin.name"), "1.0.0", "Ice Box Studio", LocalizationManager.Instance.GetLocalizedText("plugin.description") }); } } } } public static class PluginInfo { public const string PLUGIN_GUID = "IceBoxStudio.IslandMarketSimulator.OneClickCheckout"; public const string PLUGIN_NAME = "OneClickCheckout"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace OneClickCheckout.Patches { [HarmonyPatch] public class CashRegisterPatch { [CompilerGenerated] private sealed class d__0 : IEnumerable, IEnumerable, IEnumerator, IEnumerator, IDisposable { private int <>1__state; private MethodBase <>2__current; private int <>l__initialThreadId; private Type 5__2; MethodBase IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__0(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { 5__2 = null; <>1__state = -2; } private bool MoveNext() { MethodInfo methodInfo2; switch (<>1__state) { default: return false; case 0: { <>1__state = -1; 5__2 = typeof(CashRegister); MethodInfo methodInfo = AccessTools.Method(5__2, "UserCode_RpcShowBag__Int32", new Type[1] { typeof(int) }, (Type[])null); if (methodInfo != null) { <>2__current = methodInfo; <>1__state = 1; return true; } goto IL_0077; } case 1: <>1__state = -1; goto IL_0077; case 2: { <>1__state = -1; break; } IL_0077: methodInfo2 = AccessTools.Method(5__2, "RpcShowBag", new Type[1] { typeof(int) }, (Type[])null); if (methodInfo2 != null) { <>2__current = methodInfo2; <>1__state = 2; return true; } break; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; return this; } return new d__0(0); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } [IteratorStateMachine(typeof(d__0))] [HarmonyTargetMethods] public static IEnumerable TargetMethods() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__0(-2); } [HarmonyPostfix] public static void RpcShowBagPostfix(CashRegister __instance, int amount, MethodBase __originalMethod) { if (amount > 0 && (!(__originalMethod != null) || !(__originalMethod.Name == "RpcShowBag") || !(AccessTools.Method(typeof(CashRegister), "UserCode_RpcShowBag__Int32", new Type[1] { typeof(int) }, (Type[])null) != null))) { TryInteractBag(__instance); } } private static void TryInteractBag(CashRegister cashRegister) { if ((Object)(object)cashRegister.bagItem != (Object)null && ((Component)cashRegister.bagItem).gameObject.activeInHierarchy) { cashRegister.bagItem.Interact(); } } } [HarmonyPatch(typeof(ProductInContainer), "Interact")] public class ProductInContainerPatch { private static int _skipPrefixDepth; [HarmonyPrefix] public static bool Prefix(ProductInContainer __instance) { if (_skipPrefixDepth > 0) { return true; } CashRegister componentInParent = ((Component)__instance).GetComponentInParent(); if ((Object)(object)componentInParent == (Object)null) { return true; } ProductInContainer[] array = Il2CppArrayBase.op_Implicit(((Component)componentInParent).GetComponentsInChildren()); if (array == null || array.Length <= 1) { return true; } bool flag = false; _skipPrefixDepth++; foreach (ProductInContainer val in array) { if ((Object)(object)val != (Object)null) { val.CmdInteract((NetworkConnectionToClient)null); flag = true; } } _skipPrefixDepth--; return !flag; } } [HarmonyPatch(typeof(CashRegister), "RemoveProduct")] public class ApprenticeCashierRemovePatch { private static bool _isProcessing; [HarmonyPrefix] public static void Prefix(CashRegister __instance, GameObject product) { if (_isProcessing || (Object)(object)__instance == (Object)null || __instance.currentProductsOnRegister == null || __instance.currentProductsOnRegister.Count <= 1) { return; } _isProcessing = true; List currentProductsOnRegister = __instance.currentProductsOnRegister; for (int num = currentProductsOnRegister.Count - 1; num >= 0; num--) { GameObject val = currentProductsOnRegister[num]; if ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)product) { __instance.RemoveProduct(val); } } _isProcessing = false; } } } namespace OneClickCheckout.Localization { public static class LocalizationHelper { public static Dictionary GetDefaultTranslations(string language) { Dictionary dictionary = new Dictionary(); switch (language) { case "zh": dictionary.Add("plugin.initializing", "开始初始化..."); dictionary.Add("plugin.author_prefix", "作者:"); dictionary.Add("plugin.initialized", "初始化成功!"); dictionary.Add("plugin.patches_skipped", "补丁已应用,跳过..."); dictionary.Add("plugin.name", "一键结账"); dictionary.Add("plugin.description", "只需单击一次即可完成结账!学徒也可以一键结账。"); break; case "zh-TW": dictionary.Add("plugin.initializing", "開始初始化..."); dictionary.Add("plugin.author_prefix", "作者:"); dictionary.Add("plugin.initialized", "初始化成功!"); dictionary.Add("plugin.patches_skipped", "補丁已套用,跳過..."); dictionary.Add("plugin.name", "一鍵結帳"); dictionary.Add("plugin.description", "只需按一下即可完成結帳!學徒也可以一鍵結帳。"); break; case "en": dictionary.Add("plugin.initializing", "Initializing..."); dictionary.Add("plugin.author_prefix", "Author: "); dictionary.Add("plugin.initialized", "Initialized successfully!"); dictionary.Add("plugin.patches_skipped", "Patches already applied, skipping..."); dictionary.Add("plugin.name", "One Click Checkout"); dictionary.Add("plugin.description", "Complete checkout with just one click! Apprentices can also checkout with one click."); break; case "ja": dictionary.Add("plugin.initializing", "初期化中..."); dictionary.Add("plugin.author_prefix", "作者: "); dictionary.Add("plugin.initialized", "初期化に成功しました!"); dictionary.Add("plugin.patches_skipped", "パッチは適用済みです。スキップします..."); dictionary.Add("plugin.name", "ワンクリック会計"); dictionary.Add("plugin.description", "ワンクリックで会計を完了!見習いもワンクリックで会計できます。"); break; case "tr": dictionary.Add("plugin.initializing", "Başlatılıyor..."); dictionary.Add("plugin.author_prefix", "Yazar: "); dictionary.Add("plugin.initialized", "Başarıyla başlatıldı!"); dictionary.Add("plugin.patches_skipped", "Yamalar zaten uygulandı, atlanıyor..."); dictionary.Add("plugin.name", "Tek Tıkla Ödeme"); dictionary.Add("plugin.description", "Sadece tek bir tıklama ile ödemeyi tamamlayın! Çıraklar da tek tıkla ödeme yapabilir."); break; case "fr": dictionary.Add("plugin.initializing", "Initialisation..."); dictionary.Add("plugin.author_prefix", "Auteur : "); dictionary.Add("plugin.initialized", "Initialisation réussie !"); dictionary.Add("plugin.patches_skipped", "Correctifs déjà appliqués, passage..."); dictionary.Add("plugin.name", "Paiement en un Clic"); dictionary.Add("plugin.description", "Terminez le paiement en un seul clic ! Les apprentis peuvent également payer en un clic."); break; case "es": dictionary.Add("plugin.initializing", "Inicializando..."); dictionary.Add("plugin.author_prefix", "Autor: "); dictionary.Add("plugin.initialized", "¡Inicializado con éxito!"); dictionary.Add("plugin.patches_skipped", "Parches ya aplicados, omitiendo..."); dictionary.Add("plugin.name", "Pago en un Clic"); dictionary.Add("plugin.description", "¡Complete el pago con solo un clic! Los aprendices también pueden cobrar con un clic."); break; case "de": dictionary.Add("plugin.initializing", "Initialisierung..."); dictionary.Add("plugin.author_prefix", "Autor: "); dictionary.Add("plugin.initialized", "Erfolgreich initialisiert!"); dictionary.Add("plugin.patches_skipped", "Patches bereits angewendet, überspringen..."); dictionary.Add("plugin.name", "Ein-Klick-Kasse"); dictionary.Add("plugin.description", "Schließen Sie den Kassiervorgang mit nur einem Klick ab! Lehrlinge können ebenfalls mit einem Klick kassieren."); break; case "el": dictionary.Add("plugin.initializing", "Αρχικοποίηση..."); dictionary.Add("plugin.author_prefix", "Δημιουργός: "); dictionary.Add("plugin.initialized", "Επιτυχής αρχικοποίηση!"); dictionary.Add("plugin.patches_skipped", "Οι διορθώσεις έχουν ήδη εφαρμοστεί, παράβλεψη..."); dictionary.Add("plugin.name", "Ταμείο με Ένα Κλικ"); dictionary.Add("plugin.description", "Ολοκληρώστε το ταμείο με ένα μόνο κλικ! Οι μαθητευόμενοι μπορούν επίσης να κάνουν ταμείο με ένα κλικ."); break; case "pt-BR": dictionary.Add("plugin.initializing", "Inicializando..."); dictionary.Add("plugin.author_prefix", "Autor: "); dictionary.Add("plugin.initialized", "Inicializado com sucesso!"); dictionary.Add("plugin.patches_skipped", "Patches já aplicados, ignorando..."); dictionary.Add("plugin.name", "Pagamento com Um Clique"); dictionary.Add("plugin.description", "Conclua o pagamento com apenas um clique! Os aprendizes também podem pagar com um clique."); break; case "it": dictionary.Add("plugin.initializing", "Inizializzazione..."); dictionary.Add("plugin.author_prefix", "Autore: "); dictionary.Add("plugin.initialized", "Inizializzato con successo!"); dictionary.Add("plugin.patches_skipped", "Patch già applicate, salto..."); dictionary.Add("plugin.name", "Pagamento in un Clic"); dictionary.Add("plugin.description", "Completa il pagamento con un solo clic! Anche gli apprendisti possono incassare con un clic."); break; case "pl": dictionary.Add("plugin.initializing", "Inicjowanie..."); dictionary.Add("plugin.author_prefix", "Autor: "); dictionary.Add("plugin.initialized", "Pomyślnie zainicjowano!"); dictionary.Add("plugin.patches_skipped", "Poprawki już zastosowane, pomijanie..."); dictionary.Add("plugin.name", "Płatność Jednym Kliknięciem"); dictionary.Add("plugin.description", "Zakończ płatność jednym kliknięciem! Praktykanci również mogą obsługiwać kasę jednym kliknięciem."); break; case "pt-PT": dictionary.Add("plugin.initializing", "A inicializar..."); dictionary.Add("plugin.author_prefix", "Autor: "); dictionary.Add("plugin.initialized", "Inicializado com sucesso!"); dictionary.Add("plugin.patches_skipped", "Correções já aplicadas, a ignorar..."); dictionary.Add("plugin.name", "Pagamento Num Clique"); dictionary.Add("plugin.description", "Conclua o pagamento com apenas um clique! Os aprendizes também podem fazer pagamentos com um clique."); break; case "ru": dictionary.Add("plugin.initializing", "Инициализация..."); dictionary.Add("plugin.author_prefix", "Автор: "); dictionary.Add("plugin.initialized", "Успешно инициализировано!"); dictionary.Add("plugin.patches_skipped", "Патчи уже применены, пропуск..."); dictionary.Add("plugin.name", "Оплата в Один Клик"); dictionary.Add("plugin.description", "Завершите оплату всего одним кликом! Ученики также могут рассчитывать покупателей в один клик."); break; case "ko": dictionary.Add("plugin.initializing", "초기화 중..."); dictionary.Add("plugin.author_prefix", "제작자: "); dictionary.Add("plugin.initialized", "초기화 성공!"); dictionary.Add("plugin.patches_skipped", "패치가 이미 적용되었습니다. 건너뜁니다..."); dictionary.Add("plugin.name", "원클릭 결제"); dictionary.Add("plugin.description", "단 한 번의 클릭으로 결제를 완료하세요! 견습생도 원클릭으로 결제할 수 있습니다."); break; case "th": dictionary.Add("plugin.initializing", "กำล\u0e31งเร\u0e34\u0e48มต\u0e49น..."); dictionary.Add("plugin.author_prefix", "ผ\u0e39\u0e49สร\u0e49าง: "); dictionary.Add("plugin.initialized", "เร\u0e34\u0e48มต\u0e49นสำเร\u0e47จ!"); dictionary.Add("plugin.patches_skipped", "ใช\u0e49งานแพตช\u0e4cแล\u0e49ว ข\u0e49าม..."); dictionary.Add("plugin.name", "ชำระเง\u0e34นในคล\u0e34กเด\u0e35ยว"); dictionary.Add("plugin.description", "ชำระเง\u0e34นเสร\u0e47จส\u0e34\u0e49นด\u0e49วยการคล\u0e34กเพ\u0e35ยงคร\u0e31\u0e49งเด\u0e35ยว! เด\u0e47กฝ\u0e36กงานก\u0e47สามารถค\u0e34ดเง\u0e34นได\u0e49ด\u0e49วยคล\u0e34กเด\u0e35ยวเช\u0e48นก\u0e31น"); break; } return dictionary; } } public class LocalizationManager { private static LocalizationManager _instance; private readonly Dictionary> _localizations = new Dictionary>(); private string _currentLocale = "zh"; public static readonly string[] SupportedLanguages = new string[16] { "en", "tr", "fr", "es", "zh", "zh-TW", "de", "el", "pt-BR", "it", "ja", "pl", "pt-PT", "ru", "ko", "th" }; public static LocalizationManager Instance => _instance ?? (_instance = new LocalizationManager()); private LocalizationManager() { Initialize(); } public void Initialize() { RefreshCurrentLocale(); string[] supportedLanguages = SupportedLanguages; foreach (string text in supportedLanguages) { Dictionary defaultTranslations = LocalizationHelper.GetDefaultTranslations(text); if (defaultTranslations != null && defaultTranslations.Count > 0) { _localizations[text] = defaultTranslations; } } } private void RefreshCurrentLocale() { if (PlayerPrefs.HasKey("Lang")) { int @int = PlayerPrefs.GetInt("Lang"); ILocalesProvider availableLocales = LocalizationSettings.AvailableLocales; if (availableLocales != null && availableLocales.Locales != null && @int >= 0 && @int < availableLocales.Locales.Count) { string code = availableLocales.Locales[@int].Identifier.Code; _currentLocale = (_localizations.ContainsKey(code) ? code : "en"); } } } public string GetLocalizedText(string key, params object[] args) { RefreshCurrentLocale(); if (string.IsNullOrEmpty(_currentLocale) || !_localizations.ContainsKey(_currentLocale)) { _currentLocale = "en"; } if (_localizations.ContainsKey(_currentLocale) && _localizations[_currentLocale].TryGetValue(key, out var value)) { if (args.Length == 0) { return value; } return string.Format(value, args); } if (_currentLocale != "en" && _localizations.ContainsKey("en") && _localizations["en"].TryGetValue(key, out var value2)) { if (args.Length == 0) { return value2; } return string.Format(value2, args); } if (_localizations.ContainsKey("zh") && _localizations["zh"].TryGetValue(key, out var value3)) { if (args.Length == 0) { return value3; } return string.Format(value3, args); } return key; } } }