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.5
AutoPickupCommandQueue.dll
Decompiled 2 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using Microsoft.CodeAnalysis; using RoR2; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("AutoPickupCommandQueue")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("AutoPickupCommandQueue")] [assembly: AssemblyTitle("AutoPickupCommandQueue")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [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 AutoPickupCommandQueue { [BepInPlugin("com.gogogadgetjustice.autopickup", "Auto Pickup", "2.1.0")] public class AutoPickupCommandQueue : BaseUnityPlugin { private ConfigEntry<bool> cfgEnabled; private ConfigEntry<float> cfgScanRadius; private ConfigEntry<KeyboardShortcut> cfgToggleKey; private ItemQueueManager queueManager; private bool isFeatureActive = true; private float drifterBagTimer = 0f; private const float DRIFTER_BAG_DELAY = 3f; private void Awake() { InitializeConfiguration(); queueManager = new ItemQueueManager(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Auto Pickup 2.1.0 Loaded - Command Essence Auto Pickup"); } private void InitializeConfiguration() { //IL_0062: Unknown result type (might be due to invalid IL or missing references) cfgEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Is the auto-pickup active?"); cfgScanRadius = ((BaseUnityPlugin)this).Config.Bind<float>("General", "ScanRadius", 1.5f, "Radius for interaction scan"); cfgToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keybinds", "ToggleFeature", new KeyboardShortcut((KeyCode)282, Array.Empty<KeyCode>()), "Toggle automatic pickup on/off"); } private void Update() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (cfgEnabled.Value) { KeyboardShortcut value = cfgToggleKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { isFeatureActive = !isFeatureActive; Chat.AddMessage("Auto Pickup: " + (isFeatureActive ? "ENABLED" : "DISABLED")); } if (isFeatureActive) { ProcessAutoPickup(); } } } private void ProcessAutoPickup() { //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Invalid comparison between Unknown and I4 //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Invalid comparison between Unknown and I4 //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Invalid comparison between Unknown and I4 LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser(); if ((Object)(object)((firstLocalUser != null) ? firstLocalUser.cachedBody : null) == (Object)null) { return; } CharacterBody cachedBody = firstLocalUser.cachedBody; bool flag = cachedBody.baseNameToken == "DRIFTER_BODY_NAME"; bool flag2 = cachedBody.baseNameToken == "SEEKER_BODY_NAME"; if (flag && drifterBagTimer < 3f) { drifterBagTimer += Time.deltaTime; return; } if (!flag) { drifterBagTimer = 0f; } if (flag2 && IsSeekerInFlight(cachedBody)) { return; } Interactor component = ((Component)cachedBody).GetComponent<Interactor>(); if ((Object)(object)component == (Object)null) { return; } Collider[] array = Physics.OverlapSphere(((Component)cachedBody).transform.position, cfgScanRadius.Value); Collider[] array2 = array; foreach (Collider val in array2) { if ((Object)(object)val == (Object)null) { continue; } GameObject gameObject = ((Component)val).gameObject; if ((Object)(object)gameObject == (Object)null) { continue; } string objName = ((Object)gameObject).name.ToLowerInvariant(); if ((flag && IsDrifterSpecialPickup(objName)) || IsBlockedInteractable(objName)) { continue; } GenericPickupController component2 = gameObject.GetComponent<GenericPickupController>(); if ((Object)(object)component2 != (Object)null) { if ((Object)(object)gameObject.GetComponent<PickupPickerController>() != (Object)null) { continue; } PickupDef pickupDef = PickupCatalog.GetPickupDef(component2.pickupIndex); if (pickupDef != null && ((int)pickupDef.equipmentIndex != -1 || ((Object)gameObject).name.ToLowerInvariant().Contains("equipment"))) { continue; } if (pickupDef != null && (int)pickupDef.itemIndex != -1) { ItemDef itemDef = ItemCatalog.GetItemDef(pickupDef.itemIndex); if ((Object)(object)itemDef != (Object)null && (int)itemDef.tier == 4) { continue; } } } try { component.AttemptInteraction(gameObject); } catch { } } } private bool IsDrifterSpecialPickup(string objName) { return objName.Contains("drifter") || objName.Contains("scrap") || objName.Contains("consume") || objName.Contains("bag"); } private bool IsBlockedInteractable(string objName) { string[] source = new string[11] { "shrine", "duplicator", "printer", "teleporter", "scrapper", "chest", "barrel", "pod", "terminal", "portal", "equipmentpickup" }; return source.Any((string b) => objName.Contains(b)); } private bool IsSeekerInFlight(CharacterBody body) { try { EntityStateMachine[] components = ((Component)body).GetComponents<EntityStateMachine>(); EntityStateMachine[] array = components; foreach (EntityStateMachine val in array) { if (((val != null) ? val.state : null) != null) { string name = ((object)val.state).GetType().Name; string text = ((object)val.state).GetType().FullName ?? ""; if (name.Contains("Sojourn") || name.Contains("Reprieve") || text.Contains("Sojourn") || text.Contains("Reprieve")) { return true; } } } } catch { } return false; } } public class ItemQueueManager { public enum ItemTier { Common, Uncommon, Legendary, Boss, Lunar, Void, Equipment } private Dictionary<ItemTier, List<ItemIndex>> queues = new Dictionary<ItemTier, List<ItemIndex>>(); private Dictionary<ItemTier, int> currentIndices = new Dictionary<ItemTier, int>(); public ItemQueueManager() { foreach (ItemTier value in Enum.GetValues(typeof(ItemTier))) { queues[value] = new List<ItemIndex>(); currentIndices[value] = 0; } } public ItemTier GetItemTier(ItemDef itemDef) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Invalid comparison between Unknown and I4 //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Invalid comparison between Unknown and I4 //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Invalid comparison between Unknown and I4 //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Invalid comparison between Unknown and I4 //IL_006f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)itemDef == (Object)null) { return ItemTier.Common; } try { if ((int)itemDef.tier == 0) { return ItemTier.Common; } if ((int)itemDef.tier == 1) { return ItemTier.Uncommon; } if ((int)itemDef.tier == 2) { return ItemTier.Legendary; } if ((int)itemDef.tier == 4) { return ItemTier.Boss; } if ((int)itemDef.tier == 3) { return ItemTier.Lunar; } if (IsVoidTier(itemDef.tier)) { return ItemTier.Void; } return ItemTier.Common; } catch { return ItemTier.Common; } } private bool IsVoidTier(ItemTier tier) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Invalid comparison between Unknown and I4 return (int)tier == 6 || (int)tier == 7 || (int)tier == 8; } public List<ItemIndex> GetQueue(ItemTier tier) { return queues.ContainsKey(tier) ? queues[tier] : new List<ItemIndex>(); } public int GetCurrentIndex(ItemTier tier) { return currentIndices.ContainsKey(tier) ? currentIndices[tier] : 0; } public void SetCurrentIndex(ItemTier tier, int index) { if (currentIndices.ContainsKey(tier)) { currentIndices[tier] = Mathf.Clamp(index, 0, Mathf.Max(0, queues[tier].Count - 1)); } } public void MoveToNextItem(ItemTier tier) { List<ItemIndex> queue = GetQueue(tier); if (queue.Count != 0) { currentIndices[tier]++; if (currentIndices[tier] >= queue.Count) { currentIndices[tier] = 0; } } } public string GetTierName(ItemTier tier) { if (1 == 0) { } string result = tier switch { ItemTier.Common => "Common", ItemTier.Uncommon => "Uncommon", ItemTier.Legendary => "Legendary", ItemTier.Boss => "Boss", ItemTier.Lunar => "Lunar", ItemTier.Void => "Void", _ => "Unknown", }; if (1 == 0) { } return result; } } }