Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of BazaarNoAutoPickup v1.5.0
Plugins/BazaarNoAutoPickup.dll
Decompiled 3 months agousing System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using On.RoR2; using RoR2; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("BazaarNoAutoPickup")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("BazaarNoAutoPickup")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("9543fe8e-f414-450f-a4cb-d0db93858e8a")] [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")] namespace BazaarNoAutoPickup; [BepInPlugin("yourname.bazaarnoautopickup", "Bazaar No Auto Pickup", "1.5.0")] public class Plugin : BaseUnityPlugin { private static ManualLogSource LogSrc; private static bool inBazaar = false; private static float bazaarEnterTime = 0f; private const float GraceSeconds = 3f; private const float ProximityAllow = 7f; private const float PurchaseWindow = 1.5f; private static readonly Dictionary<int, float> lastPurchaseTime = new Dictionary<int, float>(); private void Awake() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown LogSrc = ((BaseUnityPlugin)this).Logger; SceneManager.activeSceneChanged += OnSceneChanged; Inventory.GiveItem_ItemIndex_int += new hook_GiveItem_ItemIndex_int(OnGiveItem); PurchaseInteraction.OnInteractionBegin += new hook_OnInteractionBegin(OnPurchaseBegin); ((BaseUnityPlugin)this).Logger.LogInfo((object)"BazaarNoAutoPickup loaded (v1.5.0)"); } private void OnDestroy() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown SceneManager.activeSceneChanged -= OnSceneChanged; Inventory.GiveItem_ItemIndex_int -= new hook_GiveItem_ItemIndex_int(OnGiveItem); PurchaseInteraction.OnInteractionBegin -= new hook_OnInteractionBegin(OnPurchaseBegin); } private void OnSceneChanged(Scene prev, Scene next) { string text = ((Scene)(ref next)).name ?? string.Empty; inBazaar = text.ToLowerInvariant().Contains("bazaar"); if (inBazaar) { bazaarEnterTime = Time.realtimeSinceStartup; lastPurchaseTime.Clear(); } LogSrc.LogInfo((object)$"Scene -> {text} | inBazaar={inBazaar}"); } private void OnPurchaseBegin(orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator) { if (inBazaar && (Object)(object)activator != (Object)null) { CharacterBody component = ((Component)activator).GetComponent<CharacterBody>(); CharacterMaster val = (((Object)(object)component != (Object)null) ? component.master : null); if ((Object)(object)val != (Object)null) { lastPurchaseTime[((Object)val).GetInstanceID()] = Time.realtimeSinceStartup; } } orig.Invoke(self, activator); } private void OnGiveItem(orig_GiveItem_ItemIndex_int orig, Inventory self, ItemIndex itemIndex, int count) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) if (!inBazaar) { orig.Invoke(self, itemIndex, count); } else if (!(Time.realtimeSinceStartup - bazaarEnterTime < 3f)) { CharacterMaster val = (((Object)(object)self != (Object)null) ? ((Component)self).GetComponent<CharacterMaster>() : null); CharacterBody body = (((Object)(object)val != (Object)null) ? val.GetBody() : null); if ((Object)(object)val != (Object)null && lastPurchaseTime.TryGetValue(((Object)val).GetInstanceID(), out var value) && Time.realtimeSinceStartup - value <= 1.5f) { orig.Invoke(self, itemIndex, count); } else if (!(GetNearestPickupDistance(body) > 7f)) { orig.Invoke(self, itemIndex, count); } } } private static float GetNearestPickupDistance(CharacterBody body) { //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) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)body == (Object)null) { return float.PositiveInfinity; } float num = float.PositiveInfinity; GenericPickupController[] array = Object.FindObjectsOfType<GenericPickupController>(); Vector3 corePosition = body.corePosition; GenericPickupController[] array2 = array; foreach (GenericPickupController val in array2) { if (!((Object)(object)val == (Object)null)) { float num2 = Vector3.Distance(corePosition, ((Component)val).transform.position); if (num2 < num) { num = num2; } } } return num; } }