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 BuyableExtractors v1.0.1
BepInEx/plugins/BuyableExtractors/BuyableExtractors.dll
Decompiled 2 weeks agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("0.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace BuyableExtractors { [BepInPlugin("com.zmods.buyableextractors", "BuyableExtractors", "1.0.1")] public sealed class BuyableExtractorsPlugin : BaseUnityPlugin { public const string PluginGuid = "com.zmods.buyableextractors"; public const string PluginName = "BuyableExtractors"; public const string PluginVersion = "1.0.1"; internal const string ExtractorPrefabName = "DvergrNeedle"; internal static ManualLogSource Log; internal static BuyableExtractorsSettings Settings; private Harmony harmony; internal static string UnlockKey { get { if (!string.Equals(Settings.UnlockAfterBoss.Value, "Queen", StringComparison.OrdinalIgnoreCase)) { return "defeated_goblinking"; } return "defeated_queen"; } } private void Awake() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Settings = new BuyableExtractorsSettings(((BaseUnityPlugin)this).Config); harmony = new Harmony("com.zmods.buyableextractors"); harmony.PatchAll(typeof(BuyableExtractorsPlugin).Assembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)"BuyableExtractors 1.0.1 loaded."); } private void OnDestroy() { Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } internal static void AddOffer(Trader trader) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Expected O, but got Unknown if (IsHaldor(trader) && trader.m_items != null && !HasExtractorOffer(trader)) { ObjectDB instance = ObjectDB.instance; GameObject val = ((instance != null) ? instance.GetItemPrefab("DvergrNeedle") : null); ItemDrop val2 = (((Object)(object)val == (Object)null) ? null : val.GetComponent<ItemDrop>()); if ((Object)(object)val2 == (Object)null) { Log.LogWarning((object)"Could not find the vanilla Dvergr Extractor prefab DvergrNeedle."); return; } trader.m_items.Add(new TradeItem { m_prefab = val2, m_stack = 1, m_price = Math.Max(1, Settings.ExtractorPrice.Value), m_requiredGlobalKey = UnlockKey, m_name = val2.m_itemData.m_shared.m_name, m_tooltip = "Looks like a perfect piece for piercing something..." }); } } private static bool IsHaldor(Trader trader) { string name = ((Object)((Component)trader).gameObject).name; if (!(name == "Haldor") && !name.StartsWith("Haldor(", StringComparison.Ordinal)) { return string.Equals(trader.m_name, "Haldor", StringComparison.OrdinalIgnoreCase); } return true; } private static bool HasExtractorOffer(Trader trader) { foreach (TradeItem item in trader.m_items) { if ((Object)(object)item?.m_prefab != (Object)null && ((Object)((Component)item.m_prefab).gameObject).name == "DvergrNeedle") { return true; } } return false; } } [HarmonyPatch(typeof(Trader), "Start")] internal static class TraderStartPatch { private static void Postfix(Trader __instance) { BuyableExtractorsPlugin.AddOffer(__instance); } } public sealed class BuyableExtractorsSettings { public readonly ConfigEntry<int> ExtractorPrice; public readonly ConfigEntry<string> UnlockAfterBoss; public BuyableExtractorsSettings(ConfigFile config) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown ExtractorPrice = config.Bind<int>("Trade", "ExtractorPrice", 1500, new ConfigDescription("Gold coins required for one Dvergr Extractor.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 9999999), Array.Empty<object>())); UnlockAfterBoss = config.Bind<string>("Trade", "UnlockAfterBoss", "Yagluth", new ConfigDescription("Boss whose defeat unlocks the Haldor offer. Choose Yagluth or Queen.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[2] { "Yagluth", "Queen" }), Array.Empty<object>())); } } }