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 Autopickup v1.0.1
plugins/Autopickup.dll
Decompiled a year agousing System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("Autopickup")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Autopickup")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("7d7f1406-a2b8-4cf3-b839-7e54cdb5569d")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] [BepInPlugin("com.yourname.autogather", "Auto Gather", "1.0.0")] public class AutoGather : BaseUnityPlugin { private ConfigEntry<float> gatherRadius; private ConfigEntry<KeyCode> gatherKey; private ConfigEntry<bool> enableAutoGather; private ConfigEntry<KeyCode> toggleAutoGatherKey; private float gatherInterval = 0.5f; private float lastGatherTime = 0f; private void Awake() { gatherRadius = ((BaseUnityPlugin)this).Config.Bind<float>("General", "GatherRadius", 8f, "自动采集半径(米)"); gatherKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "GatherKey", (KeyCode)103, "手动采集快捷键"); enableAutoGather = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableAutoGather", true, "是否启用自动采集"); toggleAutoGatherKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "ToggleAutoGatherKey", (KeyCode)289, "切换自动采集开关的快捷键"); } private void Update() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } if (Input.GetKeyDown(toggleAutoGatherKey.Value)) { enableAutoGather.Value = !enableAutoGather.Value; string text = (enableAutoGather.Value ? "<color=green>开启</color>" : "<color=red>关闭</color>"); if ((Object)(object)Player.m_localPlayer != (Object)null) { ((Character)Player.m_localPlayer).Message((MessageType)1, "<size=30>自动拾取功能已" + text + "</size>", 0, (Sprite)null); } } if (!IsInventoryFull(localPlayer)) { if (enableAutoGather.Value && Time.time - lastGatherTime > gatherInterval) { GatherNearbyPickables(localPlayer); lastGatherTime = Time.time; } if (Input.GetKeyDown(gatherKey.Value)) { GatherNearbyPickables(localPlayer); } } } private void GatherNearbyPickables(Player player) { IEnumerable<Pickable> enumerable = from p in Object.FindObjectsOfType<Pickable>() where Vector3.Distance(((Component)p).transform.position, ((Component)player).transform.position) < gatherRadius.Value select p; foreach (Pickable item in enumerable) { item.Interact((Humanoid)(object)player, false, false); if (IsInventoryFull(player)) { break; } } } private bool IsInventoryFull(Player player) { Inventory inventory = ((Humanoid)player).GetInventory(); for (int i = 0; i < inventory.GetHeight(); i++) { for (int j = 0; j < inventory.GetWidth(); j++) { if (inventory.GetItemAt(j, i) == null) { return false; } } } return true; } private void ShowMessage(string msg) { if ((Object)(object)Player.m_localPlayer != (Object)null) { ((Character)Player.m_localPlayer).Message((MessageType)1, msg, 0, (Sprite)null); } } }