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 EarlyHaldorPockets v1.0.0
EarlyHaldorPockets.dll
Decompiled a month 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.1", FrameworkDisplayName = ".NET Framework 4.8.1")] [assembly: AssemblyCompany("EarlyHaldorPockets")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("EarlyHaldorPockets")] [assembly: AssemblyTitle("EarlyHaldorPockets")] [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.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; } } [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 EarlyHaldorPockets { [BepInPlugin("chooweey.valheim.earlyhaldorockets", "Early Haldor Pockets", "1.0.0")] public sealed class Plugin : BaseUnityPlugin { public const string PluginGuid = "chooweey.valheim.earlyhaldorockets"; public const string PluginName = "Early Haldor Pockets"; public const string PluginVersion = "1.0.0"; internal static ManualLogSource Log; internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<string> WiderRequiredKey; internal static ConfigEntry<string> DeeperRequiredKey; private Harmony? _harmony; private void Awake() { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable the mod."); WiderRequiredKey = ((BaseUnityPlugin)this).Config.Bind<string>("Pocket Progression", "WiderPocketsRequiredKey", "defeated_eikthyr", "Required global key for Wider Pockets. Blank = no boss gate."); DeeperRequiredKey = ((BaseUnityPlugin)this).Config.Bind<string>("Pocket Progression", "DeeperPocketsRequiredKey", "defeated_gdking", "Required global key for Deeper Pockets. Blank = no boss gate."); _harmony = new Harmony("chooweey.valheim.earlyhaldorockets"); _harmony.PatchAll(Assembly.GetExecutingAssembly()); Log.LogInfo((object)"Early Haldor Pockets 1.0.0 loaded."); } private void OnDestroy() { Harmony? harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } internal static void ApplyPocketRequirements(Trader trader) { if (!Enabled.Value || (Object)(object)trader == (Object)null || trader.m_items == null) { return; } int num = 0; foreach (TradeItem item in trader.m_items) { if (item == null) { continue; } if (ContainsToken(item, "hud_extrainvslot1")) { string text = Normalize(WiderRequiredKey.Value); if (!string.Equals(item.m_requiredGlobalKey ?? string.Empty, text, StringComparison.Ordinal)) { item.m_requiredGlobalKey = text; num++; } } else if (ContainsToken(item, "hud_extrainvslot2")) { string text2 = Normalize(DeeperRequiredKey.Value); if (!string.Equals(item.m_requiredGlobalKey ?? string.Empty, text2, StringComparison.Ordinal)) { item.m_requiredGlobalKey = text2; num++; } } } if (num > 0) { Log.LogInfo((object)$"Adjusted {num} Haldor pocket upgrade requirement(s)."); } } private static bool ContainsToken(TradeItem item, string token) { FieldInfo[] fields = typeof(TradeItem).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { if (!(fieldInfo.FieldType != typeof(string)) && ((fieldInfo.GetValue(item) as string) ?? string.Empty).IndexOf(token, StringComparison.OrdinalIgnoreCase) >= 0) { return true; } } return false; } private static string Normalize(string? value) { return (value ?? string.Empty).Trim(); } } [HarmonyPatch(typeof(Trader), "GetAvailableItems")] internal static class TraderGetAvailableItemsPatch { private static void Prefix(Trader __instance) { Plugin.ApplyPocketRequirements(__instance); } } }