Decompiled source of Prestige Items Beta v0.2.0

plugins/PrestigeItems/PrestigeItems.dll

Decompiled 4 months 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+7fdc85a623dad6f0146cfd4f95c20a58e916c524")]
[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.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 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.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("BlueB.PrestigeItemsMod", "PrestigeItemsMod", "0.2.0")]
	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.2.0";

		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();
			PrestigeBauble.Init();
			PrestigeSymbiote.Init();
		}

		private void Update()
		{
		}

		private void debugSpawnItem(ItemDef itemDef, KeyCode keyTrigger)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown(keyTrigger))
			{
				Transform transform = PlayerCharacterMasterController.instances[0].master.GetBodyObject().transform;
				Log.Info($"Player pressed {keyTrigger}. Spawning our custom item {((Object)itemDef).name} at coordinates {transform.position}");
				PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(itemDef.itemIndex), transform.position, transform.forward * 20f);
			}
		}
	}
}
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 PrestigeBauble
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Action <>9__6_0;

			public static Action<Run> <>9__7_0;

			public static hook_OnHitEnemy <>9__7_1;

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

			internal void <Hooks>b__7_0(Run orig)
			{
				progressionList = new List<BuffDef>
				{
					Buffs.Slow50,
					Buffs.ClayGoo,
					Buffs.Slow60,
					Buffs.Slow80,
					Buffs.Nullified,
					Buffs.LunarSecondaryRoot
				};
				Log.Debug("PrestigeBauble's Progession List has been initialized.");
			}

			internal void <Hooks>b__7_1(orig_OnHitEnemy orig, GlobalEventManager self, DamageInfo damageInfo, GameObject victim)
			{
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_0151: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cb: 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))
				{
					return;
				}
				int itemCount = component.inventory.GetItemCount(itemDef.itemIndex);
				float num = (float)(basePercent + stackPercent * (itemCount - 1)) * damageInfo.procCoefficient;
				if (itemCount <= 0 || !Util.CheckRoll(num, component.master))
				{
					return;
				}
				if (component2.HasBuff(Buffs.LunarSecondaryRoot))
				{
					float num2 = 0f;
					List<TimedBuff> timedBuffs = component2.timedBuffs;
					foreach (TimedBuff item in timedBuffs)
					{
						if (item.buffIndex == Buffs.LunarSecondaryRoot.buffIndex)
						{
							num2 = item.timer;
						}
					}
					component2.AddTimedBuff(Buffs.LunarSecondaryRoot, 3f + num2);
					return;
				}
				for (int num3 = progressionList.Count - 2; num3 >= 0; num3--)
				{
					if (component2.HasBuff(progressionList[num3]))
					{
						component2.ClearTimedBuffs(progressionList[num3].buffIndex);
						if (num3 == progressionList.Count - 2)
						{
							component2.AddTimedBuff(progressionList[num3 + 1], 3f);
						}
						else
						{
							component2.AddTimedBuff(progressionList[num3 + 1], 5f);
						}
						return;
					}
				}
				component2.AddTimedBuff(progressionList[0], 5f);
			}
		}

		public static ItemDef itemDef;

		private static string itemId = "PRESTIGEBAUBLE";

		private static int basePercent = 10;

		private static int stackPercent = 10;

		private static List<BuffDef> progressionList;

		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)2;
				}
			});
			itemDef.pickupIconSprite = AssetUtil.LoadSprite("PrestigeBauble_Alt");
			itemDef.pickupModelPrefab = AssetUtil.LoadModel("PrestigeBauble");
			itemDef.canRemove = true;
			itemDef.hidden = false;
			itemDef.tags = (ItemTag[])(object)new ItemTag[1] { (ItemTag)3 };
		}

		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
			Run.onRunStartGlobal += delegate
			{
				progressionList = new List<BuffDef>
				{
					Buffs.Slow50,
					Buffs.ClayGoo,
					Buffs.Slow60,
					Buffs.Slow80,
					Buffs.Nullified,
					Buffs.LunarSecondaryRoot
				};
				Log.Debug("PrestigeBauble's Progession List has been initialized.");
			};
			object obj = <>c.<>9__7_1;
			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)
					//IL_0151: Unknown result type (might be due to invalid IL or missing references)
					//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
					//IL_00cb: 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);
						float num = (float)(basePercent + stackPercent * (itemCount - 1)) * damageInfo.procCoefficient;
						if (itemCount > 0 && Util.CheckRoll(num, component.master))
						{
							if (component2.HasBuff(Buffs.LunarSecondaryRoot))
							{
								float num2 = 0f;
								List<TimedBuff> timedBuffs = component2.timedBuffs;
								foreach (TimedBuff item in timedBuffs)
								{
									if (item.buffIndex == Buffs.LunarSecondaryRoot.buffIndex)
									{
										num2 = item.timer;
									}
								}
								component2.AddTimedBuff(Buffs.LunarSecondaryRoot, 3f + num2);
							}
							else
							{
								for (int num3 = progressionList.Count - 2; num3 >= 0; num3--)
								{
									if (component2.HasBuff(progressionList[num3]))
									{
										component2.ClearTimedBuffs(progressionList[num3].buffIndex);
										if (num3 == progressionList.Count - 2)
										{
											component2.AddTimedBuff(progressionList[num3 + 1], 3f);
										}
										else
										{
											component2.AddTimedBuff(progressionList[num3 + 1], 5f);
										}
										return;
									}
								}
								component2.AddTimedBuff(progressionList[0], 5f);
							}
						}
					}
				};
				<>c.<>9__7_1 = val;
				obj = (object)val;
			}
			GlobalEventManager.OnHitEnemy += (hook_OnHitEnemy)obj;
		}

		private static void AddTokens()
		{
			LanguageAPI.Add(itemId ?? "", "Promobauble");
			LanguageAPI.Add(itemId + "_NAME", "Promobauble");
			LanguageAPI.Add(itemId + "_PICKUP", "Gain the ability to inflict and promote slowness debuffs on enemies until they are rooted.");
			LanguageAPI.Add(itemId + "_DESCRIPTION", $"<style=cIsUtility>{basePercent}%</style> <style=cStack>(+{stackPercent}% per stack)</style> chance to <style=cWorldEvent>promote</style> the <style=cIsUtility>current slowing debuff</style> on the enemy to the <style=cIsUtility>next tier of slowness</style>. Inflicts a <style=cIsUtility>low-level slow</style> to enemies who have <style=cIsUtility>no slowness debuffs</style>.");
			string text = "\"Wait a minute, that just sounds like Tentabauble with extra steps!\" \n\n(That's what you sound like I bet.)";
			LanguageAPI.Add(itemId + "_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);
		}
	}
	internal class PrestigeSymbiote
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Action <>9__4_0;

			public static StatHookEventHandler <>9__5_0;

			public static hook_OnInventoryChanged <>9__5_1;

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

			internal void <Hooks>b__5_0(CharacterBody sender, StatHookEventArgs args)
			{
				if ((Object)(object)sender == (Object)null || (Object)(object)sender.inventory == (Object)null)
				{
					return;
				}
				int itemCount = sender.inventory.GetItemCount(itemDef);
				if (itemCount > 0)
				{
					args.healthMultAdd -= 0.5f;
					args.baseShieldAdd += sender.maxHealth;
					if (sender.healthComponent.shield > 0f)
					{
						args.healthMultAdd += (float)itemCount * commonScaling;
						args.regenMultAdd += (float)itemCount * commonScaling;
						args.moveSpeedMultAdd += (float)itemCount * commonScaling;
						args.damageMultAdd += (float)itemCount * commonScaling;
						args.attackSpeedMultAdd += (float)itemCount * commonScaling;
						args.critAdd += (float)itemCount * (commonScaling * 100f);
						args.armorAdd += (float)itemCount * (commonScaling * 100f);
					}
				}
			}

			internal void <Hooks>b__5_1(orig_OnInventoryChanged orig, CharacterBody body)
			{
				orig.Invoke(body);
				if (body.inventory.GetItemCount(itemDef) == 1)
				{
					float num = body.maxHealth / 2f;
					body.maxHealth -= num;
					body.maxShield += num;
					if (body.healthComponent.health > body.maxHealth)
					{
						body.healthComponent.health = body.maxHealth;
					}
					if (body.healthComponent.shield > body.maxShield)
					{
						body.healthComponent.shield = body.maxShield;
					}
				}
				body.RecalculateStats();
			}
		}

		public static ItemDef itemDef;

		private static string itemId = "PRESTIGESYMBIOTE";

		private static readonly float commonScaling = 0.1f;

		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)3;
				}
			});
			itemDef.pickupIconSprite = AssetUtil.LoadSprite("PrestigeSymbiote_Alt.png");
			itemDef.pickupModelPrefab = AssetUtil.LoadModel("PrestigeSymbioteClean.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
			//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__5_0;
			if (obj == null)
			{
				StatHookEventHandler val = delegate(CharacterBody sender, StatHookEventArgs args)
				{
					if (!((Object)(object)sender == (Object)null) && !((Object)(object)sender.inventory == (Object)null))
					{
						int itemCount = sender.inventory.GetItemCount(itemDef);
						if (itemCount > 0)
						{
							args.healthMultAdd -= 0.5f;
							args.baseShieldAdd += sender.maxHealth;
							if (sender.healthComponent.shield > 0f)
							{
								args.healthMultAdd += (float)itemCount * commonScaling;
								args.regenMultAdd += (float)itemCount * commonScaling;
								args.moveSpeedMultAdd += (float)itemCount * commonScaling;
								args.damageMultAdd += (float)itemCount * commonScaling;
								args.attackSpeedMultAdd += (float)itemCount * commonScaling;
								args.critAdd += (float)itemCount * (commonScaling * 100f);
								args.armorAdd += (float)itemCount * (commonScaling * 100f);
							}
						}
					}
				};
				<>c.<>9__5_0 = val;
				obj = (object)val;
			}
			RecalculateStatsAPI.GetStatCoefficients += (StatHookEventHandler)obj;
			object obj2 = <>c.<>9__5_1;
			if (obj2 == null)
			{
				hook_OnInventoryChanged val2 = delegate(orig_OnInventoryChanged orig, CharacterBody body)
				{
					orig.Invoke(body);
					if (body.inventory.GetItemCount(itemDef) == 1)
					{
						float num = body.maxHealth / 2f;
						body.maxHealth -= num;
						body.maxShield += num;
						if (body.healthComponent.health > body.maxHealth)
						{
							body.healthComponent.health = body.maxHealth;
						}
						if (body.healthComponent.shield > body.maxShield)
						{
							body.healthComponent.shield = body.maxShield;
						}
					}
					body.RecalculateStats();
				};
				<>c.<>9__5_1 = val2;
				obj2 = (object)val2;
			}
			CharacterBody.OnInventoryChanged += (hook_OnInventoryChanged)obj2;
		}

		private static void AddTokens()
		{
			LanguageAPI.Add(itemId ?? "", "Parasitic Symbiosis");
			LanguageAPI.Add(itemId + "_NAME", "Parasitic Symbiosis");
			LanguageAPI.Add(itemId + "_PICKUP", "Half your health is shield, but ALL of your stats are buffed while your shields are up.");
			LanguageAPI.Add(itemId + "_DESCRIPTION", "<style=cIsHealing>Convert half your health</style> to <style=cIsHealing>regenerating shields</style>. " + $"<style=cIsUtility>ALL stats</style> are buffed by <style=cIsUtility>{commonScaling * 100f}%</style> " + $"<style=cStack>(+{commonScaling * 100f}% per stack)</style> while you have a <style=cIsHealing>shield active</style>.");
			string text = "Two bugs, sitting in a yin-yang, five feet apart because they are in perfect harmony <3";
			LanguageAPI.Add(itemId + "_LORE", text);
		}
	}
}