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 AutoShield v1.0.0
BepInEx/plugins/AutoShield.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 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: AssemblyCompany("AutoShield")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Valheim mod: auto-equips your shield when you equip a one-handed weapon.")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("AutoShield")] [assembly: AssemblyTitle("AutoShield")] [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 AutoShield { [BepInPlugin("snep.valheim.autoshield", "AutoShield", "1.0.0")] public class AutoShieldPlugin : BaseUnityPlugin { public const string PluginGuid = "snep.valheim.autoshield"; public const string PluginName = "AutoShield"; public const string PluginVersion = "1.0.0"; public static ConfigEntry<bool> Enabled; internal static string LastShieldName; private Harmony _harmony; private void Awake() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "When enabled, equipping a one-handed weapon will automatically re-equip your last shield."); _harmony = new Harmony("snep.valheim.autoshield"); _harmony.PatchAll(); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } [HarmonyPatch(typeof(Humanoid), "EquipItem")] internal static class EquipPatch { private static void Postfix(Humanoid __instance, ItemData item, bool __result) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Invalid comparison between Unknown and I4 //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Invalid comparison between Unknown and I4 if (!__result || !AutoShieldPlugin.Enabled.Value) { return; } Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val == null || (Object)(object)val != (Object)(object)Player.m_localPlayer) { return; } if ((int)item.m_shared.m_itemType == 5) { AutoShieldPlugin.LastShieldName = item.m_shared.m_name; } else { if ((int)item.m_shared.m_itemType != 3 || ((Humanoid)val).LeftItem != null || string.IsNullOrEmpty(AutoShieldPlugin.LastShieldName)) { return; } foreach (ItemData allItem in ((Humanoid)val).GetInventory().GetAllItems()) { if ((int)allItem.m_shared.m_itemType == 5 && allItem.m_shared.m_name == AutoShieldPlugin.LastShieldName) { ((Humanoid)val).EquipItem(allItem, true); break; } } } } } }