Decompiled source of ItemLuck v1.0.1

ItemLuck.dll

Decompiled a year ago
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.ScavBackpack;
using Microsoft.CodeAnalysis;
using On.EntityStates.ScavBackpack;
using On.RoR2;
using On.RoR2.Artifacts;
using RiskOfOptions;
using RiskOfOptions.Components.Options;
using RiskOfOptions.Components.Panel;
using RiskOfOptions.Components.RuntimePrefabs;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Artifacts;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("ItemLuck")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+6828a68ef7c4460a8d7be2b6f8885d07f1597043")]
[assembly: AssemblyProduct("ItemLuck")]
[assembly: AssemblyTitle("ItemLuck")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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;
		}
	}
	[EditorBrowsable(EditorBrowsableState.Never)]
	public static class IsExternalInit
	{
	}
}
namespace ItemLuck
{
	public record Element(bool IsSelected, string Name, float Weigth);
	public class DescriptionBuilder
	{
		private readonly StringBuilder _sb;

		public DescriptionBuilder(StringBuilder sb)
		{
			_sb = sb;
		}

		public void AppendElements(List<Element> elements)
		{
			float num = elements.Sum((Element x) => x.Weigth);
			float num2 = 1f / (float)elements.Count;
			for (int i = 0; i < elements.Count; i++)
			{
				Element element = elements[i];
				if (element.IsSelected)
				{
					_sb.Append("<color=\"yellow\">");
				}
				_sb.Append(element.Name);
				if (element.IsSelected)
				{
					_sb.Append("</color>");
				}
				_sb.Append(": ");
				float num3 = element.Weigth / num;
				float num4 = num3 - num2;
				bool num5 = Mathf.Abs(num4) <= 0.001f;
				if (!num5)
				{
					if (num3 > num2)
					{
						_sb.Append("<color=\"green\">");
					}
					else
					{
						_sb.Append("<color=\"red\">");
					}
				}
				_sb.Append($"{num3 * 100f:0.##}%");
				if (!num5)
				{
					_sb.Append("</color>");
					_sb.Append(" (");
					if (num4 > 0f)
					{
						_sb.Append('+');
					}
					_sb.Append($"{num4 * 100f:0.##}%");
					_sb.Append(')');
				}
				_sb.AppendLine();
			}
		}
	}
	public static class ModOptionPanelControllerExtensions
	{
		private static readonly FieldInfo _panelField = typeof(ModOptionPanelController).GetField("_panel", BindingFlags.Instance | BindingFlags.NonPublic);

		public static ModOptionsPanelPrefab GetPanel(this ModOptionPanelController controller)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			return (ModOptionsPanelPrefab)_panelField.GetValue(controller);
		}
	}
	public class TierList
	{
		private readonly Dictionary<ItemIndex, ConfigEntry<Tier>> _itemConfigByItem;

		private readonly Dictionary<EquipmentIndex, ConfigEntry<Tier>> _equipmentConfigByItem;

		private TierList(Dictionary<ItemIndex, ConfigEntry<Tier>> itemConfigByItem, Dictionary<EquipmentIndex, ConfigEntry<Tier>> equipmentConfigByItem)
		{
			_itemConfigByItem = itemConfigByItem;
			_equipmentConfigByItem = equipmentConfigByItem;
		}

		public static TierList Create(ConfigFile config)
		{
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			Log.Debug("Initializing TierList");
			DefaultTierList defaultTierList = DefaultTierList.Create();
			Dictionary<ItemIndex, Rank<ItemDef>> dictionary = defaultTierList.Items.ToDictionary((Rank<ItemDef> x) => x.Def.itemIndex);
			Dictionary<ItemIndex, ConfigEntry<Tier>> dictionary2 = new Dictionary<ItemIndex, ConfigEntry<Tier>>();
			var items = from x in GetValidItems()
				select new
				{
					Name = NormaliseName(Language.GetString(x.nameToken)),
					ItemDef = x
				} into x
				orderby x.ItemDef.tier, x.Name
				select x;
			foreach (var item in items)
			{
				Tier tier = Tier.Unspecified;
				if (dictionary.TryGetValue(item.ItemDef.itemIndex, out var value))
				{
					tier = value.Tier;
				}
				ConfigEntry<Tier> val = config.Bind<Tier>(item.ItemDef.tier.GetShortName(), item.Name, tier, "test2");
				dictionary2[item.ItemDef.itemIndex] = val;
				Func<List<Element>> getElements = () => (from x in items
					where x.ItemDef.tier == item.ItemDef.tier
					select new Element((Object)(object)x.ItemDef == (Object)(object)item.ItemDef, x.Name, (ItemLuckPlugin.TierList.GetTier(x.ItemDef.itemIndex) ?? Tier.Unspecified).ApplyItemLuck(1f)) into x
					orderby x.Name
					select x).ToList();
				UpdatableChoiceOption choiceOption2 = new UpdatableChoiceOption((ConfigEntryBase)(object)val, getElements);
				ModSettingsManager.AddOption((BaseOption)(object)choiceOption2);
				val.SettingChanged += delegate
				{
					UpdatableOptions.UpdateDescriptions();
					choiceOption2.UpdatePanel();
				};
			}
			Dictionary<EquipmentIndex, Rank<EquipmentDef>> dictionary3 = defaultTierList.Equipments.ToDictionary((Rank<EquipmentDef> x) => x.Def.equipmentIndex);
			Dictionary<EquipmentIndex, ConfigEntry<Tier>> dictionary4 = new Dictionary<EquipmentIndex, ConfigEntry<Tier>>();
			var equipements = from x in GetValidEquipments()
				select new
				{
					Name = NormaliseName(Language.GetString(x.nameToken)),
					EquipmentDef = x
				} into x
				orderby x.Name
				select x;
			foreach (var equipment in equipements)
			{
				Tier tier2 = Tier.Unspecified;
				if (dictionary3.TryGetValue(equipment.EquipmentDef.equipmentIndex, out var value2))
				{
					tier2 = value2.Tier;
				}
				ConfigEntry<Tier> val2 = config.Bind<Tier>("Equipments", equipment.Name, tier2, (ConfigDescription)null);
				dictionary4[equipment.EquipmentDef.equipmentIndex] = val2;
				Func<List<Element>> getElements2 = () => (from x in equipements
					select new Element((Object)(object)x.EquipmentDef == (Object)(object)equipment.EquipmentDef, x.Name, (ItemLuckPlugin.TierList.GetTier(x.EquipmentDef.equipmentIndex) ?? Tier.Unspecified).ApplyItemLuck(1f)) into x
					orderby x.Name
					select x).ToList();
				UpdatableChoiceOption choiceOption = new UpdatableChoiceOption((ConfigEntryBase)(object)val2, getElements2);
				ModSettingsManager.AddOption((BaseOption)(object)choiceOption);
				val2.SettingChanged += delegate
				{
					UpdatableOptions.UpdateDescriptions();
					choiceOption.UpdatePanel();
				};
			}
			Log.Debug("TierList Initialized");
			return new TierList(dictionary2, dictionary4);
			static string NormaliseName(string name)
			{
				return Regex.Replace(name, "[=\\n\\t\\\\\"'\\[\\]]", "").Trim();
			}
		}

		public static IEnumerable<ItemDef> GetValidItems()
		{
			return from x in ItemCatalog.itemDefs
				where (int)x.tier != 5
				where x.canRemove
				where !x.hidden
				where x.DoesNotContainTag((ItemTag)10)
				where x.DoesNotContainTag((ItemTag)9)
				select x;
		}

		public static IEnumerable<EquipmentDef> GetValidEquipments()
		{
			return EquipmentCatalog.equipmentDefs.Where((EquipmentDef x) => x.canDrop);
		}

		public Tier? GetTier(ItemIndex itemIndex)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			if (_itemConfigByItem.TryGetValue(itemIndex, out var value))
			{
				return value.Value;
			}
			return null;
		}

		public Tier? GetTier(EquipmentIndex equipmentIndex)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			if (_equipmentConfigByItem.TryGetValue(equipmentIndex, out var value))
			{
				return value.Value;
			}
			return null;
		}
	}
	public class UpdatableChoiceOption : ChoiceOption, IUpdatableOption
	{
		private DropDownController _dropdownController;

		private Func<List<Element>> _getElements;

		public UpdatableChoiceOption(ConfigEntryBase configEntry, Func<List<Element>> getElements)
			: base(configEntry)
		{
			_getElements = getElements;
			UpdatableOptions.Instances.Add(this);
		}

		public override GameObject CreateOptionGameObject(GameObject prefab, Transform parent)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			GameObject val = ((ChoiceOption)this).CreateOptionGameObject(prefab, parent);
			_dropdownController = val.GetComponentInChildren<DropDownController>();
			((MPButton)val.GetComponentInChildren<HGButton>()).onSelect.AddListener(new UnityAction(UpdatePanel));
			return val;
		}

		private string GetCurrentDescription()
		{
			List<Element> elements = _getElements();
			StringBuilder stringBuilder = new StringBuilder();
			new DescriptionBuilder(stringBuilder).AppendElements(elements);
			return stringBuilder.ToString();
		}

		public void UpdateDescription()
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			string currentDescription = GetCurrentDescription();
			((BaseOption)this).SetDescription(currentDescription, new BaseOptionConfig());
		}

		public void UpdatePanel()
		{
			ModOptionsPanelPrefab panel = ((ModSetting)_dropdownController).optionController.GetPanel();
			string currentDescription = GetCurrentDescription();
			((TMP_Text)panel.ModOptionsDescriptionPanel.GetComponentInChildren<HGTextMeshProUGUI>()).SetText(currentDescription, true);
		}
	}
	public interface IUpdatableOption
	{
		void UpdateDescription();

		void UpdatePanel();
	}
	public static class UpdatableOptions
	{
		public static List<IUpdatableOption> Instances { get; } = new List<IUpdatableOption>();


		public static void UpdateDescriptions()
		{
			foreach (IUpdatableOption instance in Instances)
			{
				instance.UpdateDescription();
			}
		}
	}
	public class UpdatableStepSliderOption : StepSliderOption, IUpdatableOption
	{
		private ModSettingsStepSlider _silder;

		public UpdatableStepSliderOption(ConfigEntry<float> configEntry, StepSliderConfig config)
			: base(configEntry, config)
		{
			UpdatableOptions.Instances.Add(this);
		}

		public override GameObject CreateOptionGameObject(GameObject prefab, Transform parent)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			GameObject val = ((StepSliderOption)this).CreateOptionGameObject(prefab, parent);
			_silder = val.GetComponentInChildren<ModSettingsStepSlider>();
			((MPButton)val.GetComponentInChildren<HGButton>()).onSelect.AddListener(new UnityAction(UpdatePanel));
			return val;
		}

		private string GetCurrentDescription()
		{
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			var list = (from x in TierList.GetValidItems()
				select new
				{
					Tier = x.tier,
					Element = new Element(IsSelected: false, Language.GetString(x.nameToken), (ItemLuckPlugin.TierList.GetTier(x.itemIndex) ?? Tier.Unspecified).ApplyItemLuck(1f))
				} into x
				group x by x.Tier into x
				orderby x.Key
				select new
				{
					Color = ColorCatalog.GetColor(ItemTierCatalog.GetItemTierDef(x.Key).colorIndex),
					CategoryName = x.Key.GetFullName(),
					Elements = (from x in x
						select x.Element into x
						orderby x.Name
						select x).ToList()
				}).ToList();
			list.Add(new
			{
				Color = ColorCatalog.GetColor((ColorIndex)5),
				CategoryName = "Equipments",
				Elements = (from x in TierList.GetValidEquipments()
					select new Element(IsSelected: false, Language.GetString(x.nameToken), (ItemLuckPlugin.TierList.GetTier(x.equipmentIndex) ?? Tier.Unspecified).ApplyItemLuck(1f))).ToList()
			});
			StringBuilder stringBuilder = new StringBuilder();
			DescriptionBuilder descriptionBuilder = new DescriptionBuilder(stringBuilder);
			foreach (var item in list)
			{
				stringBuilder.Append("<color=#" + ColorUtility.ToHtmlStringRGB(Color32.op_Implicit(item.Color)) + ">");
				stringBuilder.Append(item.CategoryName);
				stringBuilder.Append(":</color>");
				stringBuilder.AppendLine();
				descriptionBuilder.AppendElements(item.Elements);
				stringBuilder.AppendLine();
			}
			return stringBuilder.ToString();
		}

		public void UpdateDescription()
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			string currentDescription = GetCurrentDescription();
			((BaseOption)this).SetDescription(currentDescription, new BaseOptionConfig());
		}

		public void UpdatePanel()
		{
			ModOptionsPanelPrefab panel = ((ModSetting)_silder).optionController.GetPanel();
			string currentDescription = GetCurrentDescription();
			((TMP_Text)panel.ModOptionsDescriptionPanel.GetComponentInChildren<HGTextMeshProUGUI>()).SetText(currentDescription, true);
		}
	}
	public class DefaultTierList
	{
		public List<Rank<ItemDef>> Items { get; }

		public List<Rank<EquipmentDef>> Equipments { get; }

		private DefaultTierList(List<Rank<ItemDef>> items, List<Rank<EquipmentDef>> equipments)
		{
			Items = items;
			Equipments = equipments;
		}

		public static DefaultTierList Create()
		{
			List<Rank<ItemDef>> items = new List<Rank<ItemDef>>
			{
				new Rank<ItemDef>(Items.Hoof, Tier.S),
				new Rank<ItemDef>(Items.CritGlasses, Tier.S),
				new Rank<ItemDef>(Items.SprintBonus, Tier.S),
				new Rank<ItemDef>(Items.FragileDamageBonus, Tier.S),
				new Rank<ItemDef>(Items.AttackSpeedAndMoveSpeed, Tier.A),
				new Rank<ItemDef>(Items.IgniteOnKill, Tier.A),
				new Rank<ItemDef>(Items.BleedOnHit, Tier.A),
				new Rank<ItemDef>(Items.Syringe, Tier.A),
				new Rank<ItemDef>(Items.Bear, Tier.A),
				new Rank<ItemDef>(Items.HealWhileSafe, Tier.A),
				new Rank<ItemDef>(Items.OutOfCombatArmor, Tier.A),
				new Rank<ItemDef>(Items.BossDamageBonus, Tier.A),
				new Rank<ItemDef>(Items.TreasureCache, Tier.B),
				new Rank<ItemDef>(Items.StickyBomb, Tier.B),
				new Rank<ItemDef>(Items.Crowbar, Tier.B),
				new Rank<ItemDef>(Items.ArmorPlate, Tier.B),
				new Rank<ItemDef>(Items.NearbyDamageBonus, Tier.B),
				new Rank<ItemDef>(Items.SecondarySkillMagazine, Tier.B),
				new Rank<ItemDef>(Items.BarrierOnKill, Tier.C),
				new Rank<ItemDef>(Items.PersonalShield, Tier.C),
				new Rank<ItemDef>(Items.HealingPotion, Tier.C),
				new Rank<ItemDef>(Items.Firework, Tier.C),
				new Rank<ItemDef>(Items.Tooth, Tier.C),
				new Rank<ItemDef>(Items.GoldOnHurt, Tier.D),
				new Rank<ItemDef>(Items.Mushroom, Tier.D),
				new Rank<ItemDef>(Items.Medkit, Tier.D),
				new Rank<ItemDef>(Items.StunChanceOnHit, Tier.D),
				new Rank<ItemDef>(Items.WardOnLevel, Tier.F),
				new Rank<ItemDef>(Items.FlatHealth, Tier.F),
				new Rank<ItemDef>(Items.Feather, Tier.S),
				new Rank<ItemDef>(Items.IceRing, Tier.S),
				new Rank<ItemDef>(Items.FireRing, Tier.S),
				new Rank<ItemDef>(Items.Missile, Tier.S),
				new Rank<ItemDef>(Items.ChainLightning, Tier.A),
				new Rank<ItemDef>(Items.ExplodeOnDeath, Tier.A),
				new Rank<ItemDef>(Items.PrimarySkillShuriken, Tier.A),
				new Rank<ItemDef>(Items.StrengthenBurn, Tier.B),
				new Rank<ItemDef>(Items.JumpBoost, Tier.B),
				new Rank<ItemDef>(Items.SprintArmor, Tier.B),
				new Rank<ItemDef>(Items.BonusGoldPackOnKill, Tier.C),
				new Rank<ItemDef>(Items.EquipmentMagazine, Tier.C),
				new Rank<ItemDef>(Items.FreeChest, Tier.C),
				new Rank<ItemDef>(Items.SlowOnHit, Tier.C),
				new Rank<ItemDef>(Items.AttackSpeedOnCrit, Tier.C),
				new Rank<ItemDef>(Items.SprintOutOfCombat, Tier.C),
				new Rank<ItemDef>(Items.ExecuteLowHealthElite, Tier.C),
				new Rank<ItemDef>(Items.DeathMark, Tier.C),
				new Rank<ItemDef>(Items.EnergizedOnEquipmentUse, Tier.D),
				new Rank<ItemDef>(Items.Bandolier, Tier.D),
				new Rank<ItemDef>(Items.RegeneratingScrap, Tier.D),
				new Rank<ItemDef>(Items.HealOnCrit, Tier.D),
				new Rank<ItemDef>(Items.Squid, Tier.F),
				new Rank<ItemDef>(Items.Thorns, Tier.F),
				new Rank<ItemDef>(Items.Infusion, Tier.F),
				new Rank<ItemDef>(Items.WarCryOnMultiKill, Tier.F),
				new Rank<ItemDef>(Items.Phasing, Tier.F),
				new Rank<ItemDef>(Items.MoveSpeedOnKill, Tier.F),
				new Rank<ItemDef>(Items.Seed, Tier.F),
				new Rank<ItemDef>(Items.TPHealingNova, Tier.F),
				new Rank<ItemDef>(Items.TreasureCacheVoid, Tier.S),
				new Rank<ItemDef>(Items.BearVoid, Tier.S),
				new Rank<ItemDef>(Items.ChainLightningVoid, Tier.S),
				new Rank<ItemDef>(Items.MissileVoid, Tier.S),
				new Rank<ItemDef>(Items.ExplodeOnDeathVoid, Tier.A),
				new Rank<ItemDef>(Items.MushroomVoid, Tier.A),
				new Rank<ItemDef>(Items.ExtraLifeVoid, Tier.A),
				new Rank<ItemDef>(Items.EquipmentMagazineVoid, Tier.A),
				new Rank<ItemDef>(Items.BleedOnHitVoid, Tier.B),
				new Rank<ItemDef>(Items.SlowOnHitVoid, Tier.B),
				new Rank<ItemDef>(Items.CritGlassesVoid, Tier.D),
				new Rank<ItemDef>(Items.CloverVoid, Tier.D),
				new Rank<ItemDef>(Items.VoidMegaCrabItem, Tier.F),
				new Rank<ItemDef>(Items.ElementalRingVoid, Tier.F),
				new Rank<ItemDef>(Items.ShieldOnly, Tier.S),
				new Rank<ItemDef>(Items.AutoCastEquipment, Tier.S),
				new Rank<ItemDef>(Items.LunarSpecialReplacement, Tier.S),
				new Rank<ItemDef>(Items.LunarDagger, Tier.S),
				new Rank<ItemDef>(Items.RandomlyLunar, Tier.A),
				new Rank<ItemDef>(Items.FocusConvergence, Tier.B),
				new Rank<ItemDef>(Items.LunarBadLuck, Tier.B),
				new Rank<ItemDef>(Items.LunarUtilityReplacement, Tier.B),
				new Rank<ItemDef>(Items.LunarSun, Tier.B),
				new Rank<ItemDef>(Items.LunarPrimaryReplacement, Tier.B),
				new Rank<ItemDef>(Items.LunarSecondaryReplacement, Tier.B),
				new Rank<ItemDef>(Items.RepeatHeal, Tier.C),
				new Rank<ItemDef>(Items.GoldOnHit, Tier.C),
				new Rank<ItemDef>(Items.RandomDamageZone, Tier.C),
				new Rank<ItemDef>(Items.LunarTrinket, Tier.D),
				new Rank<ItemDef>(Items.MonstersOnShrineUse, Tier.D),
				new Rank<ItemDef>(Items.HalfAttackSpeedHalfCooldowns, Tier.F),
				new Rank<ItemDef>(Items.HalfSpeedDoubleHealth, Tier.F),
				new Rank<ItemDef>(Items.LightningStrikeOnHit, Tier.S),
				new Rank<ItemDef>(Items.FireballsOnHit, Tier.S),
				new Rank<ItemDef>(Items.BleedOnHitAndExplode, Tier.S),
				new Rank<ItemDef>(Items.ShinyPearl, Tier.S),
				new Rank<ItemDef>(Items.SprintWisp, Tier.S),
				new Rank<ItemDef>(Items.RoboBallBuddy, Tier.A),
				new Rank<ItemDef>(Items.SiphonOnLowHealth, Tier.C),
				new Rank<ItemDef>(Items.BeetleGland, Tier.C),
				new Rank<ItemDef>(Items.NovaOnLowHealth, Tier.D),
				new Rank<ItemDef>(Items.TitanGoldDuringTP, Tier.D),
				new Rank<ItemDef>(Items.ParentEgg, Tier.D),
				new Rank<ItemDef>(Items.Pearl, Tier.D),
				new Rank<ItemDef>(Items.Knurl, Tier.D),
				new Rank<ItemDef>(Items.MinorConstructOnKill, Tier.F),
				new Rank<ItemDef>(Items.FallBoots, Tier.S),
				new Rank<ItemDef>(Items.Clover, Tier.S),
				new Rank<ItemDef>(Items.DroneWeapons, Tier.S),
				new Rank<ItemDef>(Items.ExtraLife, Tier.S),
				new Rank<ItemDef>(Items.BounceNearby, Tier.S),
				new Rank<ItemDef>(Items.PermanentDebuffOnHit, Tier.S),
				new Rank<ItemDef>(Items.Behemoth, Tier.S),
				new Rank<ItemDef>(Items.MoreMissile, Tier.A),
				new Rank<ItemDef>(Items.ShockNearby, Tier.A),
				new Rank<ItemDef>(Items.Dagger, Tier.A),
				new Rank<ItemDef>(Items.ArmorReductionOnHit, Tier.A),
				new Rank<ItemDef>(Items.CritDamage, Tier.A),
				new Rank<ItemDef>(Items.UtilitySkillMagazine, Tier.A),
				new Rank<ItemDef>(Items.Icicle, Tier.B),
				new Rank<ItemDef>(Items.Talisman, Tier.C),
				new Rank<ItemDef>(Items.LaserTurbine, Tier.C),
				new Rank<ItemDef>(Items.Plant, Tier.C),
				new Rank<ItemDef>(Items.AlienHead, Tier.C),
				new Rank<ItemDef>(Items.IncreaseHealing, Tier.D),
				new Rank<ItemDef>(Items.KillEliteFrenzy, Tier.D),
				new Rank<ItemDef>(Items.ImmuneToDebuff, Tier.D),
				new Rank<ItemDef>(Items.GhostOnKill, Tier.D),
				new Rank<ItemDef>(Items.RandomEquipmentTrigger, Tier.D),
				new Rank<ItemDef>(Items.HeadHunter, Tier.F),
				new Rank<ItemDef>(Items.NovaOnHeal, Tier.F),
				new Rank<ItemDef>(Items.BarrierOnOverHeal, Tier.F)
			};
			List<Rank<EquipmentDef>> equipments = new List<Rank<EquipmentDef>>
			{
				new Rank<EquipmentDef>(Equipment.Tonic, Tier.S),
				new Rank<EquipmentDef>(Equipment.Recycle, Tier.S),
				new Rank<EquipmentDef>(Equipment.BossHunter, Tier.S),
				new Rank<EquipmentDef>(Equipment.MultiShopCard, Tier.S),
				new Rank<EquipmentDef>(Equipment.Lightning, Tier.A),
				new Rank<EquipmentDef>(Equipment.GoldGat, Tier.A),
				new Rank<EquipmentDef>(Equipment.Jetpack, Tier.A),
				new Rank<EquipmentDef>(Equipment.Saw, Tier.A),
				new Rank<EquipmentDef>(Equipment.CommandMissile, Tier.B),
				new Rank<EquipmentDef>(Equipment.FireBallDash, Tier.B),
				new Rank<EquipmentDef>(Equipment.Gateway, Tier.B),
				new Rank<EquipmentDef>(Equipment.BFG, Tier.C),
				new Rank<EquipmentDef>(Equipment.GummyClone, Tier.C),
				new Rank<EquipmentDef>(Equipment.Cleanse, Tier.C),
				new Rank<EquipmentDef>(Equipment.VendingMachine, Tier.C),
				new Rank<EquipmentDef>(Equipment.BurnNearby, Tier.C),
				new Rank<EquipmentDef>(Equipment.Blackhole, Tier.C),
				new Rank<EquipmentDef>(Equipment.DeathProjectile, Tier.C),
				new Rank<EquipmentDef>(Equipment.CritOnUse, Tier.C),
				new Rank<EquipmentDef>(Equipment.GainArmor, Tier.C),
				new Rank<EquipmentDef>(Equipment.Meteor, Tier.C),
				new Rank<EquipmentDef>(Equipment.TeamWarCry, Tier.C),
				new Rank<EquipmentDef>(Equipment.LifestealOnHit, Tier.D),
				new Rank<EquipmentDef>(Equipment.PassiveHealing, Tier.D),
				new Rank<EquipmentDef>(Equipment.Fruit, Tier.D),
				new Rank<EquipmentDef>(Equipment.DroneBackup, Tier.F),
				new Rank<EquipmentDef>(Equipment.Molotov, Tier.F),
				new Rank<EquipmentDef>(Equipment.Scanner, Tier.F),
				new Rank<EquipmentDef>(Equipment.CrippleWard, Tier.F)
			};
			return new DefaultTierList(items, equipments);
		}
	}
	public class Disposable : IDisposable
	{
		private readonly Action _dispose;

		public static Disposable Empty { get; } = new Disposable(delegate
		{
		});


		public Disposable(Action dispose)
		{
			_dispose = dispose;
		}

		public void Dispose()
		{
			_dispose();
		}
	}
	public class CompositeDisposable : IDisposable
	{
		private readonly List<IDisposable> _disposables;

		public CompositeDisposable()
		{
			_disposables = new List<IDisposable>();
		}

		public void Add(IDisposable disposable)
		{
			_disposables.Add(disposable);
		}

		public void AddRange(IEnumerable<IDisposable> disposables)
		{
			_disposables.AddRange(disposables);
		}

		public void Dispose()
		{
			foreach (IDisposable disposable in _disposables)
			{
				disposable.Dispose();
			}
		}
	}
	public static class Hooks
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Init <0>__ItemCatalog_Init;

			public static hook_Roll <1>__ChestBehavior_Roll;

			public static hook_GenerateNewPickupServer_bool <2>__ShopTerminalBehavior_GenerateNewPickupServer_bool;

			public static hook_GenerateEntriesServer <3>__RouletteChestController_GenerateEntriesServer;

			public static hook_AddShrineStack <4>__ShrineChanceBehavior_AddShrineStack;

			public static hook_GenerateDropPreReplacement <5>__FreeChestDropTable_GenerateDropPreReplacement;

			public static hook_Roll <6>__OptionChestBehavior_Roll;

			public static hook_DropRewards <7>__BossGroup_DropRewards;

			public static hook_FixedUpdate <8>__Opening_FixedUpdate;

			public static hook_RollItem <9>__ChestBehavior_RollItem;

			public static hook_GenerateDropPreReplacement <10>__DoppelgangerDropTable_GenerateDropPreReplacement;

			public static hook_OnServerCharacterDeath <11>__SacrificeArtifactManager_OnServerCharacterDeath;

			public static hook_DropRewards <12>__InfiniteTowerWaveController_DropRewards;

			public static hook_GenerateUniqueDropsPreReplacement <13>__ArenaMonsterItemDropTable_GenerateUniqueDropsPreReplacement;

			public static hook_EndRound <14>__ArenaMissionController_EndRound;

			public static hook_FireRecycle <15>__EquipmentSlot_FireRecycle;
		}

		private static ConfigFile _config;

		public static void Init(ConfigFile config)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0036: 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_0041: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Expected O, but got Unknown
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Expected O, but got Unknown
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Expected O, but got Unknown
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Expected O, but got Unknown
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Expected O, but got Unknown
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Expected O, but got Unknown
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Expected O, but got Unknown
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Expected O, but got Unknown
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Expected O, but got Unknown
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Expected O, but got Unknown
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Expected O, but got Unknown
			_config = config;
			object obj = <>O.<0>__ItemCatalog_Init;
			if (obj == null)
			{
				hook_Init val = ItemCatalog_Init;
				<>O.<0>__ItemCatalog_Init = val;
				obj = (object)val;
			}
			ItemCatalog.Init += (hook_Init)obj;
			object obj2 = <>O.<1>__ChestBehavior_Roll;
			if (obj2 == null)
			{
				hook_Roll val2 = ChestBehavior_Roll;
				<>O.<1>__ChestBehavior_Roll = val2;
				obj2 = (object)val2;
			}
			ChestBehavior.Roll += (hook_Roll)obj2;
			object obj3 = <>O.<2>__ShopTerminalBehavior_GenerateNewPickupServer_bool;
			if (obj3 == null)
			{
				hook_GenerateNewPickupServer_bool val3 = ShopTerminalBehavior_GenerateNewPickupServer_bool;
				<>O.<2>__ShopTerminalBehavior_GenerateNewPickupServer_bool = val3;
				obj3 = (object)val3;
			}
			ShopTerminalBehavior.GenerateNewPickupServer_bool += (hook_GenerateNewPickupServer_bool)obj3;
			object obj4 = <>O.<3>__RouletteChestController_GenerateEntriesServer;
			if (obj4 == null)
			{
				hook_GenerateEntriesServer val4 = RouletteChestController_GenerateEntriesServer;
				<>O.<3>__RouletteChestController_GenerateEntriesServer = val4;
				obj4 = (object)val4;
			}
			RouletteChestController.GenerateEntriesServer += (hook_GenerateEntriesServer)obj4;
			object obj5 = <>O.<4>__ShrineChanceBehavior_AddShrineStack;
			if (obj5 == null)
			{
				hook_AddShrineStack val5 = ShrineChanceBehavior_AddShrineStack;
				<>O.<4>__ShrineChanceBehavior_AddShrineStack = val5;
				obj5 = (object)val5;
			}
			ShrineChanceBehavior.AddShrineStack += (hook_AddShrineStack)obj5;
			object obj6 = <>O.<5>__FreeChestDropTable_GenerateDropPreReplacement;
			if (obj6 == null)
			{
				hook_GenerateDropPreReplacement val6 = FreeChestDropTable_GenerateDropPreReplacement;
				<>O.<5>__FreeChestDropTable_GenerateDropPreReplacement = val6;
				obj6 = (object)val6;
			}
			FreeChestDropTable.GenerateDropPreReplacement += (hook_GenerateDropPreReplacement)obj6;
			object obj7 = <>O.<6>__OptionChestBehavior_Roll;
			if (obj7 == null)
			{
				hook_Roll val7 = OptionChestBehavior_Roll;
				<>O.<6>__OptionChestBehavior_Roll = val7;
				obj7 = (object)val7;
			}
			OptionChestBehavior.Roll += (hook_Roll)obj7;
			object obj8 = <>O.<7>__BossGroup_DropRewards;
			if (obj8 == null)
			{
				hook_DropRewards val8 = BossGroup_DropRewards;
				<>O.<7>__BossGroup_DropRewards = val8;
				obj8 = (object)val8;
			}
			BossGroup.DropRewards += (hook_DropRewards)obj8;
			object obj9 = <>O.<8>__Opening_FixedUpdate;
			if (obj9 == null)
			{
				hook_FixedUpdate val9 = Opening_FixedUpdate;
				<>O.<8>__Opening_FixedUpdate = val9;
				obj9 = (object)val9;
			}
			Opening.FixedUpdate += (hook_FixedUpdate)obj9;
			object obj10 = <>O.<9>__ChestBehavior_RollItem;
			if (obj10 == null)
			{
				hook_RollItem val10 = ChestBehavior_RollItem;
				<>O.<9>__ChestBehavior_RollItem = val10;
				obj10 = (object)val10;
			}
			ChestBehavior.RollItem += (hook_RollItem)obj10;
			object obj11 = <>O.<10>__DoppelgangerDropTable_GenerateDropPreReplacement;
			if (obj11 == null)
			{
				hook_GenerateDropPreReplacement val11 = DoppelgangerDropTable_GenerateDropPreReplacement;
				<>O.<10>__DoppelgangerDropTable_GenerateDropPreReplacement = val11;
				obj11 = (object)val11;
			}
			DoppelgangerDropTable.GenerateDropPreReplacement += (hook_GenerateDropPreReplacement)obj11;
			object obj12 = <>O.<11>__SacrificeArtifactManager_OnServerCharacterDeath;
			if (obj12 == null)
			{
				hook_OnServerCharacterDeath val12 = SacrificeArtifactManager_OnServerCharacterDeath;
				<>O.<11>__SacrificeArtifactManager_OnServerCharacterDeath = val12;
				obj12 = (object)val12;
			}
			SacrificeArtifactManager.OnServerCharacterDeath += (hook_OnServerCharacterDeath)obj12;
			object obj13 = <>O.<12>__InfiniteTowerWaveController_DropRewards;
			if (obj13 == null)
			{
				hook_DropRewards val13 = InfiniteTowerWaveController_DropRewards;
				<>O.<12>__InfiniteTowerWaveController_DropRewards = val13;
				obj13 = (object)val13;
			}
			InfiniteTowerWaveController.DropRewards += (hook_DropRewards)obj13;
			object obj14 = <>O.<13>__ArenaMonsterItemDropTable_GenerateUniqueDropsPreReplacement;
			if (obj14 == null)
			{
				hook_GenerateUniqueDropsPreReplacement val14 = ArenaMonsterItemDropTable_GenerateUniqueDropsPreReplacement;
				<>O.<13>__ArenaMonsterItemDropTable_GenerateUniqueDropsPreReplacement = val14;
				obj14 = (object)val14;
			}
			ArenaMonsterItemDropTable.GenerateUniqueDropsPreReplacement += (hook_GenerateUniqueDropsPreReplacement)obj14;
			object obj15 = <>O.<14>__ArenaMissionController_EndRound;
			if (obj15 == null)
			{
				hook_EndRound val15 = ArenaMissionController_EndRound;
				<>O.<14>__ArenaMissionController_EndRound = val15;
				obj15 = (object)val15;
			}
			ArenaMissionController.EndRound += (hook_EndRound)obj15;
			object obj16 = <>O.<15>__EquipmentSlot_FireRecycle;
			if (obj16 == null)
			{
				hook_FireRecycle val16 = EquipmentSlot_FireRecycle;
				<>O.<15>__EquipmentSlot_FireRecycle = val16;
				obj16 = (object)val16;
			}
			EquipmentSlot.FireRecycle += (hook_FireRecycle)obj16;
		}

		private static void ItemCatalog_Init(orig_Init orig)
		{
			orig.Invoke();
			ItemLuckPlugin.TierList = TierList.Create(_config);
			UpdatableOptions.UpdateDescriptions();
		}

		private static void ChestBehavior_Roll(orig_Roll orig, ChestBehavior self)
		{
			if (ItemLuckPlugin.UpdateLuckEnabled && Object.op_Implicit((Object)(object)self.dropTable))
			{
				using (ReplaceDropTable(self.dropTable, "ChestBehavior_Roll"))
				{
					orig.Invoke(self);
					return;
				}
			}
			orig.Invoke(self);
		}

		private static void ShopTerminalBehavior_GenerateNewPickupServer_bool(orig_GenerateNewPickupServer_bool orig, ShopTerminalBehavior self, bool newHidden)
		{
			if (ItemLuckPlugin.UpdateLuckEnabled)
			{
				using (ReplaceDropTable(self.dropTable, "ShopTerminalBehavior_GenerateNewPickupServer_bool"))
				{
					orig.Invoke(self, newHidden);
					return;
				}
			}
			orig.Invoke(self, newHidden);
		}

		private static void RouletteChestController_GenerateEntriesServer(orig_GenerateEntriesServer orig, RouletteChestController self, FixedTimeStamp startTime)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			if (ItemLuckPlugin.UpdateLuckEnabled)
			{
				using (ReplaceDropTable(self.dropTable, "RouletteChestController_GenerateEntriesServer"))
				{
					orig.Invoke(self, startTime);
					return;
				}
			}
			orig.Invoke(self, startTime);
		}

		private static void ShrineChanceBehavior_AddShrineStack(orig_AddShrineStack orig, ShrineChanceBehavior self, Interactor activator)
		{
			if (ItemLuckPlugin.UpdateLuckEnabled)
			{
				using (ReplaceDropTable(self.dropTable, "ShrineChanceBehavior_AddShrineStack"))
				{
					orig.Invoke(self, activator);
					return;
				}
			}
			orig.Invoke(self, activator);
		}

		private static void BossGroup_DropRewards(orig_DropRewards orig, BossGroup self)
		{
			if (ItemLuckPlugin.UpdateLuckEnabled)
			{
				using (CompositeDisposable compositeDisposable = new CompositeDisposable())
				{
					if (Object.op_Implicit((Object)(object)self.dropTable))
					{
						compositeDisposable.Add(ReplaceDropTable(self.dropTable, "BossGroup_DropRewards"));
					}
					else
					{
						Log.Info("dropTable is " + (((object)self.dropTable)?.GetType().Name ?? "null"));
					}
					foreach (PickupDropTable item in self.bossDropTables.Distinct())
					{
						compositeDisposable.Add(ReplaceDropTable(item, "BossGroup_DropRewards"));
					}
					orig.Invoke(self);
					return;
				}
			}
			orig.Invoke(self);
		}

		private static void Opening_FixedUpdate(orig_FixedUpdate orig, Opening self)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_0060: 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)
			if (ItemLuckPlugin.UpdateLuckEnabled)
			{
				ChestBehavior component = ((EntityState)self).GetComponent<ChestBehavior>();
				BasicPickupDropTable dropTable = (BasicPickupDropTable)component.dropTable;
				using (CreateSelectorCopy(dropTable.selector, delegate(WeightedSelection<PickupIndex> x)
				{
					dropTable.selector = x;
				}))
				{
					dropTable.selector.Clear();
					List<PickupIndex> list = new List<PickupIndex> { PickupCatalog.FindPickupIndex(MiscPickups.LunarCoin.miscPickupIndex) };
					dropTable.Add(Run.instance.availableTier1DropList, component.tier1Chance / (float)Run.instance.availableTier1DropList.Count);
					dropTable.Add(Run.instance.availableTier2DropList, component.tier2Chance / (float)Run.instance.availableTier2DropList.Count);
					dropTable.Add(Run.instance.availableTier3DropList, component.tier3Chance / (float)Run.instance.availableTier3DropList.Count);
					dropTable.Add(Run.instance.availableLunarCombinedDropList, component.lunarChance / (float)Run.instance.availableLunarCombinedDropList.Count);
					dropTable.Add(list, component.lunarCoinChance);
					using (ReplaceDropTable((PickupDropTable)(object)dropTable, "Opening_FixedUpdate"))
					{
						orig.Invoke(self);
						return;
					}
				}
			}
			orig.Invoke(self);
		}

		private static void ChestBehavior_RollItem(orig_RollItem orig, ChestBehavior self)
		{
			if (ItemLuckPlugin.UpdateLuckEnabled)
			{
				self.Roll();
			}
			else
			{
				orig.Invoke(self);
			}
		}

		private static PickupIndex FreeChestDropTable_GenerateDropPreReplacement(orig_GenerateDropPreReplacement orig, FreeChestDropTable self, Xoroshiro128Plus rng)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			if (ItemLuckPlugin.UpdateLuckEnabled)
			{
				orig.Invoke(self, rng);
				using (ReplaceDropTable((PickupDropTable)(object)self, "FreeChestDropTable_GenerateDropPreReplacement"))
				{
					return PickupDropTable.GenerateDropFromWeightedSelection(rng, self.selector);
				}
			}
			return orig.Invoke(self, rng);
		}

		private static PickupIndex DoppelgangerDropTable_GenerateDropPreReplacement(orig_GenerateDropPreReplacement orig, DoppelgangerDropTable self, Xoroshiro128Plus rng)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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)
			if (ItemLuckPlugin.UpdateLuckEnabled)
			{
				using (ReplaceDropTable((PickupDropTable)(object)self, "DoppelgangerDropTable_GenerateDropPreReplacement"))
				{
					return orig.Invoke(self, rng);
				}
			}
			return orig.Invoke(self, rng);
		}

		private static void SacrificeArtifactManager_OnServerCharacterDeath(orig_OnServerCharacterDeath orig, DamageReport damageReport)
		{
			if (ItemLuckPlugin.UpdateLuckEnabled)
			{
				using (ReplaceDropTable(SacrificeArtifactManager.dropTable, "SacrificeArtifactManager_OnServerCharacterDeath"))
				{
					orig.Invoke(damageReport);
					return;
				}
			}
			orig.Invoke(damageReport);
		}

		private static void OptionChestBehavior_Roll(orig_Roll orig, OptionChestBehavior self)
		{
			if (ItemLuckPlugin.UpdateLuckEnabled)
			{
				using (ReplaceDropTable(self.dropTable, "OptionChestBehavior_Roll"))
				{
					orig.Invoke(self);
					return;
				}
			}
			orig.Invoke(self);
		}

		private static void InfiniteTowerWaveController_DropRewards(orig_DropRewards orig, InfiniteTowerWaveController self)
		{
			if (ItemLuckPlugin.UpdateLuckEnabled)
			{
				using (ReplaceDropTable(self.rewardDropTable, "InfiniteTowerWaveController_DropRewards"))
				{
					orig.Invoke(self);
					return;
				}
			}
			orig.Invoke(self);
		}

		private static PickupIndex[] ArenaMonsterItemDropTable_GenerateUniqueDropsPreReplacement(orig_GenerateUniqueDropsPreReplacement orig, ArenaMonsterItemDropTable self, int maxDrops, Xoroshiro128Plus rng)
		{
			if (ItemLuckPlugin.UpdateLuckEnabled)
			{
				using (ReplaceDropTable((PickupDropTable)(object)self, "ArenaMonsterItemDropTable_GenerateUniqueDropsPreReplacement"))
				{
					return orig.Invoke(self, maxDrops, rng);
				}
			}
			return orig.Invoke(self, maxDrops, rng);
		}

		private static void ArenaMissionController_EndRound(orig_EndRound orig, ArenaMissionController self)
		{
			if (ItemLuckPlugin.UpdateLuckEnabled)
			{
				using (CompositeDisposable compositeDisposable = new CompositeDisposable())
				{
					PickupDropTable[] playerRewardOrder = self.playerRewardOrder;
					foreach (PickupDropTable dropTable in playerRewardOrder)
					{
						compositeDisposable.Add(ReplaceDropTable(dropTable, "ArenaMissionController_EndRound"));
					}
					orig.Invoke(self);
					return;
				}
			}
			orig.Invoke(self);
		}

		private static bool EquipmentSlot_FireRecycle(orig_FireRecycle orig, EquipmentSlot self)
		{
			//IL_001b: 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)
			//IL_004b: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			if (!ItemLuckPlugin.UpdateLuckEnabled)
			{
				return orig.Invoke(self);
			}
			self.UpdateTargets(Equipment.Recycle.equipmentIndex, false);
			GenericPickupController pickupController = self.currentTarget.pickupController;
			if (!Object.op_Implicit((Object)(object)pickupController) || pickupController.Recycled)
			{
				return false;
			}
			PickupIndex initialPickupIndex = pickupController.pickupIndex;
			self.subcooldownTimer = 0.2f;
			List<PickupIndex> list = (from pickupIndex in PickupTransmutationManager.GetAvailableGroupFromPickupIndex(pickupController.pickupIndex)
				where pickupIndex != initialPickupIndex
				select pickupIndex).ToList();
			if (list == null || list.Count == 0)
			{
				return false;
			}
			WeightedSelection<PickupIndex> val = new WeightedSelection<PickupIndex>(list.Count);
			foreach (PickupIndex item in list)
			{
				val.AddChoice(item, 1f);
			}
			ReplaceSelector(val, "EquipmentSlot_FireRecycle", null);
			pickupController.NetworkpickupIndex = val.Evaluate(Run.instance.treasureRng.nextNormalizedFloat);
			EffectManager.SimpleEffect(LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/OmniEffect/OmniRecycleEffect"), ((Component)pickupController.pickupDisplay).transform.position, Quaternion.identity, true);
			pickupController.NetworkRecycled = true;
			self.InvalidateCurrentTarget();
			return true;
		}

		private static IDisposable ReplaceDropTable(PickupDropTable dropTable, string caller)
		{
			BasicPickupDropTable basicDropTable = (BasicPickupDropTable)(object)((dropTable is BasicPickupDropTable) ? dropTable : null);
			if (basicDropTable != null)
			{
				IDisposable result = CreateSelectorCopy(basicDropTable.selector, delegate(WeightedSelection<PickupIndex> x)
				{
					basicDropTable.selector = x;
				});
				ReplaceSelector(basicDropTable.selector, caller, dropTable);
				return result;
			}
			ExplicitPickupDropTable explicitDropTable = (ExplicitPickupDropTable)(object)((dropTable is ExplicitPickupDropTable) ? dropTable : null);
			if (explicitDropTable != null)
			{
				IDisposable result2 = CreateSelectorCopy(explicitDropTable.weightedSelection, delegate(WeightedSelection<PickupIndex> x)
				{
					explicitDropTable.weightedSelection = x;
				});
				ReplaceSelector(explicitDropTable.weightedSelection, caller, dropTable);
				return result2;
			}
			FreeChestDropTable freeChestDropTable = (FreeChestDropTable)(object)((dropTable is FreeChestDropTable) ? dropTable : null);
			if (freeChestDropTable != null)
			{
				IDisposable result3 = CreateSelectorCopy(freeChestDropTable.selector, delegate(WeightedSelection<PickupIndex> x)
				{
					freeChestDropTable.selector = x;
				});
				ReplaceSelector(freeChestDropTable.selector, caller, dropTable);
				return result3;
			}
			DoppelgangerDropTable doppelgangerDropTable = (DoppelgangerDropTable)(object)((dropTable is DoppelgangerDropTable) ? dropTable : null);
			if (doppelgangerDropTable != null)
			{
				IDisposable result4 = CreateSelectorCopy(doppelgangerDropTable.selector, delegate(WeightedSelection<PickupIndex> x)
				{
					doppelgangerDropTable.selector = x;
				});
				ReplaceSelector(doppelgangerDropTable.selector, caller, dropTable);
				return result4;
			}
			ArenaMonsterItemDropTable arenaMonsterItemDropTable = (ArenaMonsterItemDropTable)(object)((dropTable is ArenaMonsterItemDropTable) ? dropTable : null);
			if (arenaMonsterItemDropTable != null)
			{
				IDisposable result5 = CreateSelectorCopy(arenaMonsterItemDropTable.selector, delegate(WeightedSelection<PickupIndex> x)
				{
					arenaMonsterItemDropTable.selector = x;
				});
				ReplaceSelector(arenaMonsterItemDropTable.selector, caller, dropTable);
				return result5;
			}
			Log.Warning("Failed to override " + caller + " dropTable");
			Log.Warning(caller + " dropTable is of type " + (((object)dropTable)?.GetType().FullName ?? "null"));
			return Disposable.Empty;
		}

		private static void ReplaceSelector(WeightedSelection<PickupIndex> selector, string caller, PickupDropTable dropTable)
		{
			//IL_0026: 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)
			for (int i = 0; i < selector.Count; i++)
			{
				ref ChoiceInfo<PickupIndex> reference = ref selector.choices[i];
				float weight = reference.weight;
				float num = (ItemLuckPlugin.TierList.GetTier(((PickupIndex)(ref reference.value)).itemIndex) ?? ItemLuckPlugin.TierList.GetTier(((PickupIndex)(ref reference.value)).equipmentIndex) ?? Tier.Unspecified).ApplyItemLuck(reference.weight);
				selector.ModifyChoiceWeight(i, num);
				Log.Debug($"{Language.GetString(((PickupIndex)(ref reference.value)).pickupDef.nameToken)} weight changed from {weight} to {num}");
			}
			Log.Debug(caller + " " + ((object)dropTable)?.GetType()?.Name + " (" + ((dropTable != null) ? ((Object)dropTable).name : null) + ") replaced");
		}

		private static IDisposable CreateSelectorCopy(WeightedSelection<PickupIndex> selector, Action<WeightedSelection<PickupIndex>> setSelector)
		{
			WeightedSelection<PickupIndex> oldSelector = selector;
			setSelector(new WeightedSelection<PickupIndex>(8)
			{
				Capacity = selector.Capacity,
				choices = selector.choices.ToArray(),
				totalWeight = selector.totalWeight,
				Count = selector.Count
			});
			return new Disposable(delegate
			{
				setSelector(oldSelector);
			});
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("Lawlzee.ItemLuck", "ItemLuck", "1.0.1")]
	public class ItemLuckPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "Lawlzee.ItemLuck";

		public const string PluginAuthor = "Lawlzee";

		public const string PluginName = "ItemLuck";

		public const string PluginVersion = "1.0.1";

		public static ConfigEntry<bool> ModEnabled;

		public static ConfigEntry<float> ItemLuck;

		public static TierList TierList;

		public static bool UpdateLuckEnabled
		{
			get
			{
				if (ModEnabled.Value)
				{
					return ItemLuck.Value != 0f;
				}
				return false;
			}
		}

		public void Awake()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			Log.Init(((BaseUnityPlugin)this).Logger);
			ModEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Configuration", "Mod enabled", true, "Mod enabled");
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(ModEnabled));
			ItemLuck = ((BaseUnityPlugin)this).Config.Bind<float>("Configuration", "Item luck", 2f, "Controls the item luck");
			UpdatableStepSliderOption option = new UpdatableStepSliderOption(ItemLuck, new StepSliderConfig
			{
				min = -8f,
				max = 8f,
				increment = 0.05f,
				formatString = "{0:+0.##;-0.##;0.##}"
			});
			ModSettingsManager.AddOption((BaseOption)(object)option);
			ItemLuck.SettingChanged += delegate
			{
				UpdatableOptions.UpdateDescriptions();
				option.UpdatePanel();
			};
			Texture2D val = LoadTexture("icon.png");
			ModSettingsManager.SetModIcon(Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0f, 0f)));
			Hooks.Init(((BaseUnityPlugin)this).Config);
		}

		private Texture2D LoadTexture(string name)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_002a: Expected O, but got Unknown
			Texture2D val = new Texture2D(2, 2);
			ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), name)));
			return val;
		}
	}
	public static class ItemTierExtensions
	{
		public static string GetShortName(this ItemTier itemTier)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected I4, but got Unknown
			return (int)itemTier switch
			{
				0 => "White items", 
				1 => "Green items", 
				2 => "Red items", 
				3 => "Lunar items", 
				4 => "Boss items", 
				6 => "Void items", 
				7 => "Void items", 
				8 => "Void items", 
				9 => "Void items", 
				_ => "Other items", 
			};
		}

		public static string GetFullName(this ItemTier itemTier)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected I4, but got Unknown
			return (int)itemTier switch
			{
				0 => "White items", 
				1 => "Green items", 
				2 => "Red items", 
				3 => "Lunar items", 
				4 => "Boss items", 
				6 => "Void white items", 
				7 => "Void green items", 
				8 => "Void red items", 
				9 => "Void boss items", 
				_ => "Other items", 
			};
		}
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	public enum Tier
	{
		S,
		A,
		B,
		C,
		D,
		F,
		Unspecified
	}
	public static class TierExtensions
	{
		public static float ToMultiplier(this Tier tier)
		{
			return tier switch
			{
				Tier.S => 1f, 
				Tier.A => 0.6f, 
				Tier.B => 0.2f, 
				Tier.C => -0.2f, 
				Tier.D => -0.6f, 
				Tier.F => -1f, 
				_ => 0f, 
			};
		}

		public static float ApplyItemLuck(this Tier itemTier, float currentWeigth)
		{
			float num = itemTier.ToMultiplier();
			return 2f * currentWeigth / (1f + Mathf.Exp(num * ItemLuckPlugin.ItemLuck.Value * -0.8f));
		}
	}
	public class Rank<T>
	{
		public T Def { get; }

		public Tier Tier { get; }

		public Rank(T index, Tier tier)
		{
			Def = index;
			Tier = tier;
		}
	}
}