Decompiled source of Prestige Items Beta v0.1.0

plugins/PrestigeItems/PrestigeItems.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HG.Reflection;
using Microsoft.CodeAnalysis;
using On.RoR2;
using PrestigeItems.Items;
using PrestigeItems.Util;
using R2API;
using RoR2;
using RoR2.Items;
using UnityEngine;
using UnityEngine.AddressableAssets;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("PrestigeItems")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+cf056c7ffe111fb691643dc9e5aa91fe9964225a")]
[assembly: AssemblyProduct("PrestigeItems")]
[assembly: AssemblyTitle("PrestigeItems")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace PrestigeItems
{
	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.*/)]
	[BepInPlugin("BlueB.PrestigeItemsMod", "PrestigeItemsMod", "0.0.1")]
	public class PrestigeItems : BaseUnityPlugin
	{
		public const string PluginGUID = "BlueB.PrestigeItemsMod";

		public const string PluginAuthor = "BlueB";

		public const string PluginName = "PrestigeItemsMod";

		public const string PluginVersion = "0.0.1";

		public static PluginInfo SavedInfo { get; private set; }

		public void Awake()
		{
			SavedInfo = ((BaseUnityPlugin)this).Info;
			Log.Init(((BaseUnityPlugin)this).Logger);
			AssetUtil.Init();
			Log.Debug("Asset Bundle loaded from stream. (allegedly)");
			DevCube.Init();
			PrestigeBleed.Init();
			PrestigeFungus.Init();
		}

		private void Update()
		{
		}
	}
}
namespace PrestigeItems.Util
{
	public static class AssetUtil
	{
		public static AssetBundle bundle;

		public const string bundleName = "prestigemodassets";

		public static Sprite defaultSprite = Addressables.LoadAssetAsync<Sprite>((object)"RoR2/Base/Common/MiscIcons/texMysteryIcon.png").WaitForCompletion();

		public static GameObject defaultModel = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Mystery/PickupMystery.prefab").WaitForCompletion();

		public static string AssetBundlePath => Path.Combine(Path.GetDirectoryName(PrestigeItems.SavedInfo.Location), "prestigemodassets");

		public static void Init()
		{
			bundle = AssetBundle.LoadFromFile(AssetBundlePath);
		}

		private static T SafeLoad<T>(string fileName) where T : Object
		{
			try
			{
				T val = bundle.LoadAsset<T>(fileName);
				if ((Object)(object)val == (Object)null)
				{
					Log.Debug("Asset " + fileName + " not found in the AssetBundle. Using fallback asset.");
				}
				return val;
			}
			catch (Exception ex)
			{
				Log.Error("Error loading asset " + fileName + ": " + ex.Message + "\n" + ex.StackTrace);
				return default(T);
			}
		}

		public static Sprite LoadSprite(string filename)
		{
			if (!filename.Contains("."))
			{
				filename += ".png";
			}
			return SafeLoad<Sprite>(filename) ?? defaultSprite;
		}

		public static GameObject LoadModel(string filename)
		{
			if (!filename.Contains("."))
			{
				filename += ".prefab";
			}
			return SafeLoad<GameObject>(filename) ?? defaultModel;
		}

		public static Sprite LoadBaseGameSprite(string path)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return Addressables.LoadAssetAsync<Sprite>((object)path).WaitForCompletion();
		}

		public static GameObject LoadBaseGameModel(string path)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return Addressables.LoadAssetAsync<GameObject>((object)path).WaitForCompletion();
		}
	}
}
namespace PrestigeItems.Items
{
	internal class ItemTemplate
	{
		public static ItemDef itemDef;

		private static string itemId = "";

		internal static void Init()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			GenerateItem();
			AddTokens();
			ItemDisplayRuleDict val = new ItemDisplayRuleDict((ItemDisplayRule[])null);
			ItemAPI.Add(new CustomItem(itemDef, val));
			Hooks();
		}

		private static void GenerateItem()
		{
			itemDef = ScriptableObject.CreateInstance<ItemDef>();
			itemId = itemId.Replace(" ", "").ToUpper();
			((Object)itemDef).name = itemId;
			itemDef.nameToken = itemId + "_NAME";
			itemDef.pickupToken = itemId + "_PICKUP";
			itemDef.descriptionToken = itemId + "_DESCRIPTION";
			itemDef.loreToken = itemId + "_LORE";
			((ResourceAvailability)(ref ItemTierCatalog.availability)).CallWhenAvailable((Action)delegate
			{
				if (Object.op_Implicit((Object)(object)itemDef))
				{
					itemDef.tier = (ItemTier)0;
				}
			});
			itemDef.pickupIconSprite = AssetUtil.LoadSprite("");
			itemDef.pickupModelPrefab = AssetUtil.LoadModel("");
			itemDef.canRemove = true;
			itemDef.hidden = false;
			itemDef.tags = (ItemTag[])(object)new ItemTag[2]
			{
				(ItemTag)11,
				(ItemTag)3
			};
		}

		public static void Hooks()
		{
		}

		private static void AddTokens()
		{
			LanguageAPI.Add(itemId ?? "", "Item Name");
			LanguageAPI.Add(itemId + "_NAME", "Item Name");
			LanguageAPI.Add(itemId + "_PICKUP", "Pickup Flavor Text / Basic Description");
			LanguageAPI.Add(itemId + "_DESCRIPTION", "A Detailed Description of the Item's Mechanics.");
			string text = "Lore Text";
			LanguageAPI.Add(itemId + "_LORE", text);
		}
	}
	internal class Boilerplate
	{
		public static ItemDef myItemDef;

		internal static void Init()
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			myItemDef = ScriptableObject.CreateInstance<ItemDef>();
			((Object)myItemDef).name = "EXAMPLE_CLOAKONKILL_NAME";
			myItemDef.nameToken = "EXAMPLE_CLOAKONKILL_NAME";
			myItemDef.pickupToken = "EXAMPLE_CLOAKONKILL_PICKUP";
			myItemDef.descriptionToken = "EXAMPLE_CLOAKONKILL_DESC";
			myItemDef.loreToken = "EXAMPLE_CLOAKONKILL_LORE";
			myItemDef._itemTierDef = Addressables.LoadAssetAsync<ItemTierDef>((object)"RoR2/Base/Common/Tier2Def.asset").WaitForCompletion();
			myItemDef.pickupIconSprite = Addressables.LoadAssetAsync<Sprite>((object)"RoR2/Base/Common/MiscIcons/texMysteryIcon.png").WaitForCompletion();
			myItemDef.pickupModelPrefab = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Mystery/PickupMystery.prefab").WaitForCompletion();
			myItemDef.canRemove = true;
			myItemDef.hidden = false;
			ItemDisplayRuleDict val = new ItemDisplayRuleDict((ItemDisplayRule[])null);
			ItemAPI.Add(new CustomItem(myItemDef, val));
			GlobalEventManager.onCharacterDeathGlobal += GlobalEventManager_onCharacterDeathGlobal;
		}

		private static void GlobalEventManager_onCharacterDeathGlobal(DamageReport report)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)report.attacker) || !Object.op_Implicit((Object)(object)report.attackerBody))
			{
				return;
			}
			CharacterBody attackerBody = report.attackerBody;
			if (Object.op_Implicit((Object)(object)attackerBody.inventory))
			{
				int itemCount = attackerBody.inventory.GetItemCount(myItemDef.itemIndex);
				if (itemCount > 0 && Util.CheckRoll(50f, attackerBody.master))
				{
					attackerBody.AddTimedBuff(Buffs.Cloak, (float)(3 + itemCount));
				}
			}
		}

		private static void AddTokens()
		{
			((Object)myItemDef).name = "EXAMPLE_CLOAKONKILL_NAME";
			myItemDef.nameToken = "EXAMPLE_CLOAKONKILL_NAME";
			myItemDef.pickupToken = "EXAMPLE_CLOAKONKILL_PICKUP";
			myItemDef.descriptionToken = "EXAMPLE_CLOAKONKILL_DESC";
			myItemDef.loreToken = "EXAMPLE_CLOAKONKILL_LORE";
			LanguageAPI.Add("EXAMPLE_CLOAKONKILL_NAME", "Cuthroat's Garb");
			LanguageAPI.Add("EXAMPLE_CLOAKONKILL_PICKUP", "chance to cloak on kill.");
			LanguageAPI.Add("DEVCUBE_DESCRIPTION", "Whenever you <style=cIsDamage>kill an enemy</style>, you have a <style=cIsUtility>50%</style> chance to cloak for <style=cIsUtility>4s</style> <style=cStack>(+1s per stack)</style>.");
			string text = "Those who visit in the night are either praying for a favour, or preying on a neighbour.";
			LanguageAPI.Add("DEVCUBE_LORE", text);
		}
	}
	internal class DevCube
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_OnCharacterDeath <>9__4_0;

			internal void <Hooks>b__4_0(orig_OnCharacterDeath orig, GlobalEventManager eventManager, DamageReport damageReport)
			{
				orig.Invoke(eventManager, damageReport);
				if (!Object.op_Implicit((Object)(object)damageReport.attacker) || !Object.op_Implicit((Object)(object)damageReport.attackerBody))
				{
					return;
				}
				CharacterBody attackerBody = damageReport.attackerBody;
				if (Object.op_Implicit((Object)(object)attackerBody.inventory))
				{
					int itemCount = attackerBody.inventory.GetItemCount(itemDef);
					if (itemCount > 0)
					{
						List<BuffDef> list = new List<BuffDef>
						{
							Buffs.ArmorBoost,
							Buffs.AttackSpeedOnCrit,
							Buffs.BanditSkull,
							Buffs.AffixHauntedRecipient,
							Buffs.Cloak,
							Buffs.CloakSpeed,
							Buffs.ImmuneToDebuffReady,
							Buffs.ElementalRingsReady,
							Buffs.ElephantArmorBoost,
							Buffs.Energized,
							Buffs.FullCrit,
							Buffs.Immune,
							Buffs.HiddenInvincibility,
							Buffs.KillMoveSpeed,
							Buffs.LifeSteal,
							Buffs.MedkitHeal,
							Buffs.NoCooldowns,
							Buffs.OutOfCombatArmorBuff,
							Buffs.PowerBuff,
							Buffs.CrocoRegen,
							Buffs.LaserTurbineKillCharge,
							Buffs.BearVoidReady,
							Buffs.PrimarySkillShurikenBuff,
							Buffs.ElementalRingVoidReady,
							Buffs.SmallArmorBoost,
							Buffs.TeamWarCry,
							Buffs.TeslaField,
							Buffs.TonicBuff,
							Buffs.VoidSurvivorCorruptMode,
							Buffs.WarCryBuff,
							Buffs.Warbanner,
							Buffs.MushroomVoidActive,
							Buffs.WhipBoost,
							Buffs.AffixRed,
							Buffs.AffixHaunted,
							Buffs.AffixWhite,
							Buffs.AffixPoison,
							Buffs.EliteEarth,
							Buffs.AffixBlue,
							Buffs.AffixLunar,
							Buffs.EliteVoid
						};
						Log.Debug("Enemy killed with Dev Cube in attacker's inventory. BuffList initialized. Conditions met, calculating buff...");
						int index = random.Next(list.Count);
						Log.Debug("Applying " + ((Object)list[index]).name + " to attacker.");
						attackerBody.AddTimedBuff(list[index], (float)(3 + itemCount));
					}
				}
			}
		}

		public static ItemDef itemDef;

		private static Random random = new Random();

		internal static void Init()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			GenerateItem();
			AddTokens();
			ItemDisplayRuleDict val = new ItemDisplayRuleDict((ItemDisplayRule[])null);
			ItemAPI.Add(new CustomItem(itemDef, val));
			Hooks();
		}

		private static void GenerateItem()
		{
			itemDef = ScriptableObject.CreateInstance<ItemDef>();
			((Object)itemDef).name = "DEVCUBE";
			itemDef.nameToken = "DEVCUBE_NAME";
			itemDef.pickupToken = "DEVCUBE_PICKUP";
			itemDef.descriptionToken = "DEVCUBE_DESCRIPTION";
			itemDef.loreToken = "DEVCUBE_LORE";
			itemDef.tier = (ItemTier)0;
			itemDef.pickupIconSprite = AssetUtil.LoadSprite("DevCube.png");
			itemDef.pickupModelPrefab = AssetUtil.LoadModel("DevCube.prefab");
			itemDef.canRemove = true;
			itemDef.hidden = false;
			ItemDef obj = itemDef;
			ItemTag[] array = new ItemTag[3];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			obj.tags = (ItemTag[])(object)array;
		}

		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__4_0;
			if (obj == null)
			{
				hook_OnCharacterDeath val = delegate(orig_OnCharacterDeath orig, GlobalEventManager eventManager, DamageReport damageReport)
				{
					orig.Invoke(eventManager, damageReport);
					if (Object.op_Implicit((Object)(object)damageReport.attacker) && Object.op_Implicit((Object)(object)damageReport.attackerBody))
					{
						CharacterBody attackerBody = damageReport.attackerBody;
						if (Object.op_Implicit((Object)(object)attackerBody.inventory))
						{
							int itemCount = attackerBody.inventory.GetItemCount(itemDef);
							if (itemCount > 0)
							{
								List<BuffDef> list = new List<BuffDef>
								{
									Buffs.ArmorBoost,
									Buffs.AttackSpeedOnCrit,
									Buffs.BanditSkull,
									Buffs.AffixHauntedRecipient,
									Buffs.Cloak,
									Buffs.CloakSpeed,
									Buffs.ImmuneToDebuffReady,
									Buffs.ElementalRingsReady,
									Buffs.ElephantArmorBoost,
									Buffs.Energized,
									Buffs.FullCrit,
									Buffs.Immune,
									Buffs.HiddenInvincibility,
									Buffs.KillMoveSpeed,
									Buffs.LifeSteal,
									Buffs.MedkitHeal,
									Buffs.NoCooldowns,
									Buffs.OutOfCombatArmorBuff,
									Buffs.PowerBuff,
									Buffs.CrocoRegen,
									Buffs.LaserTurbineKillCharge,
									Buffs.BearVoidReady,
									Buffs.PrimarySkillShurikenBuff,
									Buffs.ElementalRingVoidReady,
									Buffs.SmallArmorBoost,
									Buffs.TeamWarCry,
									Buffs.TeslaField,
									Buffs.TonicBuff,
									Buffs.VoidSurvivorCorruptMode,
									Buffs.WarCryBuff,
									Buffs.Warbanner,
									Buffs.MushroomVoidActive,
									Buffs.WhipBoost,
									Buffs.AffixRed,
									Buffs.AffixHaunted,
									Buffs.AffixWhite,
									Buffs.AffixPoison,
									Buffs.EliteEarth,
									Buffs.AffixBlue,
									Buffs.AffixLunar,
									Buffs.EliteVoid
								};
								Log.Debug("Enemy killed with Dev Cube in attacker's inventory. BuffList initialized. Conditions met, calculating buff...");
								int index = random.Next(list.Count);
								Log.Debug("Applying " + ((Object)list[index]).name + " to attacker.");
								attackerBody.AddTimedBuff(list[index], (float)(3 + itemCount));
							}
						}
					}
				};
				<>c.<>9__4_0 = val;
				obj = (object)val;
			}
			GlobalEventManager.OnCharacterDeath += (hook_OnCharacterDeath)obj;
		}

		private static void AddTokens()
		{
			LanguageAPI.Add("DEVCUBE", "Dev Cube");
			LanguageAPI.Add("DEVCUBE_NAME", "Dev Cube");
			LanguageAPI.Add("DEVCUBE_PICKUP", "Applies a random buff upon killing an enemy.");
			LanguageAPI.Add("DEVCUBE_DESCRIPTION", "<style=cHumanObjective>On kill</style>, grants the holder a <style=cLunarObjective>random buff </style> for <style=cIsUtility>4</style> <style=cStack>(+1 per stack)</style> seconds.");
			string text = "This is my first custom item. I'll probably use it for testing purposes. Did you read this lore text?";
			LanguageAPI.Add("DEVCUBE_LORE", text);
		}
	}
	internal class PrestigeBleed
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Action <>9__3_0;

			public static hook_OnHitEnemy <>9__4_0;

			internal void <GenerateItem>b__3_0()
			{
				if (Object.op_Implicit((Object)(object)itemDef))
				{
					itemDef.tier = (ItemTier)1;
				}
			}

			internal void <Hooks>b__4_0(orig_OnHitEnemy orig, GlobalEventManager self, DamageInfo damageInfo, GameObject victim)
			{
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				orig.Invoke(self, damageInfo, victim);
				CharacterBody component = damageInfo.attacker.GetComponent<CharacterBody>();
				CharacterBody component2 = victim.GetComponent<CharacterBody>();
				if ((Object)(object)component != (Object)null && (Object)(object)component2 != (Object)null)
				{
					int itemCount = component.inventory.GetItemCount(itemDef.itemIndex);
					if (itemCount > 0 && Util.CheckRoll((10f + 5f * (float)(itemCount - 1)) * damageInfo.procCoefficient, component.master))
					{
						float num = (10f + 5f * (float)(itemCount - 1)) * damageInfo.procCoefficient;
						Log.Debug($"Enemy hit with Prestige Bleed. Player has {itemCount} stacks in inventory with a total chance of {num}%. Playable character used an attack with a proc coefficient of {damageInfo.procCoefficient}");
						component2.AddTimedBuff(Buffs.Cripple, 3f);
					}
				}
			}
		}

		public static ItemDef itemDef;

		private static string itemId = "PRESTIGEBLEED";

		internal static void Init()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			GenerateItem();
			AddTokens();
			ItemDisplayRuleDict val = new ItemDisplayRuleDict((ItemDisplayRule[])null);
			ItemAPI.Add(new CustomItem(itemDef, val));
			Hooks();
		}

		private static void GenerateItem()
		{
			itemDef = ScriptableObject.CreateInstance<ItemDef>();
			itemId = itemId.Replace(" ", "").ToUpper();
			((Object)itemDef).name = itemId;
			itemDef.nameToken = itemId + "_NAME";
			itemDef.pickupToken = itemId + "_PICKUP";
			itemDef.descriptionToken = itemId + "_DESCRIPTION";
			itemDef.loreToken = itemId + "_LORE";
			((ResourceAvailability)(ref ItemTierCatalog.availability)).CallWhenAvailable((Action)delegate
			{
				if (Object.op_Implicit((Object)(object)itemDef))
				{
					itemDef.tier = (ItemTier)1;
				}
			});
			itemDef.pickupIconSprite = AssetUtil.LoadSprite("PrestigeBleed_Alt.png");
			itemDef.pickupModelPrefab = AssetUtil.LoadModel("PrestigeBleed.prefab");
			itemDef.canRemove = true;
			itemDef.hidden = false;
			itemDef.tags = (ItemTag[])(object)new ItemTag[1] { (ItemTag)1 };
		}

		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__4_0;
			if (obj == null)
			{
				hook_OnHitEnemy val = delegate(orig_OnHitEnemy orig, GlobalEventManager self, DamageInfo damageInfo, GameObject victim)
				{
					//IL_0046: Unknown result type (might be due to invalid IL or missing references)
					orig.Invoke(self, damageInfo, victim);
					CharacterBody component = damageInfo.attacker.GetComponent<CharacterBody>();
					CharacterBody component2 = victim.GetComponent<CharacterBody>();
					if ((Object)(object)component != (Object)null && (Object)(object)component2 != (Object)null)
					{
						int itemCount = component.inventory.GetItemCount(itemDef.itemIndex);
						if (itemCount > 0 && Util.CheckRoll((10f + 5f * (float)(itemCount - 1)) * damageInfo.procCoefficient, component.master))
						{
							float num = (10f + 5f * (float)(itemCount - 1)) * damageInfo.procCoefficient;
							Log.Debug($"Enemy hit with Prestige Bleed. Player has {itemCount} stacks in inventory with a total chance of {num}%. Playable character used an attack with a proc coefficient of {damageInfo.procCoefficient}");
							component2.AddTimedBuff(Buffs.Cripple, 3f);
						}
					}
				};
				<>c.<>9__4_0 = val;
				obj = (object)val;
			}
			GlobalEventManager.OnHitEnemy += (hook_OnHitEnemy)obj;
		}

		private static void AddTokens()
		{
			LanguageAPI.Add(itemId ?? "", "Refined Shard");
			LanguageAPI.Add(itemId + "_NAME", "Refined Shard");
			LanguageAPI.Add(itemId + "_PICKUP", "Chance to cripple enemies on hit.");
			LanguageAPI.Add(itemId + "_DESCRIPTION", "<style=cIsDamage>10%</style> <style=cStack>(+5% per stack)</style> chance to inflict <style=cLunarObjective>cripple</style> on an enemy.");
			string text = "10 years ago I saw a woman get dragged away by five men and i did nothing to stop it";
			LanguageAPI.Add(itemId + "_LORE", text);
		}
	}
	internal class PrestigeFungus
	{
		public class PrestigeFungusBehavior : BaseItemBodyBehavior
		{
			private float sprintTimer = 1f;

			[ItemDefAssociation(useOnServer = true, useOnClient = false)]
			public static ItemDef GetItemDef()
			{
				return itemDef;
			}

			private void onEnable()
			{
			}

			private void FixedUpdate()
			{
				//IL_0067: Unknown result type (might be due to invalid IL or missing references)
				if (((BaseItemBodyBehavior)this).body.isSprinting)
				{
					sprintTimer -= Time.fixedDeltaTime;
					if (sprintTimer <= 0f && ((BaseItemBodyBehavior)this).body.moveSpeed > 0f)
					{
						double num = basePercentGained + percentGainedPerStack * (float)(((BaseItemBodyBehavior)this).body.inventory.GetItemCount(itemDef.itemIndex) - 1);
						((BaseItemBodyBehavior)this).body.master.GiveMoney((uint)(int)Math.Ceiling(num * (double)chestPrice));
						sprintTimer = 1f;
					}
				}
			}
		}

		public static ItemDef itemDef;

		private static string itemId = "PRESTIGEFUNGUS";

		private static int chestPrice = 25;

		private static float basePercentGained = 0.04f;

		private static float percentGainedPerStack = 0.02f;

		internal static void Init()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			GenerateItem();
			AddTokens();
			ItemDisplayRuleDict val = new ItemDisplayRuleDict((ItemDisplayRule[])null);
			ItemAPI.Add(new CustomItem(itemDef, val));
			Hooks();
		}

		private static void GenerateItem()
		{
			itemDef = ScriptableObject.CreateInstance<ItemDef>();
			itemId = itemId.Replace(" ", "").ToUpper();
			((Object)itemDef).name = itemId;
			itemDef.nameToken = itemId + "_NAME";
			itemDef.pickupToken = itemId + "_PICKUP";
			itemDef.descriptionToken = itemId + "_DESCRIPTION";
			itemDef.loreToken = itemId + "_LORE";
			((ResourceAvailability)(ref ItemTierCatalog.availability)).CallWhenAvailable((Action)delegate
			{
				if (Object.op_Implicit((Object)(object)itemDef))
				{
					itemDef.tier = (ItemTier)1;
				}
			});
			itemDef.pickupIconSprite = AssetUtil.LoadSprite("PrestigeFungus_Alt.png");
			itemDef.pickupModelPrefab = AssetUtil.LoadModel("PrestigeFungus.prefab");
			itemDef.canRemove = true;
			itemDef.hidden = false;
			ItemDef obj = itemDef;
			ItemTag[] array = new ItemTag[3];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			obj.tags = (ItemTag[])(object)array;
		}

		public static void Hooks()
		{
			Stage.onStageStartGlobal += delegate
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Invalid comparison between Unknown and I4
				PurchaseInteraction[] array = Object.FindObjectsOfType<PurchaseInteraction>();
				PurchaseInteraction[] array2 = array;
				foreach (PurchaseInteraction val in array2)
				{
					if (((Object)val).name.Contains("Chest1") && (int)val.costType == 1)
					{
						chestPrice = val.cost;
						Log.Debug($"Found chest price at {chestPrice}");
						break;
					}
				}
			};
		}

		private static void AddTokens()
		{
			LanguageAPI.Add(itemId ?? "", "Charting Fungus");
			LanguageAPI.Add(itemId + "_NAME", "Charting Fungus");
			LanguageAPI.Add(itemId + "_PICKUP", "Gain gold while sprinting.");
			LanguageAPI.Add(itemId + "_DESCRIPTION", $"<style=cIsUtility>Gain {basePercentGained * 100f}%</style> <style=cStack>(+{percentGainedPerStack * 100f}% per stack)</style> of the price of a <style=cHumanObjective>small chest in gold</style> every second <style=cIsUtility>while sprinting.</style>");
			string text = "Hello :D \n\n I like money :D";
			LanguageAPI.Add(itemId + "_LORE", text);
		}
	}
}