Please disclose if your mod was created primarily 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 ComfyAutoPicker v1.3.1
ComfyAutoPicker.dll
Decompiled 2 years agousing System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("ComfyAutoPicker")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ComfyAutoPicker")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("c912b20f-2bfa-439d-ab23-9a07f0f9ee70")] [assembly: AssemblyFileVersion("1.3.1")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.1.0")] [module: UnverifiableCode] namespace ComfyAutoPicker; [BepInPlugin("EardwulfDoesMods.valheim.ComfyAutoPicker", "ComfyAutoPicker", "1.3.1")] public class Mod : BaseUnityPlugin { public const string PluginGuid = "EardwulfDoesMods.valheim.ComfyAutoPicker"; public const string PluginName = "ComfyAutoPicker"; public const string PluginVersion = "1.3.1"; public static readonly HashSet<int> PlantsToAutoPick = new HashSet<int> { StringExtensionMethods.GetStableHashCode("CloudberryBush"), StringExtensionMethods.GetStableHashCode("Pickable_Barley"), StringExtensionMethods.GetStableHashCode("Pickable_Barley_Wild"), StringExtensionMethods.GetStableHashCode("Pickable_Flax"), StringExtensionMethods.GetStableHashCode("Pickable_Flax_Wild"), StringExtensionMethods.GetStableHashCode("Pickable_Carrot"), StringExtensionMethods.GetStableHashCode("Pickable_SeedCarrot"), StringExtensionMethods.GetStableHashCode("Pickable_Turnip"), StringExtensionMethods.GetStableHashCode("Pickable_SeedTurnip"), StringExtensionMethods.GetStableHashCode("Pickable_Onion"), StringExtensionMethods.GetStableHashCode("Pickable_SeedOnion"), StringExtensionMethods.GetStableHashCode("Pickable_Mushroom_JotunPuffs"), StringExtensionMethods.GetStableHashCode("Pickable_Mushroom_Magecap"), "VineAsh".GetHashCode() }; private Harmony _harmony; private void Awake() { PluginConfig.BindConfig(((BaseUnityPlugin)this).Config); _harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "EardwulfDoesMods.valheim.ComfyAutoPicker"); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } } public sealed class AutoPicker : MonoBehaviour { private Pickable _pickable; private void Awake() { _pickable = ((Component)this).GetComponent<Pickable>(); if (PluginConfig.IsModEnabled.Value) { ((MonoBehaviour)this).InvokeRepeating("CheckAndPick", 1f, 0.425f); } } public void CheckAndPick() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) if (!PluginConfig.IsModEnabled.Value || !Object.op_Implicit((Object)(object)Player.m_localPlayer) || Vector3.Distance(((Component)this).transform.position, ((Component)Player.m_localPlayer).transform.position) > 0.875f) { return; } if (!PrivateArea.CheckAccess(((Component)this).transform.position, 0f, true, false)) { ((Terminal)Chat.m_instance).AddString("You are not on the ward for this area."); return; } ItemData rightItem = ((Humanoid)Player.m_localPlayer).m_rightItem; if (((rightItem != null) ? ((Object)rightItem.m_dropPrefab).name : null) == "Cultivator") { ((Terminal)Chat.m_instance).AddString("You cannot pick plants when you have a Cultivator equipped."); } else { _pickable.Interact((Humanoid)(object)Player.m_localPlayer, false, false); } } } [HarmonyPatch(typeof(Pickable))] internal static class PickablePatch { [HarmonyPostfix] [HarmonyPatch("Awake")] private static void AwakePostfix(Pickable __instance) { if (PluginConfig.IsModEnabled.Value && Mod.PlantsToAutoPick.Contains(__instance.m_nview.m_zdo.m_prefab) && !__instance.m_picked) { ((Component)__instance).gameObject.AddComponent<AutoPicker>(); } } } public static class PluginConfig { public static ConfigEntry<bool> IsModEnabled { get; private set; } public static void BindConfig(ConfigFile config) { IsModEnabled = config.Bind<bool>("Global", "IsModEnabled", true, "Globally enable or disable this mod"); } }