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 ItemReroll v1.2.1
ItemReroll.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HarmonyLib; using RoR2; using UnityEngine; using UnityEngine.Networking; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace ItemReroll; [BepInPlugin("HotelPoolWater.ItemReroll", "ItemReroll", "1.2.1")] public class ItemRerollPlugin : BaseUnityPlugin { public const string PluginGUID = "HotelPoolWater.ItemReroll"; public const string PluginName = "ItemReroll"; public const string PluginVersion = "1.2.1"; private const string ThousandItemsGUID = "HotelPoolWater.ThousandItems"; private static List<PickupIndex> pendingItemPool; public void Awake() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) new Harmony("HotelPoolWater.ItemReroll").PatchAll(typeof(ItemRerollPlugin)); GenericPickupController.onPickupConsumed += OnPickupConsumed; } [HarmonyPatch(typeof(GenericPickupController), "AttemptGrant")] [HarmonyPrefix] private static void AttemptGrantPrefix(GenericPickupController __instance) { //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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Invalid comparison between Unknown and I4 //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Invalid comparison between Unknown and I4 //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Invalid comparison between Unknown and I4 pendingItemPool = null; if (!NetworkServer.active || !Object.op_Implicit((Object)(object)Run.instance)) { return; } UniquePickup pickup = __instance.pickup; PickupDef pickupDef = PickupCatalog.GetPickupDef(pickup.pickupIndex); if (pickupDef == null) { return; } List<PickupIndex> list; if ((int)pickupDef.itemIndex != -1) { list = BuildItemPool(); } else { if ((int)pickupDef.equipmentIndex == -1) { return; } list = BuildEquipmentPool(); } if (list.Count > 1) { list.Remove(pickup.pickupIndex); } if (list.Count != 0) { PickupIndex val = list[Random.Range(0, list.Count)]; __instance.pickup = ((UniquePickup)(ref pickup)).WithPickupIndex(val); if ((int)pickupDef.itemIndex != -1) { pendingItemPool = list; } } } [HarmonyPostfix] [HarmonyPatch(typeof(GenericPickupController), "AttemptGrant")] private static void AttemptGrantPostfix() { pendingItemPool = null; } private static List<PickupIndex> BuildItemPool() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Invalid comparison between Unknown and I4 //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) List<PickupIndex> list = new List<PickupIndex>(); for (int i = 0; i < ItemCatalog.itemCount; i++) { ItemIndex val = (ItemIndex)i; ItemDef itemDef = ItemCatalog.GetItemDef(val); if (!((Object)(object)itemDef == (Object)null) && !itemDef.hidden && (int)itemDef.tier != 5 && (int)itemDef.tier != 13 && Array.IndexOf(itemDef.tags, (ItemTag)10) < 0 && Run.instance.IsItemAvailable(val)) { PickupIndex val2 = PickupCatalog.FindPickupIndex(val); if (val2 != PickupIndex.none) { list.Add(val2); } } } return list; } private static List<PickupIndex> BuildEquipmentPool() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) List<PickupIndex> list = new List<PickupIndex>(); for (int i = 0; i < EquipmentCatalog.equipmentCount; i++) { EquipmentIndex val = (EquipmentIndex)i; EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(val); if (!((Object)(object)equipmentDef == (Object)null) && equipmentDef.canDrop && Run.instance.IsEquipmentAvailable(val)) { PickupIndex val2 = PickupCatalog.FindPickupIndex(val); if (val2 != PickupIndex.none) { list.Add(val2); } } } return list; } private static int GetThousandItemsStackSize() { if (!Chainloader.PluginInfos.TryGetValue("HotelPoolWater.ThousandItems", out var value) || !Object.op_Implicit((Object)(object)value.Instance)) { return 1; } ConfigEntry<int> val = default(ConfigEntry<int>); if (!value.Instance.Config.TryGetEntry<int>("General", "StackSize", ref val)) { return 1; } return val.Value; } private static void OnPickupConsumed(CharacterBody body, UniquePickup pickup) { //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Invalid comparison between Unknown and I4 //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) List<PickupIndex> list = pendingItemPool; if (list == null || list.Count == 0 || !NetworkServer.active || !Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.inventory)) { return; } int num = GetThousandItemsStackSize() - 1; if (num <= 0) { return; } Dictionary<ItemIndex, int> dictionary = new Dictionary<ItemIndex, int>(); for (int i = 0; i < num; i++) { PickupDef pickupDef = PickupCatalog.GetPickupDef(list[Random.Range(0, list.Count)]); if (pickupDef != null && (int)pickupDef.itemIndex != -1) { dictionary.TryGetValue(pickupDef.itemIndex, out var value); dictionary[pickupDef.itemIndex] = value + 1; } } Inventory inventory = body.inventory; foreach (KeyValuePair<ItemIndex, int> item in dictionary) { try { inventory.GiveItemPermanent(item.Key, item.Value); } catch (Exception ex) { Debug.LogException(ex); } } } }