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 WoodMerchants v0.1.1
WoodMerchants.dll
Decompiled 20 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("MaderasMercaderes")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("MaderasMercaderes")] [assembly: AssemblyTitle("MaderasMercaderes")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 MaderasMercaderes { [BepInPlugin("com.tuusuario.maderasmercaderes", "MaderasMercaderes", "0.1.0")] public class MaderasMercaderesPlugin : BaseUnityPlugin { public const string PluginGuid = "com.tuusuario.maderasmercaderes"; public const string PluginName = "MaderasMercaderes"; public const string PluginVersion = "0.1.0"; internal static MaderasMercaderesPlugin Instance; private Harmony _harmony; internal static readonly List<WoodOffer> Offers = new List<WoodOffer>(); private void Awake() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown Instance = this; ConfigureOffers(); _harmony = new Harmony("com.tuusuario.maderasmercaderes"); _harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"MaderasMercaderes cargado. Las ofertas se agregan al inventario de los mercaderes cuando la API del juego las expone."); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void ConfigureOffers() { AddOffer("Wood", "Madera común", 10, 20); AddOffer("FineWood", "Madera noble", 20, 10); AddOffer("RoundLog", "Madera maciza", 20, 10); AddOffer("AncientBark", "Corteza antigua", 25, 10); AddOffer("YggdrasilWood", "Madera de Yggdrasil", 30, 10); } private void AddOffer(string prefab, string displayName, int defaultPrice, int defaultStack) { ConfigEntry<bool> enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Ofertas", prefab + "_Activar", true, "Permite comprar este tipo de madera."); ConfigEntry<int> price = ((BaseUnityPlugin)this).Config.Bind<int>("Ofertas", prefab + "_Precio", defaultPrice, "Precio en monedas por paquete. Debe ser mayor que cero."); ConfigEntry<int> stack = ((BaseUnityPlugin)this).Config.Bind<int>("Ofertas", prefab + "_Cantidad", defaultStack, "Unidades de madera que recibís por compra."); Offers.Add(new WoodOffer(prefab, displayName, enabled, price, stack)); } } internal sealed class WoodOffer { internal readonly string Prefab; internal readonly string DisplayName; internal readonly ConfigEntry<bool> Enabled; internal readonly ConfigEntry<int> Price; internal readonly ConfigEntry<int> Stack; internal WoodOffer(string prefab, string displayName, ConfigEntry<bool> enabled, ConfigEntry<int> price, ConfigEntry<int> stack) { Prefab = prefab; DisplayName = displayName; Enabled = enabled; Price = price; Stack = stack; } } [HarmonyPatch(typeof(Trader), "GetAvailableItems")] internal static class Trader_GetAvailableItems_Patch { private static void Postfix(Trader __instance, ref List<TradeItem> __result) { //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Expected O, but got Unknown if ((Object)(object)__instance == (Object)null || __result == null) { return; } string obj = (((Object)(object)((Component)__instance).gameObject != (Object)null) ? ((Object)((Component)__instance).gameObject).name.ToLowerInvariant() : string.Empty); bool flag = obj.Contains("haldor"); bool flag2 = obj.Contains("hildir"); if (!flag && !flag2) { return; } foreach (WoodOffer offer in MaderasMercaderesPlugin.Offers) { if (!offer.Enabled.Value) { continue; } int price = Math.Max(1, offer.Price.Value); int stack = Math.Max(1, offer.Stack.Value); GameObject val = (((Object)(object)ObjectDB.instance != (Object)null) ? ObjectDB.instance.GetItemPrefab(offer.Prefab) : null); if (!((Object)(object)val == (Object)null)) { ItemDrop itemDrop = val.GetComponent<ItemDrop>(); if (!((Object)(object)itemDrop == (Object)null) && !__result.Exists((TradeItem item) => item != null && (Object)(object)item.m_prefab == (Object)(object)itemDrop)) { __result.Add(new TradeItem { m_prefab = itemDrop, m_price = price, m_stack = stack }); } } } } } [HarmonyPatch(typeof(StoreGui), "GetSelectedItemIndex")] internal static class StoreGui_GetSelectedItemIndex_Patch { private static bool Prefix(StoreGui __instance, ref int __result) { try { if ((Object)(object)__instance == (Object)null) { return true; } Trader value = Traverse.Create((object)__instance).Field("m_trader").GetValue<Trader>(); TradeItem selected = Traverse.Create((object)__instance).Field("m_selectedItem").GetValue<TradeItem>(); if ((Object)(object)value == (Object)null || selected == null || (Object)(object)selected.m_prefab == (Object)null) { return true; } List<TradeItem> availableItems = value.GetAvailableItems(); if (availableItems == null) { return true; } int num = availableItems.FindIndex((TradeItem item) => item != null && (Object)(object)item.m_prefab == (Object)(object)selected.m_prefab && item.m_stack == selected.m_stack); if (num < 0) { num = availableItems.FindIndex((TradeItem item) => item != null && (Object)(object)item.m_prefab == (Object)(object)selected.m_prefab); } if (num < 0) { return true; } __result = num; return false; } catch { return true; } } } }