Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of NoCofee ChillaxShop v1.0.2
BepInEx/plugins/ChillaxShop.dll
Decompiled 11 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("ChillaxShop")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ChillaxShop")] [assembly: AssemblyTitle("ChillaxShop")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ChillaxShop { [BepInPlugin("fen.chillaxshop", "Chillax Shop Addon", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { private class Runner : MonoBehaviour { [CompilerGenerated] private sealed class <Loop>d__7 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Runner <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <Loop>d__7(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown int num = <>1__state; Runner runner = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; runner._log.LogInfo((object)"Runner.Loop: start"); break; case 1: <>1__state = -1; try { if (runner._itemsType == null || runner._netPrefType == null) { runner._itemsType = Type.GetType("LethalLib.Modules.Items, LethalLib", throwOnError: false); runner._netPrefType = Type.GetType("LethalLib.Modules.NetworkPrefabs, LethalLib", throwOnError: false); runner._log.LogInfo((object)string.Format("Runner[{0}]: LethalLib.Items {1}, NetworkPrefabs {2}.", runner._attempt, (runner._itemsType != null) ? "найден" : "не найден", (runner._netPrefType != null) ? "найден" : "не найден")); } HashSet<Item> hashSet = new HashSet<Item>(); Item[] array = Resources.FindObjectsOfTypeAll<Item>(); foreach (Item val in array) { if (Object.op_Implicit((Object)(object)val)) { hashSet.Add(val); } } if (hashSet.Count == 0) { runner._log.LogInfo((object)$"Runner[{runner._attempt}]: Items пока 0 — жду дальше…"); break; } int num2 = 0; foreach (Item item in hashSet) { if ((Object)(object)item == (Object)null) { continue; } string text = (item.itemName ?? "").Trim(); if (text.Equals("Uno Reverse Card DX", StringComparison.OrdinalIgnoreCase) || !runner._wanted.TryGetValue(text, out var value)) { continue; } try { if ((Object)(object)item.spawnPrefab != (Object)null && runner._netPrefType != null) { runner._netPrefType.GetMethod("RegisterNetworkPrefab", new Type[1] { typeof(GameObject) })?.Invoke(null, new object[1] { item.spawnPrefab }); } bool flag = false; if (runner._itemsType != null) { flag = TryRegisterShopItemReflective(runner._itemsType, item, value); } if (flag) { runner._log.LogInfo((object)$"Добавлен в магазин: '{item.itemName}' за {value}₵"); num2++; continue; } runner._log.LogWarning((object)("Не удалось добавить '" + item.itemName + "' — LethalLib " + ((runner._itemsType == null) ? "не найден" : "не принял параметры") + ".")); } catch (Exception arg) { runner._log.LogError((object)$"Ошибка при добавлении '{item?.itemName}': {arg}"); } } runner._log.LogInfo((object)$"Runner[{runner._attempt}]: добавлено предметов: {num2}."); runner._done = true; } catch (Exception ex) { runner._log.LogError((object)("Runner fatal: " + ex)); runner._done = true; } break; } if (!runner._done && runner._attempt < 60) { runner._attempt++; runner._log.LogInfo((object)$"Runner[{runner._attempt}]: попытка добавления…"); <>2__current = (object)new WaitForSeconds(1f); <>1__state = 1; return true; } if (!runner._done) { runner._log.LogWarning((object)"Runner: достигнут лимит попыток — ассеты так и не загрузились."); } 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(); } } private ManualLogSource _log; private Dictionary<string, int> _wanted; private bool _done; private int _attempt; private Type _itemsType; private Type _netPrefType; public void Init(ManualLogSource log, Dictionary<string, int> wanted) { _log = log; _wanted = wanted; _log.LogInfo((object)"Runner.Init: стартую цикл добавления товаров…"); ((MonoBehaviour)this).StartCoroutine(Loop()); } [IteratorStateMachine(typeof(<Loop>d__7))] private IEnumerator Loop() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <Loop>d__7(0) { <>4__this = this }; } private static bool TryRegisterShopItemReflective(Type itemsType, Item item, int price) { try { MethodInfo[] array = (from m in itemsType.GetMethods(BindingFlags.Static | BindingFlags.Public) where m.Name == "RegisterShopItem" select m).ToArray(); if (array.Length == 0) { return false; } MethodInfo[] array2 = array; foreach (MethodInfo methodInfo in array2) { ParameterInfo[] parameters = methodInfo.GetParameters(); object[] array3 = new object[parameters.Length]; for (int j = 0; j < parameters.Length; j++) { Type parameterType = parameters[j].ParameterType; if (parameterType == typeof(Item)) { array3[j] = item; } else if (parameterType == typeof(int)) { array3[j] = price; } else if (typeof(TerminalNode).IsAssignableFrom(parameterType)) { array3[j] = null; } else if (parameterType.IsEnum || parameterType.IsValueType) { array3[j] = Activator.CreateInstance(parameterType); } else { array3[j] = null; } } try { methodInfo.Invoke(null, array3); return true; } catch { } } } catch { } return false; } } [CompilerGenerated] private sealed class <ParseNamePriceList>d__9 : IEnumerable<KeyValuePair<string, int>>, IEnumerable, IEnumerator<KeyValuePair<string, int>>, IDisposable, IEnumerator { private int <>1__state; private KeyValuePair<string, int> <>2__current; private int <>l__initialThreadId; private string raw; public string <>3__raw; private string[] <>7__wrap1; private int <>7__wrap2; KeyValuePair<string, int> IEnumerator<KeyValuePair<string, int>>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ParseNamePriceList>d__9(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { <>7__wrap1 = null; <>1__state = -2; } private bool MoveNext() { int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -1; goto IL_00fa; } <>1__state = -1; if (string.IsNullOrWhiteSpace(raw)) { return false; } char[] separator = new char[4] { '\r', '\n', ',', ';' }; <>7__wrap1 = raw.Split(separator, StringSplitOptions.RemoveEmptyEntries); <>7__wrap2 = 0; goto IL_0108; IL_00fa: <>7__wrap2++; goto IL_0108; IL_0108: if (<>7__wrap2 < <>7__wrap1.Length) { string text = <>7__wrap1[<>7__wrap2].Trim(); if (text.Length != 0) { int num2 = text.IndexOf('#'); if (num2 >= 0) { text = text.Substring(0, num2).Trim(); } if (text.Length != 0) { int num3 = text.IndexOf('='); if (num3 > 0) { string text2 = text.Substring(0, num3).Trim(); if (int.TryParse(text.Substring(num3 + 1).Trim(), out var result) && !string.IsNullOrEmpty(text2)) { <>2__current = new KeyValuePair<string, int>(text2, result); <>1__state = 1; return true; } } } } goto IL_00fa; } <>7__wrap1 = null; 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<KeyValuePair<string, int>> IEnumerable<KeyValuePair<string, int>>.GetEnumerator() { <ParseNamePriceList>d__9 <ParseNamePriceList>d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; <ParseNamePriceList>d__ = this; } else { <ParseNamePriceList>d__ = new <ParseNamePriceList>d__9(0); } <ParseNamePriceList>d__.raw = <>3__raw; return <ParseNamePriceList>d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable<KeyValuePair<string, int>>)this).GetEnumerator(); } } public const string PluginGuid = "fen.chillaxshop"; public const string PluginName = "Chillax Shop Addon"; public const string PluginVersion = "1.0.0"; internal static ManualLogSource Log; private readonly Dictionary<string, int> DefaultPrices = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase) { { "Dance Note", 1200 }, { "Uno Reverse Card", 100 }, { "Ocarina", 1000 }, { "Eevee", 500 }, { "Boink", 700 } }; private readonly Dictionary<string, ConfigEntry<int>> PriceEntries = new Dictionary<string, ConfigEntry<int>>(StringComparer.OrdinalIgnoreCase); private ConfigEntry<string> ExtraItemsRaw; private void Awake() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; Log.LogInfo((object)"Chillax Shop Addon v1.0.0 Awake(): плагин загружен."); Dictionary<string, int> wanted = BuildWantedFromConfig(); GameObject val = new GameObject("ChillaxShopRunner"); Object.DontDestroyOnLoad((Object)val); ((Object)val).hideFlags = (HideFlags)61; val.AddComponent<Runner>().Init(Log, wanted); } private Dictionary<string, int> BuildWantedFromConfig() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown foreach (KeyValuePair<string, int> defaultPrice in DefaultPrices) { ConfigEntry<int> value = ((BaseUnityPlugin)this).Config.Bind<int>("Prices", defaultPrice.Key, defaultPrice.Value, new ConfigDescription("Цена в кредах. Поставь 0, чтобы выключить этот предмет.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100000), Array.Empty<object>())); PriceEntries[defaultPrice.Key] = value; } ExtraItemsRaw = ((BaseUnityPlugin)this).Config.Bind<string>("Extra", "Items", "", new ConfigDescription("Дополнительные предметы: одна пара Name=Price на строку. Пример:\nEevee=500\nBoink=700\nUS_Padlock=900", (AcceptableValueBase)null, Array.Empty<object>())); Dictionary<string, int> dictionary = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase); foreach (KeyValuePair<string, ConfigEntry<int>> priceEntry in PriceEntries) { int value2 = priceEntry.Value.Value; if (value2 > 0) { dictionary[priceEntry.Key] = value2; } } foreach (KeyValuePair<string, int> item in ParseNamePriceList(ExtraItemsRaw.Value)) { if (item.Value > 0) { dictionary[item.Key] = item.Value; } else { dictionary.Remove(item.Key); } } Log.LogInfo((object)$"Config: итоговых позиций в магазине = {dictionary.Count}"); return dictionary; } [IteratorStateMachine(typeof(<ParseNamePriceList>d__9))] private static IEnumerable<KeyValuePair<string, int>> ParseNamePriceList(string raw) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ParseNamePriceList>d__9(-2) { <>3__raw = raw }; } } }