Decompiled source of TooManyItems v0.6.17

plugins/TooManyItems.dll

Decompiled 21 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
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.Threading.Tasks;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HG;
using LookingGlass.ItemStatsNameSpace;
using Microsoft.CodeAnalysis;
using On.RoR2;
using On.RoR2.Items;
using On.RoR2.UI.LogBook;
using ProperSave;
using R2API;
using R2API.Networking;
using R2API.Networking.Interfaces;
using R2API.Utils;
using RoR2;
using RoR2.ExpansionManagement;
using RoR2.Orbs;
using RoR2.UI.LogBook;
using TMPro;
using TooManyItems.Extensions;
using TooManyItems.Handlers;
using TooManyItems.Items.Equip;
using TooManyItems.Items.Equip.Lunar;
using TooManyItems.Items.Lunar;
using TooManyItems.Items.Tier1;
using TooManyItems.Items.Tier2;
using TooManyItems.Items.Tier3;
using TooManyItems.Items.Void;
using TooManyItems.Managers;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.UI;

[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("TooManyItems")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+1e9e3faac7b0eca9df496daba1d713ba287ee5eb")]
[assembly: AssemblyProduct("TooManyItems")]
[assembly: AssemblyTitle("TooManyItems")]
[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;
		}
	}
}
namespace TooManyItems
{
	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);
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("shirograhm.TooManyItems", "TooManyItems", "0.6.17")]
	public class TooManyItems : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_Init <>9__12_0;

			internal void <InjectVoidItemTramsforms>b__12_0(orig_Init orig)
			{
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Unknown result type (might be due to invalid IL or missing references)
				//IL_0051: 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_0099: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
				List<Pair> list = new List<Pair>();
				if ((bool)RedBlueGlasses.isEnabled)
				{
					list.Add(new Pair
					{
						itemDef1 = RedBlueGlasses.itemDef,
						itemDef2 = Items.CritGlassesVoid
					});
				}
				if ((bool)Thumbtack.isEnabled)
				{
					list.Add(new Pair
					{
						itemDef1 = Thumbtack.itemDef,
						itemDef2 = Items.BleedOnHitVoid
					});
				}
				if ((bool)IronHeart.isEnabled && (bool)VoidHeart.isEnabled)
				{
					list.Add(new Pair
					{
						itemDef1 = IronHeart.itemDef,
						itemDef2 = VoidHeart.itemDef
					});
				}
				if ((bool)HereticSeal.isEnabled && (bool)ShadowCrest.isEnabled)
				{
					list.Add(new Pair
					{
						itemDef1 = HereticSeal.itemDef,
						itemDef2 = ShadowCrest.itemDef
					});
				}
				ItemRelationshipType contagiousItem = ItemRelationshipTypes.ContagiousItem;
				Debug.Log((object)contagiousItem);
				Pair[] first = ItemCatalog.itemRelationships[ItemRelationshipTypes.ContagiousItem];
				ItemCatalog.itemRelationships[ItemRelationshipTypes.ContagiousItem] = first.Union(list).ToArray();
				Debug.Log((object)"Injected void item transformations.");
				orig.Invoke();
			}
		}

		public const string PluginGUID = "shirograhm.TooManyItems";

		public const string PluginAuthor = "shirograhm";

		public const string PluginName = "TooManyItems";

		public const string PluginVersion = "0.6.17";

		public static Random RandGen = new Random();

		public static ExpansionDef sotvDLC;

		public static ExpansionDef sotsDLC;

		public static PluginInfo PInfo { get; private set; }

		public void Awake()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			PInfo = ((BaseUnityPlugin)this).Info;
			sotvDLC = Addressables.LoadAssetAsync<ExpansionDef>((object)"RoR2/DLC1/Common/DLC1.asset").WaitForCompletion();
			sotsDLC = Addressables.LoadAssetAsync<ExpansionDef>((object)"RoR2/DLC2/Common/DLC2.asset").WaitForCompletion();
			Log.Init(((BaseUnityPlugin)this).Logger);
			AssetManager.Init();
			GameEventManager.Init();
			ConfigOptions.Init();
			DamageColorManager.Init();
			Utilities.Init();
			if (Abacus.isEnabled.Value)
			{
				Abacus.Init();
			}
			if (BloodDice.isEnabled.Value)
			{
				BloodDice.Init();
			}
			if (GlassMarbles.isEnabled.Value)
			{
				GlassMarbles.Init();
			}
			if (Horseshoe.isEnabled.Value)
			{
				Horseshoe.Init();
			}
			if (IronHeart.isEnabled.Value)
			{
				IronHeart.Init();
			}
			if (Permafrost.isEnabled.Value)
			{
				Permafrost.Init();
			}
			if (RustedTrowel.isEnabled.Value)
			{
				RustedTrowel.Init();
			}
			if (BrassKnuckles.isEnabled.Value)
			{
				BrassKnuckles.Init();
			}
			if (BrokenMask.isEnabled.Value)
			{
				BrokenMask.Init();
			}
			if (Epinephrine.isEnabled.Value)
			{
				Epinephrine.Init();
			}
			if (HereticSeal.isEnabled.Value)
			{
				HereticSeal.Init();
			}
			if (HolyWater.isEnabled.Value)
			{
				HolyWater.Init();
			}
			if (Hoodie.isEnabled.Value)
			{
				Hoodie.Init();
			}
			if (MagnifyingGlass.isEnabled.Value)
			{
				MagnifyingGlass.Init();
			}
			if (SoulRing.isEnabled.Value)
			{
				SoulRing.Init();
			}
			if (BottleCap.isEnabled.Value)
			{
				BottleCap.Init();
			}
			if (BreadLoaf.isEnabled.Value)
			{
				BreadLoaf.Init();
			}
			if (DebitCard.isEnabled.Value)
			{
				DebitCard.Init();
			}
			if (EdibleGlue.isEnabled.Value)
			{
				EdibleGlue.Init();
			}
			if (MilkCarton.isEnabled.Value)
			{
				MilkCarton.Init();
			}
			if (PaperPlane.isEnabled.Value)
			{
				PaperPlane.Init();
			}
			if (Photodiode.isEnabled.Value)
			{
				Photodiode.Init();
			}
			if (PropellerHat.isEnabled.Value)
			{
				PropellerHat.Init();
			}
			if (RedBlueGlasses.isEnabled.Value)
			{
				RedBlueGlasses.Init();
			}
			if (RubberDucky.isEnabled.Value)
			{
				RubberDucky.Init();
			}
			if ((bool)Thumbtack.isEnabled)
			{
				Thumbtack.Init();
			}
			if (Amnesia.isEnabled.Value)
			{
				Amnesia.Init();
			}
			if (AncientCoin.isEnabled.Value)
			{
				AncientCoin.Init();
			}
			if (CarvingBlade.isEnabled.Value)
			{
				CarvingBlade.Init();
			}
			if (Crucifix.isEnabled.Value)
			{
				Crucifix.Init();
			}
			if (SpiritStone.isEnabled.Value)
			{
				SpiritStone.Init();
			}
			if (DoubleDown.isEnabled.Value)
			{
				DoubleDown.Init();
			}
			if (ShadowCrest.isEnabled.Value)
			{
				ShadowCrest.Init();
			}
			if (VoidHeart.isEnabled.Value)
			{
				VoidHeart.Init();
			}
			if (BuffTotem.isEnabled.Value)
			{
				BuffTotem.Init();
			}
			if (TatteredScroll.isEnabled.Value)
			{
				TatteredScroll.Init();
			}
			if (Chalice.isEnabled.Value)
			{
				Chalice.Init();
			}
			if (Vanity.isEnabled.Value)
			{
				Vanity.Init();
			}
			((ResourceAvailability)(ref ItemCatalog.availability)).CallWhenAvailable((Action)Integrations.Init);
			((ResourceAvailability)(ref ItemCatalog.availability)).CallWhenAvailable((Action)InjectVoidItemTramsforms);
			Log.Message("Finished initializations.");
		}

		private void InjectVoidItemTramsforms()
		{
			//IL_0015: 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)
			//IL_0020: Expected O, but got Unknown
			object obj = <>c.<>9__12_0;
			if (obj == null)
			{
				hook_Init val = delegate(orig_Init orig)
				{
					//IL_0018: Unknown result type (might be due to invalid IL or missing references)
					//IL_0036: Unknown result type (might be due to invalid IL or missing references)
					//IL_0051: 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_0099: Unknown result type (might be due to invalid IL or missing references)
					//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
					//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
					//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
					List<Pair> list = new List<Pair>();
					if ((bool)RedBlueGlasses.isEnabled)
					{
						list.Add(new Pair
						{
							itemDef1 = RedBlueGlasses.itemDef,
							itemDef2 = Items.CritGlassesVoid
						});
					}
					if ((bool)Thumbtack.isEnabled)
					{
						list.Add(new Pair
						{
							itemDef1 = Thumbtack.itemDef,
							itemDef2 = Items.BleedOnHitVoid
						});
					}
					if ((bool)IronHeart.isEnabled && (bool)VoidHeart.isEnabled)
					{
						list.Add(new Pair
						{
							itemDef1 = IronHeart.itemDef,
							itemDef2 = VoidHeart.itemDef
						});
					}
					if ((bool)HereticSeal.isEnabled && (bool)ShadowCrest.isEnabled)
					{
						list.Add(new Pair
						{
							itemDef1 = HereticSeal.itemDef,
							itemDef2 = ShadowCrest.itemDef
						});
					}
					ItemRelationshipType contagiousItem = ItemRelationshipTypes.ContagiousItem;
					Debug.Log((object)contagiousItem);
					Pair[] first = ItemCatalog.itemRelationships[ItemRelationshipTypes.ContagiousItem];
					ItemCatalog.itemRelationships[ItemRelationshipTypes.ContagiousItem] = first.Union(list).ToArray();
					Debug.Log((object)"Injected void item transformations.");
					orig.Invoke();
				};
				<>c.<>9__12_0 = val;
				obj = (object)val;
			}
			ContagiousItemManager.Init += (hook_Init)obj;
		}
	}
	public static class Utilities
	{
		private class SyncForceRecalculate : INetMessage, ISerializableObject
		{
			private NetworkInstanceId netID;

			public SyncForceRecalculate()
			{
			}

			public SyncForceRecalculate(NetworkInstanceId ID)
			{
				//IL_0009: 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)
				netID = ID;
			}

			public void Deserialize(NetworkReader reader)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				netID = reader.ReadNetworkId();
			}

			public void OnReceived()
			{
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				if (NetworkServer.active)
				{
					return;
				}
				GameObject val = Util.FindNetworkObject(netID);
				if (Object.op_Implicit((Object)(object)val))
				{
					CharacterBody component = val.GetComponent<CharacterBody>();
					if (Object.op_Implicit((Object)(object)component))
					{
						component.RecalculateStats();
					}
				}
			}

			public void Serialize(NetworkWriter writer)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				writer.Write(netID);
				writer.FinishMessage();
			}
		}

		public static Color BROKEN_MASK_COLOR = new Color(0.38f, 0.38f, 0.82f, 1f);

		public static Color CARVING_BLADE_COLOR = new Color(0.09f, 0.67f, 0.62f, 1f);

		public static Color PERMAFROST_COLOR = new Color(0.76f, 0.8f, 0.98f, 1f);

		public static Color IRON_HEART_COLOR = new Color(0.44f, 0.44f, 0.44f, 1f);

		public static Color TATTERED_SCROLL_COLOR = new Color(0.8f, 0.78f, 0.57f, 1f);

		public static Color VANITY_COLOR = new Color(0.53f, 0.44f, 0.77f, 1f);

		public static List<ItemIndex> allVoidTier1Items;

		public static List<ItemIndex> allVoidTier2Items;

		public static List<ItemIndex> allVoidTier3Items;

		public static List<ItemIndex> allBossItems;

		internal static void Init()
		{
			NetworkingAPI.RegisterMessageType<SyncForceRecalculate>();
			((ResourceAvailability)(ref ItemCatalog.availability)).CallWhenAvailable((Action)InitVoidTierItemLists);
		}

		private static void InitVoidTierItemLists()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			allVoidTier1Items = (from itemDef in (IEnumerable<ItemDef>)(object)ItemCatalog.allItemDefs
				where (int)itemDef.tier == 6
				select itemDef.itemIndex).ToList();
			allVoidTier2Items = (from itemDef in (IEnumerable<ItemDef>)(object)ItemCatalog.allItemDefs
				where (int)itemDef.tier == 7
				select itemDef.itemIndex).ToList();
			allVoidTier3Items = (from itemDef in (IEnumerable<ItemDef>)(object)ItemCatalog.allItemDefs
				where (int)itemDef.tier == 8
				select itemDef.itemIndex).ToList();
			allBossItems = (from itemDef in (IEnumerable<ItemDef>)(object)ItemCatalog.allItemDefs
				where (int)itemDef.tier == 4
				select itemDef.itemIndex).ToList();
		}

		public static void ForceRecalculate(CharacterBody body)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)body == (Object)null))
			{
				body.RecalculateStats();
				if (NetworkServer.active)
				{
					new SyncForceRecalculate(((NetworkBehaviour)body).netId);
				}
			}
		}

		public static void AddRecalculateOnFrameHook(ItemDef def)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			CharacterBody.FixedUpdate += (hook_FixedUpdate)delegate(orig_FixedUpdate orig, CharacterBody self)
			{
				orig.Invoke(self);
				if (Object.op_Implicit((Object)(object)self) && Object.op_Implicit((Object)(object)self.inventory))
				{
					int itemCountEffective = self.inventory.GetItemCountEffective(def);
					if (itemCountEffective > 0)
					{
						ForceRecalculate(self);
					}
				}
			};
		}

		public static CharacterBody GetMinionOwnershipParentBody(CharacterBody body)
		{
			if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.master) && Object.op_Implicit((Object)(object)body.master.minionOwnership) && Object.op_Implicit((Object)(object)body.master.minionOwnership.ownerMaster) && Object.op_Implicit((Object)(object)body.master.minionOwnership.ownerMaster.GetBody()))
			{
				return body.master.minionOwnership.ownerMaster.GetBody();
			}
			return body;
		}

		public static bool OnSameTeam(CharacterBody body1, CharacterBody body2)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)body1 == (Object)null)
			{
				throw new ArgumentNullException("body1");
			}
			if ((Object)(object)body2 == (Object)null)
			{
				throw new ArgumentNullException("body2");
			}
			return Object.op_Implicit((Object)(object)body1.teamComponent) && Object.op_Implicit((Object)(object)body2.teamComponent) && body1.teamComponent.teamIndex == body2.teamComponent.teamIndex;
		}

		public static bool IsSkillDamage(DamageInfo damageInfo)
		{
			//IL_0002: 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_0019: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			return DamageTypeCombo.op_Implicit(damageInfo.damageType) == DamageTypeCombo.op_Implicit(DamageTypeCombo.GenericPrimary) || DamageTypeCombo.op_Implicit(damageInfo.damageType) == DamageTypeCombo.op_Implicit(DamageTypeCombo.GenericSecondary) || DamageTypeCombo.op_Implicit(damageInfo.damageType) == DamageTypeCombo.op_Implicit(DamageTypeCombo.GenericUtility) || DamageTypeCombo.op_Implicit(damageInfo.damageType) == DamageTypeCombo.op_Implicit(DamageTypeCombo.GenericSpecial);
		}

		public static uint ScaleGoldWithDifficulty(int goldGranted)
		{
			return Convert.ToUInt32((float)goldGranted * (1f + 50f * GetDifficultyAsPercentage()));
		}

		public static float GetChanceAfterLuck(float percent, float luckIn)
		{
			int num = Mathf.CeilToInt(luckIn);
			if (num > 0)
			{
				return 1f - Mathf.Pow(1f - percent, (float)(num + 1));
			}
			if (num < 0)
			{
				return Mathf.Pow(percent, (float)(Mathf.Abs(num) + 1));
			}
			return percent;
		}

		public static float GetDifficultyAsPercentage()
		{
			return (Stage.instance.entryDifficultyCoefficient - 1f) / 98f;
		}

		public static float GetDifficultyAsMultiplier()
		{
			return Stage.instance.entryDifficultyCoefficient;
		}

		public static float GetLinearStacking(float baseValue, int count)
		{
			return GetLinearStacking(baseValue, baseValue, count);
		}

		public static float GetLinearStacking(float baseValue, float extraValue, int count)
		{
			return baseValue + extraValue * (float)(count - 1);
		}

		public static int GetLinearStacking(int baseValue, int count)
		{
			return GetLinearStacking(baseValue, baseValue, count);
		}

		public static int GetLinearStacking(int baseValue, int extraValue, int count)
		{
			return baseValue + extraValue * (count - 1);
		}

		public static float GetExponentialStacking(float percent, int count)
		{
			return GetExponentialStacking(percent, percent, count);
		}

		public static float GetExponentialStacking(float percent, float stackPercent, int count)
		{
			return 1f - (1f - percent) * Mathf.Pow(1f - stackPercent, (float)(count - 1));
		}

		public static float GetReverseExponentialStacking(float baseValue, float reducePercent, int count)
		{
			return baseValue * Mathf.Pow(1f - reducePercent, (float)(count - 1));
		}

		public static float GetHyperbolicStacking(float percent, int count)
		{
			return GetHyperbolicStacking(percent, percent, count);
		}

		public static float GetHyperbolicStacking(float percent, float extraPercent, int count)
		{
			float num = (1f + percent) * (1f + extraPercent * (float)(count - 1));
			return 1f - 1f / num;
		}

		public static void SpawnHealEffect(CharacterBody self)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			if (!((Object)(object)self == (Object)null) && !((Object)(object)self.transform == (Object)null))
			{
				EffectData val = new EffectData
				{
					origin = self.transform.position,
					rootObject = ((Component)self).gameObject
				};
				EffectManager.SpawnEffect(LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/MedkitHealEffect"), val, true);
			}
		}

		public static void SendGoldOrbAndEffect(uint goldGain, Vector3 origin, HurtBox target)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0030: 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)
			OrbManager.instance.AddOrb((Orb)new GoldOrb
			{
				goldAmount = goldGain,
				origin = origin,
				target = target
			});
			EffectManager.SimpleImpactEffect(LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/ImpactEffects/CoinImpact"), origin, Vector3.up, true);
		}

		public static bool IsItemIndexScrap(ItemIndex itemIndex)
		{
			//IL_0001: 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_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: 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: Unknown result type (might be due to invalid IL or missing references)
			return itemIndex == Items.ScrapWhite.itemIndex || itemIndex == Items.ScrapGreen.itemIndex || itemIndex == Items.ScrapRed.itemIndex;
		}

		public static ItemIndex GetRandomItemOfTier(ItemTier tier)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected I4, but got Unknown
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			switch ((int)tier)
			{
			case 0:
			{
				ItemIndex[] array4 = ItemCatalog.tier1ItemList.Where((ItemIndex index) => index != Items.ScrapWhite.itemIndex).ToArray();
				if (array4.Length == 0)
				{
					return (ItemIndex)(-1);
				}
				int num4 = Random.Range(0, array4.Length);
				return array4[num4];
			}
			case 1:
			{
				ItemIndex[] array3 = ItemCatalog.tier2ItemList.Where((ItemIndex index) => index != Items.ScrapGreen.itemIndex).ToArray();
				if (array3.Length == 0)
				{
					return (ItemIndex)(-1);
				}
				int num3 = Random.Range(0, array3.Length);
				return array3[num3];
			}
			case 2:
			{
				ItemIndex[] array = ItemCatalog.tier3ItemList.Where((ItemIndex index) => index != Items.ScrapRed.itemIndex).ToArray();
				if (array.Length == 0)
				{
					return (ItemIndex)(-1);
				}
				int num = Random.Range(0, array.Length);
				return array[num];
			}
			case 3:
			{
				ItemIndex[] array2 = ItemCatalog.lunarItemList.Where((ItemIndex index) => (Object)(object)Amnesia.itemDef == (Object)null || index != Amnesia.itemDef.itemIndex).ToArray();
				if (array2.Length == 0)
				{
					return (ItemIndex)(-1);
				}
				int num2 = Random.Range(0, array2.Length);
				return array2[num2];
			}
			case 6:
			{
				if (allVoidTier1Items == null || allVoidTier1Items.Count == 0)
				{
					return (ItemIndex)(-1);
				}
				int index5 = Random.Range(0, allVoidTier1Items.Count());
				return allVoidTier1Items[index5];
			}
			case 7:
			{
				if (allVoidTier2Items == null || allVoidTier2Items.Count == 0)
				{
					return (ItemIndex)(-1);
				}
				int index3 = Random.Range(0, allVoidTier2Items.Count());
				return allVoidTier2Items[index3];
			}
			case 8:
			{
				if (allVoidTier3Items == null || allVoidTier3Items.Count == 0)
				{
					return (ItemIndex)(-1);
				}
				int index4 = Random.Range(0, allVoidTier3Items.Count());
				return allVoidTier3Items[index4];
			}
			case 4:
			{
				if (allBossItems == null || allBossItems.Count == 0)
				{
					return (ItemIndex)(-1);
				}
				int index2 = Random.Range(0, allBossItems.Count());
				return allBossItems[index2];
			}
			default:
				Log.Error("Invalid tier called for random item.");
				return (ItemIndex)(-1);
			}
		}
	}
}
namespace TooManyItems.Managers
{
	public static class AssetManager
	{
		public static AssetBundle bundle;

		public const string bundleName = "tmiassets";

		public static string AssetBundlePath => Path.Combine(Path.GetDirectoryName(TooManyItems.PInfo.Location), "tmiassets");

		public static void Init()
		{
			bundle = AssetBundle.LoadFromFile(AssetBundlePath);
		}
	}
	public static class ConfigManager
	{
		public static class Scaling
		{
			public static ConfigFile config = new ConfigFile(Paths.ConfigPath + "\\TooManyItems.cfg", true);

			public static string categoryName = "TooManyItems Config";

			public static string categoryGUID = "shirograhm.TooManyItems_config";

			public static ConfigOptions.ConfigurableValue<bool> useCustomValues = ConfigOptions.ConfigurableValue.CreateBool(categoryGUID, categoryName, config, "! Important !", "Use Custom Config", defaultValue: false, "Set to true to enable custom configurations.");
		}
	}
	public class ConfigurableValue<T> : ConfigOptions.ConfigurableValue<T>
	{
		public ConfigurableValue(string section, string key, float defaultValue, string description = "", List<string> stringsToAffect = null, Action<float> onChanged = null)
			: base(ConfigManager.Scaling.config, section, key, (T)Convert.ChangeType(defaultValue, typeof(T)), description, stringsToAffect, ConfigManager.Scaling.useCustomValues.bepinexConfigEntry, restartRequired: false, (Action<T>)null)
		{
			ConfigOptions.ConfigurableValue.CreateFloat(ConfigManager.Scaling.categoryGUID, ConfigManager.Scaling.categoryName, ConfigManager.Scaling.config, section, key, defaultValue, 0f, 1000000f, description, stringsToAffect, ConfigManager.Scaling.useCustomValues.bepinexConfigEntry, restartRequired: false, onChanged);
		}

		public ConfigurableValue(string section, string key, int defaultValue, string description = "", List<string> stringsToAffect = null, Action<int> onChanged = null)
			: base(ConfigManager.Scaling.config, section, key, (T)Convert.ChangeType(defaultValue, typeof(T)), description, stringsToAffect, ConfigManager.Scaling.useCustomValues.bepinexConfigEntry, restartRequired: false, (Action<T>)null)
		{
			ConfigOptions.ConfigurableValue.CreateInt(ConfigManager.Scaling.categoryGUID, ConfigManager.Scaling.categoryName, ConfigManager.Scaling.config, section, key, defaultValue, 0, 1000000, description, stringsToAffect, ConfigManager.Scaling.useCustomValues.bepinexConfigEntry, restartRequired: false, onChanged);
		}

		public ConfigurableValue(string section, string key, bool defaultValue, string description = "", List<string> stringsToAffect = null, Action<bool> onChanged = null)
			: base(ConfigManager.Scaling.config, section, key, (T)Convert.ChangeType(defaultValue, typeof(T)), description, stringsToAffect, ConfigManager.Scaling.useCustomValues.bepinexConfigEntry, restartRequired: false, (Action<T>)null)
		{
			ConfigOptions.ConfigurableValue.CreateBool(ConfigManager.Scaling.categoryGUID, ConfigManager.Scaling.categoryName, ConfigManager.Scaling.config, section, key, defaultValue, description, stringsToAffect, ConfigManager.Scaling.useCustomValues.bepinexConfigEntry, restartRequired: false, onChanged);
		}

		public ConfigurableValue(string section, string key, string defaultValue, string description = "", List<string> stringsToAffect = null, Action<string> onChanged = null)
			: base(ConfigManager.Scaling.config, section, key, (T)Convert.ChangeType(defaultValue, typeof(T)), description, stringsToAffect, ConfigManager.Scaling.useCustomValues.bepinexConfigEntry, restartRequired: false, (Action<T>)null)
		{
			ConfigOptions.ConfigurableValue.CreateString(ConfigManager.Scaling.categoryGUID, ConfigManager.Scaling.categoryName, ConfigManager.Scaling.config, section, key, defaultValue, description, stringsToAffect, ConfigManager.Scaling.useCustomValues.bepinexConfigEntry, restartRequired: false, onChanged);
		}
	}
	public static class ConfigOptions
	{
		public abstract class ConfigurableValue
		{
			public static List<ConfigurableValue> instancesList = new List<ConfigurableValue>();

			public List<string> stringsToAffect = new List<string>();

			public string key = "";

			public string id = "";

			public static ConfigurableValue<T> Create<T>(ConfigFile configFile, string section, string key, T defaultValue, string description = "", List<string> stringsToAffect = null, ConfigEntry<bool> useCustomValueConfigEntry = null, bool restartRequired = false, Action<T> onChanged = null)
			{
				return new ConfigurableValue<T>(configFile, section, key, defaultValue, description, stringsToAffect, useCustomValueConfigEntry, restartRequired, onChanged);
			}

			public static ConfigurableValue<int> CreateInt(string modGUID, string modName, ConfigFile configFile, string section, string key, int defaultValue, int min = 0, int max = 1000, string description = "", List<string> stringsToAffect = null, ConfigEntry<bool> useCustomValueConfigEntry = null, bool restartRequired = false, Action<int> onChanged = null)
			{
				return Create(configFile, section, key, defaultValue, description, stringsToAffect, useCustomValueConfigEntry, restartRequired, onChanged);
			}

			public static ConfigurableValue<float> CreateFloat(string modGUID, string modName, ConfigFile configFile, string section, string key, float defaultValue, float min = 0f, float max = 1000f, string description = "", List<string> stringsToAffect = null, ConfigEntry<bool> useCustomValueConfigEntry = null, bool restartRequired = false, Action<float> onChanged = null)
			{
				return Create(configFile, section, key, defaultValue, description, stringsToAffect, useCustomValueConfigEntry, restartRequired, onChanged);
			}

			public static ConfigurableValue<bool> CreateBool(string modGUID, string modName, ConfigFile configFile, string section, string key, bool defaultValue, string description = "", List<string> stringsToAffect = null, ConfigEntry<bool> useCustomValueConfigEntry = null, bool restartRequired = false, Action<bool> onChanged = null)
			{
				return Create(configFile, section, key, defaultValue, description, stringsToAffect, useCustomValueConfigEntry, restartRequired, onChanged);
			}

			public static ConfigurableValue<string> CreateString(string modGUID, string modName, ConfigFile configFile, string section, string key, string defaultValue, string description = "", List<string> stringsToAffect = null, ConfigEntry<bool> useCustomValueConfigEntry = null, bool restartRequired = false, Action<string> onChanged = null)
			{
				return Create(configFile, section, key, defaultValue, description, stringsToAffect, useCustomValueConfigEntry, restartRequired, onChanged);
			}
		}

		public class ConfigurableValue<T> : ConfigurableValue
		{
			public ConfigEntry<T> bepinexConfigEntry;

			private ConfigEntry<bool> useCustomValueConfigEntry;

			private T defaultValue;

			public T Value
			{
				get
				{
					if (useCustomValueConfigEntry != null && useCustomValueConfigEntry.Value)
					{
						return bepinexConfigEntry.Value;
					}
					return defaultValue;
				}
			}

			public ConfigurableValue(ConfigFile configFile, string section, string key, T defaultValue, string description = "", List<string> stringsToAffect = null, ConfigEntry<bool> useCustomValueConfigEntry = null, bool restartRequired = false, Action<T> onChanged = null)
			{
				ConfigurableValue<T> configurableValue = this;
				id = Path.GetFileNameWithoutExtension(configFile.ConfigFilePath) + "." + section + "." + key;
				ConfigurableValue configurableValue2 = ConfigurableValue.instancesList.FirstOrDefault((ConfigurableValue x) => x.id == configurableValue.id);
				if (configurableValue2 != null)
				{
					ConfigurableValue<T> configurableValue3 = configurableValue2 as ConfigurableValue<T>;
					bepinexConfigEntry = configurableValue3.bepinexConfigEntry;
					this.useCustomValueConfigEntry = useCustomValueConfigEntry;
				}
				else
				{
					bepinexConfigEntry = configFile.Bind<T>(section, key, defaultValue, description);
					ConfigurableValue.instancesList.Add(this);
				}
				this.useCustomValueConfigEntry = useCustomValueConfigEntry;
				base.key = key;
				this.defaultValue = defaultValue;
				if (stringsToAffect != null)
				{
					base.stringsToAffect = stringsToAffect;
				}
				else
				{
					base.stringsToAffect = new List<string>();
				}
				if (onChanged != null)
				{
					bepinexConfigEntry.SettingChanged += delegate
					{
						onChanged(configurableValue.bepinexConfigEntry.Value);
						reloadLogbook = true;
					};
					onChanged(bepinexConfigEntry.Value);
					reloadLogbook = true;
				}
			}

			public override string ToString()
			{
				return Convert.ToString(Value, CultureInfo.InvariantCulture);
			}

			public static implicit operator T(ConfigurableValue<T> configurableValue)
			{
				return configurableValue.Value;
			}
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Awake <0>__LogBookController_Awake;

			public static hook_GetLocalizedStringByToken <1>__Language_GetLocalizedStringByToken;
		}

		private static bool reloadLogbook;

		internal static void Init()
		{
			//IL_0011: 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_001c: Expected O, but got Unknown
			//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_003d: Expected O, but got Unknown
			object obj = <>O.<0>__LogBookController_Awake;
			if (obj == null)
			{
				hook_Awake val = LogBookController_Awake;
				<>O.<0>__LogBookController_Awake = val;
				obj = (object)val;
			}
			LogBookController.Awake += (hook_Awake)obj;
			object obj2 = <>O.<1>__Language_GetLocalizedStringByToken;
			if (obj2 == null)
			{
				hook_GetLocalizedStringByToken val2 = Language_GetLocalizedStringByToken;
				<>O.<1>__Language_GetLocalizedStringByToken = val2;
				obj2 = (object)val2;
			}
			Language.GetLocalizedStringByToken += (hook_GetLocalizedStringByToken)obj2;
		}

		private static void LogBookController_Awake(orig_Awake orig, LogBookController self)
		{
			orig.Invoke(self);
			if (reloadLogbook)
			{
				reloadLogbook = false;
				LogBookController.BuildStaticData();
			}
		}

		private static string Language_GetLocalizedStringByToken(orig_GetLocalizedStringByToken orig, Language self, string token)
		{
			string text = orig.Invoke(self, token);
			foreach (ConfigurableValue item in ConfigurableValue.instancesList.FindAll((ConfigurableValue x) => x.stringsToAffect.Contains(token)))
			{
				text = text.Replace("{" + item.key + "}", item.ToString());
			}
			return text;
		}
	}
	internal class DamageColorManager
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_FindColor <>9__2_0;

			internal Color <Hooks>b__2_0(orig_FindColor orig, DamageColorIndex colorIndex)
			{
				//IL_0006: 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_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: 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_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: 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)
				if (registeredColorIndexList.Contains(colorIndex))
				{
					return DamageColor.colors[colorIndex];
				}
				return orig.Invoke(colorIndex);
			}
		}

		public static List<DamageColorIndex> registeredColorIndexList = new List<DamageColorIndex>();

		internal static void Init()
		{
			Hooks();
		}

		private static void Hooks()
		{
			//IL_0015: 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)
			//IL_0020: Expected O, but got Unknown
			object obj = <>c.<>9__2_0;
			if (obj == null)
			{
				hook_FindColor val = (orig_FindColor orig, DamageColorIndex colorIndex) => registeredColorIndexList.Contains(colorIndex) ? DamageColor.colors[colorIndex] : orig.Invoke(colorIndex);
				<>c.<>9__2_0 = val;
				obj = (object)val;
			}
			DamageColor.FindColor += (hook_FindColor)obj;
		}

		public static DamageColorIndex RegisterDamageColor(Color color)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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_0026: 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)
			int num = DamageColor.colors.Length;
			DamageColorIndex val = (DamageColorIndex)(byte)num;
			ArrayUtils.ArrayAppend<Color>(ref DamageColor.colors, ref color);
			registeredColorIndexList.Add(val);
			return val;
		}
	}
	internal class GameEventManager
	{
		public delegate void DamageAttackerVictimEventHandler(DamageInfo damageInfo, GenericCharacterInfo attackerInfo, GenericCharacterInfo victimInfo);

		public delegate void DamageReportEventHandler(DamageReport damageReport);

		public class GenericDamageEvent : MonoBehaviour, IOnIncomingDamageServerReceiver, IOnTakeDamageServerReceiver
		{
			public HealthComponent healthComponent;

			public CharacterBody victimBody;

			public void Start()
			{
				healthComponent = ((Component)this).GetComponent<HealthComponent>();
				if (!Object.op_Implicit((Object)(object)healthComponent))
				{
					Object.Destroy((Object)(object)this);
				}
				else
				{
					victimBody = healthComponent.body;
				}
			}

			public void OnIncomingDamageServer(DamageInfo damageInfo)
			{
				GenericCharacterInfo attackerInfo = default(GenericCharacterInfo);
				if (Object.op_Implicit((Object)(object)damageInfo.attacker))
				{
					attackerInfo = new GenericCharacterInfo(damageInfo.attacker.GetComponent<CharacterBody>());
				}
				GenericCharacterInfo victimInfo = new GenericCharacterInfo(victimBody);
				GameEventManager.BeforeTakeDamage?.Invoke(damageInfo, attackerInfo, victimInfo);
			}

			public void OnTakeDamageServer(DamageReport damageReport)
			{
				if (Object.op_Implicit((Object)(object)victimBody) && GameEventManager.OnTakeDamage != null)
				{
					GameEventManager.OnTakeDamage(damageReport);
				}
			}
		}

		public struct GenericCharacterInfo
		{
			public GameObject gameObject;

			public CharacterBody body;

			public CharacterMaster master;

			public TeamComponent teamComponent;

			public HealthComponent healthComponent;

			public Inventory inventory;

			public TeamIndex teamIndex;

			public Vector3 aimOrigin;

			public unsafe GenericCharacterInfo(CharacterBody body)
			{
				//IL_009c: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00af: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a1->IL00a1: Incompatible stack types: Ref vs I4
				//IL_0096->IL00a1: Incompatible stack types: I4 vs Ref
				//IL_0096->IL00a1: Incompatible stack types: Ref vs I4
				this.body = body;
				gameObject = (Object.op_Implicit((Object)(object)body) ? ((Component)body).gameObject : null);
				master = (Object.op_Implicit((Object)(object)body) ? body.master : null);
				teamComponent = (Object.op_Implicit((Object)(object)body) ? body.teamComponent : null);
				healthComponent = (Object.op_Implicit((Object)(object)body) ? body.healthComponent : null);
				inventory = (Object.op_Implicit((Object)(object)master) ? master.inventory : null);
				ref GenericCharacterInfo reference = ref this;
				int num;
				if (Object.op_Implicit((Object)(object)teamComponent))
				{
					reference = ref *(GenericCharacterInfo*)teamComponent.teamIndex;
					num = (int)(ref reference);
				}
				else
				{
					num = 0;
					reference = ref *(GenericCharacterInfo*)num;
					num = (int)(ref reference);
				}
				Unsafe.Write(&((GenericCharacterInfo*)num)->teamIndex, (TeamIndex)(ref reference));
				Vector3 normalized;
				if (!Object.op_Implicit((Object)(object)body))
				{
					Vector3 insideUnitSphere = Random.insideUnitSphere;
					normalized = ((Vector3)(ref insideUnitSphere)).normalized;
				}
				else
				{
					normalized = body.aimOrigin;
				}
				aimOrigin = normalized;
			}
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_Awake <>9__11_0;

			public static hook_OnHitEnemy <>9__11_1;

			internal void <Init>b__11_0(orig_Awake orig, HealthComponent self)
			{
				((Component)self).gameObject.AddComponent<GenericDamageEvent>();
				orig.Invoke(self);
			}

			internal void <Init>b__11_1(orig_OnHitEnemy orig, GlobalEventManager self, DamageInfo damageInfo, GameObject victim)
			{
				orig.Invoke(self, damageInfo, victim);
				if (Object.op_Implicit((Object)(object)damageInfo.attacker))
				{
					CharacterBody component = damageInfo.attacker.GetComponent<CharacterBody>();
					CharacterBody body = (Object.op_Implicit((Object)(object)victim) ? victim.GetComponent<CharacterBody>() : null);
					GenericCharacterInfo attackerInfo = new GenericCharacterInfo(component);
					GenericCharacterInfo victimInfo = new GenericCharacterInfo(body);
					GameEventManager.OnHitEnemy?.Invoke(damageInfo, attackerInfo, victimInfo);
				}
			}
		}

		public static event DamageAttackerVictimEventHandler OnHitEnemy;

		public static event DamageAttackerVictimEventHandler BeforeTakeDamage;

		public static event DamageReportEventHandler OnTakeDamage;

		internal static void Init()
		{
			//IL_0015: 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)
			//IL_0020: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			object obj = <>c.<>9__11_0;
			if (obj == null)
			{
				hook_Awake val = delegate(orig_Awake orig, HealthComponent self)
				{
					((Component)self).gameObject.AddComponent<GenericDamageEvent>();
					orig.Invoke(self);
				};
				<>c.<>9__11_0 = val;
				obj = (object)val;
			}
			HealthComponent.Awake += (hook_Awake)obj;
			object obj2 = <>c.<>9__11_1;
			if (obj2 == null)
			{
				hook_OnHitEnemy val2 = delegate(orig_OnHitEnemy orig, GlobalEventManager self, DamageInfo damageInfo, GameObject victim)
				{
					orig.Invoke(self, damageInfo, victim);
					if (Object.op_Implicit((Object)(object)damageInfo.attacker))
					{
						CharacterBody component = damageInfo.attacker.GetComponent<CharacterBody>();
						CharacterBody body = (Object.op_Implicit((Object)(object)victim) ? victim.GetComponent<CharacterBody>() : null);
						GenericCharacterInfo attackerInfo = new GenericCharacterInfo(component);
						GenericCharacterInfo victimInfo = new GenericCharacterInfo(body);
						GameEventManager.OnHitEnemy?.Invoke(damageInfo, attackerInfo, victimInfo);
					}
				};
				<>c.<>9__11_1 = val2;
				obj2 = (object)val2;
			}
			GlobalEventManager.OnHitEnemy += (hook_OnHitEnemy)obj2;
		}
	}
	public static class ItemManager
	{
		public class DisplayRuleData
		{
			public string survivorName;

			public string partName;

			public Vector3 localPos;

			public Vector3 localAngles;

			public Vector3 localScale;

			public DisplayRuleData(string survivorModelName, string partName, Vector3 localPos, Vector3 localAngles, Vector3 localScale)
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: 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_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: 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)
				survivorName = survivorModelName;
				this.partName = partName;
				this.localPos = localPos;
				this.localAngles = localAngles;
				this.localScale = localScale;
				base..ctor();
			}
		}

		public static EquipmentDef GenerateEquipment(string name, float cooldown, bool isLunar = false, bool appearsInMultiPlayer = true, bool appearsInSinglePlayer = true, bool canBeRandomlyTriggered = true, bool enigmaCompatible = true, bool canDrop = true)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Expected O, but got Unknown
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Expected O, but got Unknown
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			EquipmentDef val = ScriptableObject.CreateInstance<EquipmentDef>();
			((Object)val).name = name.ToUpperInvariant();
			val.AutoPopulateTokens();
			GameObject val2 = AssetManager.bundle.LoadAsset<GameObject>(name + ".prefab");
			if ((Object)(object)val2 == (Object)null)
			{
				Log.Warning("Missing prefab file for equipment " + ((Object)val).name + ". Substituting default...");
				val2 = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Mystery/PickupMystery.prefab").WaitForCompletion();
			}
			ModelPanelParameters val3 = val2.AddComponent<ModelPanelParameters>();
			val3.focusPointTransform = val2.transform;
			val3.cameraPositionTransform = val2.transform;
			val3.maxDistance = 10f;
			val3.minDistance = 5f;
			val.pickupIconSprite = AssetManager.bundle.LoadAsset<Sprite>(name + ".png");
			val.pickupModelPrefab = val2;
			val.isLunar = isLunar;
			if (isLunar)
			{
				val.colorIndex = (ColorIndex)4;
			}
			val.appearsInMultiPlayer = appearsInMultiPlayer;
			val.appearsInSinglePlayer = appearsInSinglePlayer;
			val.canBeRandomlyTriggered = canBeRandomlyTriggered;
			val.enigmaCompatible = enigmaCompatible;
			val.canDrop = canDrop;
			val.cooldown = cooldown;
			ItemDisplayRuleDict val4 = new ItemDisplayRuleDict((ItemDisplayRule[])null);
			ItemAPI.Add(new CustomEquipment(val, val4));
			return val;
		}

		public static ItemDef GenerateItem(string name, ItemTag[] tags, ItemTier tier, List<DisplayRuleData> rules = null)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Invalid comparison between Unknown and I4
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Invalid comparison between Unknown and I4
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Invalid comparison between Unknown and I4
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Expected O, but got Unknown
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Invalid comparison between Unknown and I4
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: 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)
			ItemDef val = ScriptableObject.CreateInstance<ItemDef>();
			((Object)val).name = name.ToUpperInvariant();
			val.AutoPopulateTokens();
			SetItemTier(val, tier);
			GameObject val2 = AssetManager.bundle.LoadAsset<GameObject>(name + ".prefab");
			if ((Object)(object)val2 == (Object)null)
			{
				Log.Warning("Missing prefab file for item " + ((Object)val).name + ". Substituting default...");
				val2 = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Mystery/PickupMystery.prefab").WaitForCompletion();
			}
			ModelPanelParameters val3 = val2.AddComponent<ModelPanelParameters>();
			val3.focusPointTransform = val2.transform;
			val3.cameraPositionTransform = val2.transform;
			val3.maxDistance = 10f;
			val3.minDistance = 5f;
			if ((int)val.tier == 9 || (int)val.tier == 6 || (int)val.tier == 7 || (int)val.tier == 8)
			{
				val.requiredExpansion = TooManyItems.sotvDLC;
			}
			val.pickupIconSprite = AssetManager.bundle.LoadAsset<Sprite>(name + ".png");
			val.pickupModelPrefab = val2;
			val.canRemove = true;
			val.hidden = false;
			val.tags = tags;
			ItemDisplayRuleDict val4 = new ItemDisplayRuleDict((ItemDisplayRule[])null);
			if (rules != null)
			{
				foreach (DisplayRuleData rule in rules)
				{
					val4.Add(rule.survivorName, (ItemDisplayRule[])(object)new ItemDisplayRule[1] { GenerateItemDisplayRule(val2, rule) });
				}
			}
			ItemAPI.Add(new CustomItem(val, val4));
			return val;
		}

		public static ItemDisplayRule GenerateItemDisplayRule(GameObject prefab, DisplayRuleData data)
		{
			//IL_0003: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			//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_0043: 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)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			ItemDisplayRule result = default(ItemDisplayRule);
			result.ruleType = (ItemDisplayRuleType)0;
			result.followerPrefab = prefab;
			result.childName = data.partName;
			result.localPos = data.localPos;
			result.localAngles = data.localAngles;
			result.localScale = data.localScale;
			return result;
		}

		public static BuffDef GenerateBuff(string name, Sprite sprite, bool canStack = false, bool isHidden = false, bool isDebuff = false, bool isCooldown = false)
		{
			BuffDef val = ScriptableObject.CreateInstance<BuffDef>();
			((Object)val).name = name;
			val.iconSprite = sprite;
			val.canStack = canStack;
			val.isHidden = isHidden;
			val.isDebuff = isDebuff;
			val.isCooldown = isCooldown;
			return val;
		}

		public static void SetItemTier(ItemDef itemDef, ItemTier tier)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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_001c: Invalid comparison between Unknown and I4
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			if ((int)tier == 5)
			{
				try
				{
					itemDef.deprecatedTier = tier;
				}
				catch (Exception arg)
				{
					Log.Warning($"Error setting deprecatedTier for {((Object)itemDef).name}: {arg}");
				}
			}
			((ResourceAvailability)(ref ItemTierCatalog.availability)).CallWhenAvailable((Action)delegate
			{
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				if (Object.op_Implicit((Object)(object)itemDef))
				{
					itemDef.tier = tier;
				}
			});
		}
	}
}
namespace TooManyItems.Items.Void
{
	internal class ShadowCrest
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static StatHookEventHandler <>9__7_0;

			internal void <Hooks>b__7_0(CharacterBody sender, StatHookEventArgs args)
			{
				if (Object.op_Implicit((Object)(object)sender) && Object.op_Implicit((Object)(object)sender.inventory) && Object.op_Implicit((Object)(object)sender.healthComponent))
				{
					int itemCountEffective = sender.inventory.GetItemCountEffective(itemDef);
					if (itemCountEffective > 0 && sender.healthComponent.combinedHealthFraction < 1f)
					{
						args.baseRegenAdd += Utilities.GetHyperbolicStacking(percentRegenPerSecond, percentRegenPerSecondExtraStacks, itemCountEffective) * sender.healthComponent.missingCombinedHealth;
					}
				}
			}
		}

		public static ItemDef itemDef;

		public static ConfigurableValue<bool> isEnabled = new ConfigurableValue<bool>("Item: Shadow Crest", "Enabled", defaultValue: true, "Whether or not the item is enabled.", new List<string>(1) { "ITEM_SHADOWCREST_DESC" });

		public static ConfigurableValue<float> regenPerSecond = new ConfigurableValue<float>("Item: Shadow Crest", "Regen Per Second", 1f, "Percentage of missing health regenerated per second.", new List<string>(1) { "ITEM_SHADOWCREST_DESC" });

		public static ConfigurableValue<float> regenPerSecondExtraStacks = new ConfigurableValue<float>("Item: Shadow Crest", "Regen Per Second Extra Stacks", 1f, "Percentage of missing health regenerated per second for extra stacks.", new List<string>(1) { "ITEM_SHADOWCREST_DESC" });

		public static float percentRegenPerSecond = regenPerSecond.Value / 100f;

		public static float percentRegenPerSecondExtraStacks = regenPerSecondExtraStacks.Value / 100f;

		internal static void Init()
		{
			itemDef = ItemManager.GenerateItem("ShadowCrest", (ItemTag[])(object)new ItemTag[2]
			{
				(ItemTag)2,
				(ItemTag)31
			}, (ItemTier)7);
			Hooks();
		}

		public static void Hooks()
		{
			//IL_0020: 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: Expected O, but got Unknown
			Utilities.AddRecalculateOnFrameHook(itemDef);
			object obj = <>c.<>9__7_0;
			if (obj == null)
			{
				StatHookEventHandler val = delegate(CharacterBody sender, StatHookEventArgs args)
				{
					if (Object.op_Implicit((Object)(object)sender) && Object.op_Implicit((Object)(object)sender.inventory) && Object.op_Implicit((Object)(object)sender.healthComponent))
					{
						int itemCountEffective = sender.inventory.GetItemCountEffective(itemDef);
						if (itemCountEffective > 0 && sender.healthComponent.combinedHealthFraction < 1f)
						{
							args.baseRegenAdd += Utilities.GetHyperbolicStacking(percentRegenPerSecond, percentRegenPerSecondExtraStacks, itemCountEffective) * sender.healthComponent.missingCombinedHealth;
						}
					}
				};
				<>c.<>9__7_0 = val;
				obj = (object)val;
			}
			RecalculateStatsAPI.GetStatCoefficients += (StatHookEventHandler)obj;
		}
	}
	internal class VoidHeart
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static StatHookEventHandler <>9__9_0;

			internal void <Hooks>b__9_0(CharacterBody sender, StatHookEventArgs args)
			{
				if (Object.op_Implicit((Object)(object)sender) && Object.op_Implicit((Object)(object)sender.inventory) && Object.op_Implicit((Object)(object)sender.healthComponent))
				{
					int itemCountEffective = sender.inventory.GetItemCountEffective(itemDef);
					if (itemCountEffective > 0)
					{
						args.baseHealthAdd += healthIncrease.Value;
						args.baseDamageAdd += CalculateDamageBonus(sender, itemCountEffective);
					}
				}
			}
		}

		public static ItemDef itemDef;

		public static ConfigurableValue<bool> isEnabled = new ConfigurableValue<bool>("Item: Defiled Heart", "Enabled", defaultValue: true, "Whether or not the item is enabled.", new List<string>(1) { "ITEM_VOIDHEART_DESC" });

		public static ConfigurableValue<float> healthIncrease = new ConfigurableValue<float>("Item: Defiled Heart", "Health Increase", 200f, "Bonus health gained from this item. Does not increase with stacks.", new List<string>(1) { "ITEM_VOIDHEART_DESC" });

		public static ConfigurableValue<float> percentDamagePerStack = new ConfigurableValue<float>("Item: Defiled Heart", "Bonus Damage Scaling", 1.5f, "Percent of maximum health gained as base damage.", new List<string>(1) { "ITEM_VOIDHEART_DESC" });

		public static ConfigurableValue<float> percentDamagePerExtraStack = new ConfigurableValue<float>("Item: Defiled Heart", "Bonus Damage Scaling Extra Stacks", 1.5f, "Percent of maximum health gained as base damage with extra stacks.", new List<string>(1) { "ITEM_VOIDHEART_DESC" });

		public static float multiplierPerStack = percentDamagePerStack.Value / 100f;

		public static float multiplierPerExtraStack = percentDamagePerExtraStack.Value / 100f;

		internal static void Init()
		{
			ItemTag[] array = new ItemTag[3];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			itemDef = ItemManager.GenerateItem("VoidHeart", (ItemTag[])(object)array, (ItemTier)8);
			Hooks();
		}

		public static float CalculateDamageBonus(CharacterBody sender, int itemCount)
		{
			return sender.healthComponent.fullHealth * Utilities.GetLinearStacking(multiplierPerStack, multiplierPerExtraStack, itemCount);
		}

		public static void Hooks()
		{
			//IL_0015: 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)
			//IL_0020: Expected O, but got Unknown
			object obj = <>c.<>9__9_0;
			if (obj == null)
			{
				StatHookEventHandler val = delegate(CharacterBody sender, StatHookEventArgs args)
				{
					if (Object.op_Implicit((Object)(object)sender) && Object.op_Implicit((Object)(object)sender.inventory) && Object.op_Implicit((Object)(object)sender.healthComponent))
					{
						int itemCountEffective = sender.inventory.GetItemCountEffective(itemDef);
						if (itemCountEffective > 0)
						{
							args.baseHealthAdd += healthIncrease.Value;
							args.baseDamageAdd += CalculateDamageBonus(sender, itemCountEffective);
						}
					}
				};
				<>c.<>9__9_0 = val;
				obj = (object)val;
			}
			RecalculateStatsAPI.GetStatCoefficients += (StatHookEventHandler)obj;
		}
	}
}
namespace TooManyItems.Items.Tier3
{
	internal class Abacus
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static StatHookEventHandler <>9__6_0;

			public static Action<DamageReport> <>9__6_1;

			internal void <Hooks>b__6_0(CharacterBody sender, StatHookEventArgs args)
			{
				if (Object.op_Implicit((Object)(object)sender) && Object.op_Implicit((Object)(object)sender.inventory))
				{
					int buffCount = sender.GetBuffCount(countedBuff);
					args.critAdd += Utilities.GetLinearStacking(critChancePerStack.Value, critChancePerExtraStack.Value, buffCount);
					if (sender.inventory.GetItemCountEffective(itemDef) > 0 && sender.crit > 100f)
					{
						args.critDamageMultAdd += sender.crit / 100f - 1f;
					}
				}
			}

			internal void <Hooks>b__6_1(DamageReport damageReport)
			{
				if (!NetworkServer.active)
				{
					return;
				}
				CharacterBody attackerBody = damageReport.attackerBody;
				if (!Object.op_Implicit((Object)(object)attackerBody) || !Object.op_Implicit((Object)(object)attackerBody.inventory))
				{
					return;
				}
				int itemCountEffective = attackerBody.inventory.GetItemCountEffective(itemDef);
				if (itemCountEffective > 0)
				{
					for (int i = 0; i < itemCountEffective; i++)
					{
						attackerBody.AddBuff(countedBuff);
					}
					Utilities.ForceRecalculate(attackerBody);
				}
			}
		}

		public static ItemDef itemDef;

		public static BuffDef countedBuff;

		public static ConfigurableValue<bool> isEnabled = new ConfigurableValue<bool>("Item: Abacus", "Enabled", defaultValue: true, "Whether or not the item is enabled.", new List<string>(1) { "ITEM_ABACUS_DESC" });

		public static ConfigurableValue<float> critChancePerStack = new ConfigurableValue<float>("Item: Abacus", "Crit On Kill", 1f, "Crit chance gained on kill per first stack of item.", new List<string>(1) { "ITEM_ABACUS_DESC" });

		public static ConfigurableValue<float> critChancePerExtraStack = new ConfigurableValue<float>("Item: Abacus", "Crit On Kill Extra Stacks", 1f, "Crit chance gained on kill per extra stack of item.", new List<string>(1) { "ITEM_ABACUS_DESC" });

		internal static void Init()
		{
			ItemTag[] array = new ItemTag[4];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			itemDef = ItemManager.GenerateItem("Abacus", (ItemTag[])(object)array, (ItemTier)2);
			countedBuff = ItemManager.GenerateBuff("Counted", AssetManager.bundle.LoadAsset<Sprite>("Counted.png"), canStack: true);
			ContentAddition.AddBuffDef(countedBuff);
			Hooks();
		}

		public static void Hooks()
		{
			//IL_0015: 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)
			//IL_0020: Expected O, but got Unknown
			object obj = <>c.<>9__6_0;
			if (obj == null)
			{
				StatHookEventHandler val = delegate(CharacterBody sender, StatHookEventArgs args)
				{
					if (Object.op_Implicit((Object)(object)sender) && Object.op_Implicit((Object)(object)sender.inventory))
					{
						int buffCount = sender.GetBuffCount(countedBuff);
						args.critAdd += Utilities.GetLinearStacking(critChancePerStack.Value, critChancePerExtraStack.Value, buffCount);
						if (sender.inventory.GetItemCountEffective(itemDef) > 0 && sender.crit > 100f)
						{
							args.critDamageMultAdd += sender.crit / 100f - 1f;
						}
					}
				};
				<>c.<>9__6_0 = val;
				obj = (object)val;
			}
			RecalculateStatsAPI.GetStatCoefficients += (StatHookEventHandler)obj;
			GlobalEventManager.onCharacterDeathGlobal += delegate(DamageReport damageReport)
			{
				if (NetworkServer.active)
				{
					CharacterBody attackerBody = damageReport.attackerBody;
					if (Object.op_Implicit((Object)(object)attackerBody) && Object.op_Implicit((Object)(object)attackerBody.inventory))
					{
						int itemCountEffective = attackerBody.inventory.GetItemCountEffective(itemDef);
						if (itemCountEffective > 0)
						{
							for (int i = 0; i < itemCountEffective; i++)
							{
								attackerBody.AddBuff(countedBuff);
							}
							Utilities.ForceRecalculate(attackerBody);
						}
					}
				}
			};
		}
	}
	internal class BloodDice
	{
		public class Statistics : MonoBehaviour
		{
			public class Sync : INetMessage, ISerializableObject
			{
				private NetworkInstanceId objId;

				private float permanentHealth;

				public Sync()
				{
				}

				public Sync(NetworkInstanceId objId, float health)
				{
					//IL_0009: 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)
					this.objId = objId;
					permanentHealth = health;
				}

				public void Deserialize(NetworkReader reader)
				{
					//IL_0003: Unknown result type (might be due to invalid IL or missing references)
					//IL_0008: Unknown result type (might be due to invalid IL or missing references)
					objId = reader.ReadNetworkId();
					permanentHealth = reader.ReadSingle();
				}

				public void OnReceived()
				{
					//IL_000d: Unknown result type (might be due to invalid IL or missing references)
					if (NetworkServer.active)
					{
						return;
					}
					GameObject val = Util.FindNetworkObject(objId);
					if ((Object)(object)val != (Object)null)
					{
						Statistics component = val.GetComponent<Statistics>();
						if (component != null)
						{
							component.PermanentHealth = permanentHealth;
						}
					}
				}

				public void Serialize(NetworkWriter writer)
				{
					//IL_0003: Unknown result type (might be due to invalid IL or missing references)
					writer.Write(objId);
					writer.Write(permanentHealth);
					writer.FinishMessage();
				}
			}

			private float _permanentHealth;

			public float PermanentHealth
			{
				get
				{
					return _permanentHealth;
				}
				set
				{
					//IL_001d: Unknown result type (might be due to invalid IL or missing references)
					_permanentHealth = value;
					if (NetworkServer.active)
					{
						NetMessageExtensions.Send((INetMessage)(object)new Sync(((Component)this).gameObject.GetComponent<NetworkIdentity>().netId, value), (NetworkDestination)1);
					}
				}
			}
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Action<CharacterMaster> <>9__10_0;

			public static hook_GetHealthBarValues <>9__10_1;

			public static StatHookEventHandler <>9__10_2;

			public static Action<DamageReport> <>9__10_3;

			internal void <Hooks>b__10_0(CharacterMaster obj)
			{
				Inventory inventory = obj.inventory;
				if (inventory != null)
				{
					((Component)inventory).gameObject.AddComponent<Statistics>();
				}
			}

			internal HealthBarValues <Hooks>b__10_1(orig_GetHealthBarValues orig, HealthComponent self)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: 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_0056: Unknown result type (might be due to invalid IL or missing references)
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				HealthBarValues result = orig.Invoke(self);
				if (Object.op_Implicit((Object)(object)self.body) && Object.op_Implicit((Object)(object)self.body.inventory) && self.body.inventory.GetItemCountEffective(itemDef) > 0)
				{
					result.hasInfusion = true;
				}
				return result;
			}

			internal void <Hooks>b__10_2(CharacterBody sender, StatHookEventArgs args)
			{
				if (!Object.op_Implicit((Object)(object)sender) || !Object.op_Implicit((Object)(object)sender.inventory))
				{
					return;
				}
				int itemCountEffective = sender.inventory.GetItemCountEffective(itemDef);
				if (itemCountEffective > 0)
				{
					Statistics component = ((Component)sender.inventory).GetComponent<Statistics>();
					if (Object.op_Implicit((Object)(object)component))
					{
						args.baseHealthAdd += Mathf.Min(component.PermanentHealth, CalculateMaxHealthCap(itemCountEffective));
					}
				}
			}

			internal void <Hooks>b__10_3(DamageReport damageReport)
			{
				if (!NetworkServer.active)
				{
					return;
				}
				CharacterMaster attackerMaster = damageReport.attackerMaster;
				CharacterBody attackerBody = damageReport.attackerBody;
				if (!Object.op_Implicit((Object)(object)attackerMaster) || !Object.op_Implicit((Object)(object)attackerBody) || !Object.op_Implicit((Object)(object)attackerBody.inventory))
				{
					return;
				}
				int itemCountEffective = attackerBody.inventory.GetItemCountEffective(itemDef);
				if (itemCountEffective <= 0)
				{
					return;
				}
				Statistics component = ((Component)attackerBody.inventory).GetComponent<Statistics>();
				if (!Object.op_Implicit((Object)(object)component))
				{
					return;
				}
				int num = Math.Min(GetDiceRoll(attackerMaster), Mathf.RoundToInt(CalculateMaxHealthCap(itemCountEffective) - component.PermanentHealth));
				if (num > 0)
				{
					for (int i = 0; i < num; i++)
					{
						OrbManager.instance.AddOrb((Orb)(object)new BloodDiceOrb(damageReport, i));
					}
				}
			}
		}

		public static ItemDef itemDef;

		public static ConfigurableValue<bool> isEnabled = new ConfigurableValue<bool>("Item: Blood Dice", "Enabled", defaultValue: true, "Whether or not the item is enabled.", new List<string>(1) { "ITEM_BLOODDICE_DESC" });

		public static ConfigurableValue<bool> affectedByLuck = new ConfigurableValue<bool>("Item: Blood Dice", "Affected By Luck", defaultValue: true, "Whether or not the likelihood of a high roll is affected by luck.", new List<string>(1) { "ITEM_BLOODDICE_DESC" });

		public static ConfigurableValue<int> minHealthGain = new ConfigurableValue<int>("Item: Blood Dice", "Min Gain", 2, "Minimum health that can be gained every kill.", new List<string>(1) { "ITEM_BLOODDICE_DESC" });

		public static ConfigurableValue<int> maxHealthGain = new ConfigurableValue<int>("Item: Blood Dice", "Max Gain", 12, "Maximum health that can be gained every kill.", new List<string>(1) { "ITEM_BLOODDICE_DESC" });

		public static ConfigurableValue<float> maxHealthPerStack = new ConfigurableValue<float>("Item: Blood Dice", "Maximum Health Per Item", 550f, "Maximum amount of permanent health allowed per first stack.", new List<string>(1) { "ITEM_BLOODDICE_DESC" });

		public static ConfigurableValue<float> maxHealthPerExtraStack = new ConfigurableValue<float>("Item: Blood Dice", "Maximum Health Per Extra Item", 550f, "Maximum amount of permanent health allowed per extra stack.", new List<string>(1) { "ITEM_BLOODDICE_DESC" });

		internal static void Init()
		{
			ItemTag[] array = new ItemTag[4];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			itemDef = ItemManager.GenerateItem("BloodDice", (ItemTag[])(object)array, (ItemTier)2);
			NetworkingAPI.RegisterMessageType<Statistics.Sync>();
			Hooks();
		}

		public static float CalculateMaxHealthCap(int itemCount)
		{
			return Utilities.GetLinearStacking(maxHealthPerStack.Value, maxHealthPerExtraStack.Value, itemCount);
		}

		public static void Hooks()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			CharacterMaster.onStartGlobal += delegate(CharacterMaster obj)
			{
				Inventory inventory = obj.inventory;
				if (inventory != null)
				{
					((Component)inventory).gameObject.AddComponent<Statistics>();
				}
			};
			object obj2 = <>c.<>9__10_1;
			if (obj2 == null)
			{
				hook_GetHealthBarValues val = delegate(orig_GetHealthBarValues orig, HealthComponent self)
				{
					//IL_0003: Unknown result type (might be due to invalid IL or missing references)
					//IL_0008: 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_0056: Unknown result type (might be due to invalid IL or missing references)
					//IL_0059: Unknown result type (might be due to invalid IL or missing references)
					HealthBarValues result = orig.Invoke(self);
					if (Object.op_Implicit((Object)(object)self.body) && Object.op_Implicit((Object)(object)self.body.inventory) && self.body.inventory.GetItemCountEffective(itemDef) > 0)
					{
						result.hasInfusion = true;
					}
					return result;
				};
				<>c.<>9__10_1 = val;
				obj2 = (object)val;
			}
			HealthComponent.GetHealthBarValues += (hook_GetHealthBarValues)obj2;
			object obj3 = <>c.<>9__10_2;
			if (obj3 == null)
			{
				StatHookEventHandler val2 = delegate(CharacterBody sender, StatHookEventArgs args)
				{
					if (Object.op_Implicit((Object)(object)sender) && Object.op_Implicit((Object)(object)sender.inventory))
					{
						int itemCountEffective2 = sender.inventory.GetItemCountEffective(itemDef);
						if (itemCountEffective2 > 0)
						{
							Statistics component2 = ((Component)sender.inventory).GetComponent<Statistics>();
							if (Object.op_Implicit((Object)(object)component2))
							{
								args.baseHealthAdd += Mathf.Min(component2.PermanentHealth, CalculateMaxHealthCap(itemCountEffective2));
							}
						}
					}
				};
				<>c.<>9__10_2 = val2;
				obj3 = (object)val2;
			}
			RecalculateStatsAPI.GetStatCoefficients += (StatHookEventHandler)obj3;
			GlobalEventManager.onCharacterDeathGlobal += delegate(DamageReport damageReport)
			{
				if (NetworkServer.active)
				{
					CharacterMaster attackerMaster = damageReport.attackerMaster;
					CharacterBody attackerBody = damageReport.attackerBody;
					if (Object.op_Implicit((Object)(object)attackerMaster) && Object.op_Implicit((Object)(object)attackerBody) && Object.op_Implicit((Object)(object)attackerBody.inventory))
					{
						int itemCountEffective = attackerBody.inventory.GetItemCountEffective(itemDef);
						if (itemCountEffective > 0)
						{
							Statistics component = ((Component)attackerBody.inventory).GetComponent<Statistics>();
							if (Object.op_Implicit((Object)(object)component))
							{
								int num = Math.Min(GetDiceRoll(attackerMaster), Mathf.RoundToInt(CalculateMaxHealthCap(itemCountEffective) - component.PermanentHealth));
								if (num > 0)
								{
									for (int i = 0; i < num; i++)
									{
										OrbManager.instance.AddOrb((Orb)(object)new BloodDiceOrb(damageReport, i));
									}
								}
							}
						}
					}
				}
			};
		}

		public static int GetDiceRoll(CharacterMaster master)
		{
			float num = 7f;
			float num2 = 3.5f;
			if (affectedByLuck.Value)
			{
				num += master.luck * num2;
			}
			return Mathf.Clamp(GenerateRollNormalDistribution(num, num2), minHealthGain.Value, maxHealthGain.Value);
		}

		private static int GenerateRollNormalDistribution(float mean, float deviation)
		{
			float num = (float)(1.0 - TooManyItems.RandGen.NextDouble());
			float num2 = (float)(1.0 - TooManyItems.RandGen.NextDouble());
			float num3 = Mathf.Sqrt(-2f * Mathf.Log(num)) * Mathf.Sin(MathF.PI * 2f * num2);
			float num4 = mean + deviation * num3;
			return Mathf.RoundToInt(num4);
		}
	}
	public class BloodDiceOrb : Orb
	{
		private readonly float speed = 25f;

		private readonly CharacterBody targetBody;

		private Inventory targetInventory;

		public BloodDiceOrb(DamageReport report, int sequence)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)report.victimBody) && Object.op_Implicit((Object)(object)report.attackerBody))
			{
				targetBody = report.attackerBody ?? null;
				base.origin = (Object.op_Implicit((Object)(object)report.victimBody) ? report.victimBody.corePosition : Vector3.zero);
				if (Object.op_Implicit((Object)(object)targetBody))
				{
					base.target = targetBody.mainHurtBox;
				}
			}
			speed += sequence;
		}

		public override void Begin()
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			if ((Object)(object)targetBody == (Object)null || (Object)(object)base.target == (Object)null)
			{
				((Orb)this).duration = 0f;
				targetInventory = null;
				return;
			}
			((Orb)this).duration = ((Orb)this).distanceToTarget / speed;
			EffectData val = new EffectData
			{
				origin = base.origin,
				genericFloat = ((Orb)this).duration
			};
			val.SetHurtBoxReference(base.target);
			EffectManager.SpawnEffect(OrbStorageUtility.Get("Prefabs/Effects/OrbEffects/InfusionOrbEffect"), val, true);
			targetInventory = targetBody.inventory;
		}

		public override void OnArrival()
		{
			if (!Object.op_Implicit((Object)(object)targetInventory))
			{
				return;
			}
			int itemCountEffective = targetInventory.GetItemCountEffective(BloodDice.itemDef);
			float num = BloodDice.CalculateMaxHealthCap(itemCountEffective);
			BloodDice.Statistics component = ((Component)targetInventory).GetComponent<BloodDice.Statistics>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.PermanentHealth += 1f;
				if (component.PermanentHealth > num)
				{
					component.PermanentHealth = num;
				}
			}
			if (Object.op_Implicit((Object)(object)targetBody))
			{
				Utilities.ForceRecalculate(targetBody);
			}
		}
	}
	internal class GlassMarbles
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static StatHookEventHandler <>9__5_0;

			internal void <Hooks>b__5_0(CharacterBody sender, StatHookEventArgs args)
			{
				if (Object.op_Implicit((Object)(object)sender) && Object.op_Implicit((Object)(object)sender.inventory))
				{
					int itemCountEffective = sender.inventory.GetItemCountEffective(itemDef);
					if (itemCountEffective > 0)
					{
						args.baseDamageAdd += Utilities.GetLinearStacking(damagePerLevelPerStack.Value, damagePerLevelPerExtraStack.Value, itemCountEffective);
						args.levelDamageAdd += Utilities.GetLinearStacking(damagePerLevelPerStack.Value, damagePerLevelPerExtraStack.Value, itemCountEffective);
					}
				}
			}
		}

		public static ItemDef itemDef;

		public static ConfigurableValue<bool> isEnabled = new ConfigurableValue<bool>("Item: Glass Marbles", "Enabled", defaultValue: true, "Whether or not the item is enabled.", new List<string>(1) { "ITEM_GLASSMARBLES_DESC" });

		public static ConfigurableValue<float> damagePerLevelPerStack = new ConfigurableValue<float>("Item: Glass Marbles", "Damage Increase", 2f, "Amount of base damage gained per level per first stack.", new List<string>(1) { "ITEM_GLASSMARBLES_DESC" });

		public static ConfigurableValue<float> damagePerLevelPerExtraStack = new ConfigurableValue<float>("Item: Glass Marbles", "Damage Increase Extra Stacks", 2f, "Amount of base damage gained per level per extra stack.", new List<string>(1) { "ITEM_GLASSMARBLES_DESC" });

		internal static void Init()
		{
			itemDef = ItemManager.GenerateItem("GlassMarbles", (ItemTag[])(object)new ItemTag[2]
			{
				(ItemTag)1,
				(ItemTag)31
			}, (ItemTier)2);
			Hooks();
		}

		public static void Hooks()
		{
			//IL_0015: 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)
			//IL_0020: Expected O, but got Unknown
			object obj = <>c.<>9__5_0;
			if (obj == null)
			{
				StatHookEventHandler val = delegate(CharacterBody sender, StatHookEventArgs args)
				{
					if (Object.op_Implicit((Object)(object)sender) && Object.op_Implicit((Object)(object)sender.inventory))
					{
						int itemCountEffective = sender.inventory.GetItemCountEffective(itemDef);
						if (itemCountEffective > 0)
						{
							args.baseDamageAdd += Utilities.GetLinearStacking(damagePerLevelPerStack.Value, damagePerLevelPerExtraStack.Value, itemCountEffective);
							args.levelDamageAdd += Utilities.GetLinearStacking(damagePerLevelPerStack.Value, damagePerLevelPerExtraStack.Value, itemCountEffective);
						}
					}
				};
				<>c.<>9__5_0 = val;
				obj = (object)val;
			}
			RecalculateStatsAPI.GetStatCoefficients += (StatHookEventHandler)obj;
		}
	}
	internal class Horseshoe
	{
		public enum Bonuses
		{
			HEALTH,
			DAMAGE,
			ATTACK_SPEED,
			CRIT_CHANCE,
			CRIT_DAMAGE,
			ARMOR,
			HEALTH_REGEN,
			SHIELD,
			MOVEMENT_SPEED,
			NUM_STATS
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Action<CharacterMaster> <>9__16_0;

			public static Action<Stage> <>9__16_1;

			public static hook_GiveItemPermanent_ItemIndex_int <>9__16_2;

			public static hook_GiveItemTemp <>9__16_3;

			public static StatHookEventHandler <>9__16_4;

			internal void <Hooks>b__16_0(CharacterMaster obj)
			{
				Inventory inventory = obj.inventory;
				if (inventory != null)
				{
					((Component)inventory).gameObject.AddComponent<HorseshoeStatisticsHandler>();
				}
			}

			internal void <Hooks>b__16_1(Stage stage)
			{
				foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
				{
					CharacterMaster master = instance.master;
					if (Object.op_Implicit((Object)(object)master) && Object.op_Implicit((Object)(object)master.inventory) && master.inventory.GetItemCountEffective(itemDef) > 0)
					{
						Reroll(master.inventory, master.GetBody());
					}
				}
			}

			internal void <Hooks>b__16_2(orig_GiveItemPermanent_ItemIndex_int orig, Inventory self, ItemIndex index, int count)
			{
				//IL_001f: 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_0060: Unknown result type (might be due to invalid IL or missing references)
				HorseshoeStatisticsHandler component = ((Component)self).GetComponent<HorseshoeStatisticsHandler>();
				CharacterMaster component2 = ((Component)self).GetComponent<CharacterMaster>();
				if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component2) && index == itemDef.itemIndex && HasNotRolledYet(component) && Object.op_Implicit((Object)(object)component2.GetBody()))
				{
					Reroll(self, component2.GetBody());
				}
				orig.Invoke(self, index, count);
			}

			internal void <Hooks>b__16_3(orig_GiveItemTemp orig, Inventory self, ItemIndex index, float count)
			{
				//IL_001f: 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_0060: Unknown result type (might be due to invalid IL or missing references)
				HorseshoeStatisticsHandler component = ((Component)self).GetComponent<HorseshoeStatisticsHandler>();
				CharacterMaster component2 = ((Component)self).GetComponent<CharacterMaster>();
				if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component2) && index == itemDef.itemIndex && HasNotRolledYet(component) && Object.op_Implicit((Object)(object)component2.GetBody()))
				{
					Reroll(self, component2.GetBody());
				}
				orig.Invoke(self, index, count);
			}

			internal void <Hooks>b__16_4(CharacterBody sender, StatHookEventArgs args)
			{
				if (!Object.op_Implicit((Object)(object)sender) || !Object.op_Implicit((Object)(object)sender.inventory))
				{
					return;
				}
				int itemCountEffective = sender.inventory.GetItemCountEffective(itemDef);
				if (itemCountEffective > 0)
				{
					HorseshoeStatisticsHandler component = ((Component)sender.inventory).GetComponent<HorseshoeStatisticsHandler>();
					if (Object.op_Implicit((Object)(object)component))
					{
						args.baseHealthAdd += GetScaledValue(component.MaxHealthBonus, sender.level, itemCountEffective);
						args.baseDamageAdd += GetScaledValue(component.BaseDamageBonus, sender.level, itemCountEffective);
						args.attackSpeedMultAdd += GetScaledValue(component.AttackSpeedPercentBonus, sender.level, itemCountEffective);
						args.critAdd += GetScaledValue(component.CritChanceBonus, sender.level, itemCountEffective);
						args.critDamageMultAdd += GetScaledValue(component.CritDamageBonus, sender.level, itemCountEffective);
						args.armorAdd += GetScaledValue(component.ArmorBonus, sender.level, itemCountEffective);
						args.baseRegenAdd += GetScaledValue(component.RegenerationBonus, sender.level, itemCountEffective);
						args.baseShieldAdd += GetScaledValue(component.ShieldBonus, sender.level, itemCountEffective);
						args.moveSpeedMultAdd += GetScaledValue(component.MoveSpeedPercentBonus, sender.level, itemCountEffective);
					}
				}
			}
		}

		public static ItemDef itemDef;

		public static ConfigurableValue<bool> isEnabled = new ConfigurableValue<bool>("Item: Golden Horseshoe", "Enabled", defaultValue: true, "Whether or not the item is enabled.", new List<string>(1) { "ITEM_HORSESHOE_DESC" });

		public static ConfigurableValue<float> totalPointsCap = new ConfigurableValue<float>("Item: Golden Horseshoe", "Stat Points Cap", 18f, "Max value of stat points a reroll can have. See following configs for scalings.", new List<string>(1) { "ITEM_HORSESHOE_DESC" });

		public static ConfigurableValue<float> healthPerPoint = new ConfigurableValue<float>("Item: Golden Horseshoe", "Health Per Point", 12f, "Max health gained per stat point invested.", new List<string>(1) { "ITEM_HORSESHOE_DESC" });

		public static ConfigurableValue<float> damagePerPoint = new ConfigurableValue<float>("Item: Golden Horseshoe", "Damage Per Point", 0.75f, "Base damage gained per stat point invested.", new List<string>(1) { "ITEM_HORSESHOE_DESC" });

		public static ConfigurableValue<float> attackSpeedPerPoint = new ConfigurableValue<float>("Item: Golden Horseshoe", "Attack Speed Per Point", 4f, "Percent attack speed gained per stat point invested.", new List<string>(1) { "ITEM_HORSESHOE_DESC" });

		public static ConfigurableValue<float> critChancePerPoint = new ConfigurableValue<float>("Item: Golden Horseshoe", "Crit Chance Per Point", 2f, "Percent crit chance gained per stat point invested.", new List<string>(1) { "ITEM_HORSESHOE_DESC" });

		public static ConfigurableValue<float> critDamagePerPoint = new ConfigurableValue<float>("Item: Golden Horseshoe", "Crit Damage Per Point", 2f, "Percent crit damage gained per stat point invested.", new List<string>(1) { "ITEM_HORSESHOE_DESC" });

		public static ConfigurableValue<float> armorPerPoint = new ConfigurableValue<float>("Item: Golden Horseshoe", "Armor Per Point", 2f, "Armor gained per stat point invested.", new List<string>(1) { "ITEM_HORSESHOE_DESC" });

		public static ConfigurableValue<float> regenPerPoint = new ConfigurableValue<float>("Item: Golden Horseshoe", "Regeneration Per Point", 0.75f, "Regeneration gained per stat point invested.", new List<string>(1) { "ITEM_HORSESHOE_DESC" });

		public static ConfigurableValue<float> shieldPerPoint = new ConfigurableValue<float>("Item: Golden Horseshoe", "Shield Per Point", 15f, "Shield gained per stat point invested.", new List<string>(1) { "ITEM_HORSESHOE_DESC" });

		public static ConfigurableValue<float> moveSpeedPerPoint = new ConfigurableValue<float>("Item: Golden Horseshoe", "Move Speed Per Point", 4f, "Percent movement speed gained per stat point invested.", new List<string>(1) { "ITEM_HORSESHOE_DESC" });

		public static ConfigurableValue<float> extraStackMultiplier = new ConfigurableValue<float>("Item: Golden Horseshoe", "Increase for Additional Stacks", 30f, "Percent increase to all bonuses given for each additional stack.", new List<string>(1) { "ITEM_HORSESHOE_DESC" });

		public static float extraStackMultiplierPercent = extraStackMultiplier.Value / 100f;

		internal static void Init()
		{
			ItemTag[] array = new ItemTag[4];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			itemDef = ItemManager.GenerateItem("Horseshoe", (ItemTag[])(object)array, (ItemTier)2);
			NetworkingAPI.RegisterMessageType<HorseshoeStatisticsHandler.Sync>();
			Hooks();
		}

		public static void Hooks()
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			CharacterMaster.onStartGlobal += delegate(CharacterMaster obj)
			{
				Inventory inventory = obj.inventory;
				if (inventory != null)
				{
					((Component)inventory).gameObject.AddComponent<HorseshoeStatisticsHandler>();
				}
			};
			Stage.onStageStartGlobal += delegate
			{
				foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
				{
					CharacterMaster master = instance.master;
					if (Object.op_Implicit((Object)(object)master) && Object.op_Implicit((Object)(object)master.inventory) && master.inventory.GetItemCountEffective(itemDef) > 0)
					{
						Reroll(master.inventory, master.GetBody());
					}
				}
			};
			object obj2 = <>c.<>9__16_2;
			if (obj2 == null)
			{
				hook_GiveItemPermanent_ItemIndex_int val = delegate(orig_GiveItemPermanent_ItemIndex_int orig, Inventory self, ItemIndex index, int count)
				{
					//IL_001f: 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_0060: Unknown result type (might be due to invalid IL or missing references)
					HorseshoeStatisticsHandler component4 = ((Component)self).GetComponent<HorseshoeStatisticsHandler>();
					CharacterMaster component5 = ((Component)self).GetComponent<CharacterMaster>();
					if (Object.op_Implicit((Object)(object)component4) && Object.op_Implicit((Object)(object)component5) && index == itemDef.itemIndex && HasNotRolledYet(component4) && Object.op_Implicit((Object)(object)component5.GetBody()))
					{
						Reroll(self, component5.GetBody());
					}
					orig.Invoke(self, index, count);
				};
				<>c.<>9__16_2 = val;
				obj2 = (object)val;
			}
			Inventory.GiveItemPermanent_ItemIndex_int += (hook_GiveItemPermanent_ItemIndex_int)obj2;
			object obj3 = <>c.<>9__16_3;
			if (obj3 == null)
			{
				hook_GiveItemTemp val2 = delegate(orig_GiveItemTemp orig, Inventory self, ItemIndex index, float count)
				{
					//IL_001f: 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_0060: Unknown result type (might be due to invalid IL or missing references)
					HorseshoeStatisticsHandler component2 = ((Component)self).GetComponent<HorseshoeStatisticsHandler>();
					CharacterMaster component3 = ((Component)self).GetComponent<CharacterMaster>();
					if (Object.op_Implicit((Object)(object)component2) && Object.op_Implicit((Object)(object)component3) && index == itemDef.itemIndex && HasNotRolledYet(component2) && Object.op_Implicit((Object)(object)component3.GetBody()))
					{
						Reroll(self, component3.GetBody());
					}
					orig.Invoke(self, index, count);
				};
				<>c.<>9__16_3 = val2;
				obj3 = (object)val2;
			}
			Inventory.GiveItemTemp += (hook_GiveItemTemp)obj3;
			object obj4 = <>c.<>9__16_4;
			if (obj4 == null)
			{
				StatHookEventHandler val3 = delegate(CharacterBody sender, StatHookEventArgs args)
				{
					if (Object.op_Implicit((Object)(object)sender) && Object.op_Implicit((Object)(object)sender.inventory))
					{
						int itemCountEffective = sender.inventory.GetItemCountEffective(itemDef);
						if (itemCountEffective > 0)
						{
							HorseshoeStatisticsHandler component = ((Component)sender.inventory).GetComponent<HorseshoeStatisticsHandler>();
							if (Object.op_Implicit((Object)(object)component))
							{
								args.baseHealthAdd += GetScaledValue(component.MaxHealthBonus, sender.level, itemCountEffective);
								args.baseDamageAdd += GetScaledValue(component.BaseDamageBonus, sender.level, itemCountEffective);
								args.attackSpeedMultAdd += GetScaledValue(component.AttackSpeedPercentBonus, sender.level, itemCountEffective);
								args.critAdd += GetScaledValue(component.CritChanceBonus, sender.level, itemCountEffective);
								args.critDamageMultAdd += GetScaledValue(component.CritDamageBonus, sender.level, itemCountEffective);
								args.armorAdd += GetScaledValue(component.ArmorBonus, sender.level, itemCountEffective);
								args.baseRegenAdd += GetScaledValue(component.RegenerationBonus, sender.level, itemCountEffective);
								args.baseShieldAdd += GetScaledValue(component.ShieldBonus, sender.level, itemCountEffective);
								args.moveSpeedMultAdd += GetScaledValue(component.MoveSpeedPercentBonus, sender.level, itemCountEffective);
							}
						}
					}
				};
				<>c.<>9__16_4 = val3;
				obj4 = (object)val3;
			}
			RecalculateStatsAPI.GetStatCoefficients += (StatHookEventHandler)obj4;
		}

		public static float GetScaledValue(float value, float level, int count)
		{
			float num = (level + 11f) / 12f;
			float num2 = 1f + extraStackMultiplierPercent * (float)count;
			return value * num * num2;
		}

		public static bool HasNotRolledYet(HorseshoeStatisticsHandler bonuses)
		{
			if (bonuses.MaxHealthBonus != 0f)
			{
				return false;
			}
			if (bonuses.BaseDamageBonus != 0f)
			{
				return false;
			}
			if (bonuses.AttackSpeedPercentBonus != 0f)
			{
				return false;
			}
			if (bonuses.CritChanceBonus != 0f)
			{
				return false;
			}
			if (bonuses.CritDamageBonus != 0f)
			{
				return false;
			}
			if (bonuses.ArmorBonus != 0f)
			{
				return false;
			}
			if (bonuses.RegenerationBonus != 0f)
			{
				return false;
			}
			if (bonuses.ShieldBonus != 0f)
			{
				return false;
			}
			if (bonuses.MoveSpeedPercentBonus != 0f)
			{
				return false;
			}
			return true;
		}

		public static void Reroll(Inventory inventory, CharacterBody body)
		{
			HorseshoeStatisticsHandler component = ((Component)inventory).GetComponent<HorseshoeStatisticsHandler>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.MaxHealthBonus = 0f;
				component.BaseDamageBonus = 0f;
				component.AttackSpeedPercentBonus = 0f;
				component.CritChanceBonus = 0f;
				component.CritDamageBonus = 0f;
				component.ArmorBonus = 0f;
				component.RegenerationBonus = 0f;
				component.ShieldBonus = 0f;
				component.MoveSpeedPercentBonus = 0f;
				float num = totalPointsCap.Value;
				while (num > 0f)
				{
					float num2 = 1.8f;
					float num3 = (float)TooManyItems.RandGen.NextDouble() * num2 + num2;
					if (num - num3 < num2)
					{
						num3 = num;
					}
					switch ((Bonuses)TooManyItems.RandGen.Next(0, 9))
					{
					case Bonuses.HEALTH:
						component.MaxHealthBonus += num3 * healthPerPoint.Value;
						break;
					case Bonuses.DAMAGE:
						component.BaseDamageBonus += num3 * damagePerPoint.Value;
						break;
					case Bonuses.ATTACK_SPEED:
						component.AttackSpeedPercentBonus += num3 * attackSpeedPerPoint.Value / 100f;
						break;
					case Bonuses.CRIT_CHANCE:
						component.CritChanceBonus += num3 * critChancePerPoint.Value;
						break;
					case Bonuses.CRIT_DAMAGE:
						component.CritDamageBonus += num3 * critDamagePerPoint.Value / 100f;
						break;
					case Bonuses.ARMOR:
						component.ArmorBonus += num3 * armorPerPoint.Value;
						break;
					case Bonuses.HEALTH_REGEN:
						component.RegenerationBonus += num3 * regenPerPoint.Value;
						break;
					case Bonuses.SHIELD:
						component.ShieldBonus += num3 * shieldPerPoint.Value;
						break;
					case Bonuses.MOVEMENT_SPEED:
						component.MoveSpeedPercentBonus += num3 * moveSpeedPerPoint.Value / 100f;
						break;
					default:
						Log.Error("Attempted to boost an invalid stat.");
						break;
					}
					num -= num3;
				}
				Utilities.ForceRecalculate(body);
			}
			else
			{
				Log.Error("Unable to reroll Horseshoe statistics.");
			}
		}
	}
	internal class IronHeart
	{
		public class Statistics : MonoBehaviour
		{
			public class Sync : INetMessage, ISerializableObject
			{
				private NetworkInstanceId objId;

				private float totalDamageDealt;

				public Sync()
				{
				}

				public Sync(Network