Decompiled source of ConsumedBuff v1.3.0

plugins/ConsumedBuff.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using ConsumedBuff.Components;
using ConsumedBuff.ItemChanges;
using ConsumedBuff.Modules;
using HG;
using On.RoR2;
using R2API;
using RoR2;
using RoR2.ContentManagement;
using RoR2.Items;
using RoR2.Projectile;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;

[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 = "")]
[assembly: AssemblyCompany("ConsumedBuff")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ConsumedBuff")]
[assembly: AssemblyTitle("ConsumedBuff")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ConsumedBuff
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.kking117.ConsumedBuff", "ConsumedBuff", "1.3.0")]
	public class MainPlugin : BaseUnityPlugin
	{
		public const string MODUID = "com.kking117.ConsumedBuff";

		public const string MODNAME = "ConsumedBuff";

		public const string MODVERSION = "1.3.0";

		public const string MODTOKEN = "KKING117_CONSUMEDBUFF_";

		private const string Section_Elixir = "Empty Bottle";

		private const string Section_Watch = "Delicate Watch (Broken)";

		private const string Section_VoidDio = "Pluripotent Larva (Consumed)";

		private const string Section_Dio = "Dios Best Friend (Consumed)";

		public static bool VoidDio_Enable = false;

		public static float VoidDio_BlockCooldown = 0.9f;

		public static float VoidDio_CollapseChance = 100f;

		public static float VoidDio_CollapseDamage = 4f;

		public static bool VoidDio_CollapseUseTotal = false;

		public static bool VoidDio_Corrupt = true;

		public static float VoidDio_Curse = 0.1f;

		public static bool Dio_Enable = false;

		public static float Dio_BlockChance = 15f;

		public static bool Elixir_Enable = false;

		public static float Elixir_Buff = 2.5f;

		public static float Elixir_Regen = 1f;

		public static bool Watch_Enable = false;

		public static bool Watch_Indicator = true;

		public static float Watch_Damage = 0.2f;

		public static int Watch_HitsToProc = 12;

		public static int Watch_ProcsToDouble = 12;

		public static float Watch_SlowBase = 1f;

		public static float Watch_SlowStack = 0.25f;

		private void Awake()
		{
			ReadConfig();
			if (Elixir_Enable)
			{
				EmptyBottle.Enable();
			}
			if (VoidDio_Enable)
			{
				PluripotentLarvaConsumed.Enable();
			}
			if (Watch_Enable)
			{
				DelicateWatchBroken.Enable();
			}
			if (Dio_Enable)
			{
				DiosBestFriendConsumed.Enable();
			}
			new ContentPacks().Initialize();
		}

		private void ReadConfig()
		{
			Elixir_Enable = ((BaseUnityPlugin)this).Config.Bind<bool>("Empty Bottle", "Enable Changes", false, "Allows this mod to make changes to the Empty Bottle item.").Value;
			Elixir_Buff = ((BaseUnityPlugin)this).Config.Bind<float>("Empty Bottle", "Regen Buff Duration", 2.5f, "Duration of the regen buff when the Power Elixir item is consumed.").Value;
			Elixir_Regen = ((BaseUnityPlugin)this).Config.Bind<float>("Empty Bottle", "Passive Regen", 1f, "passive regen per stack this item gives.").Value;
			Watch_Enable = ((BaseUnityPlugin)this).Config.Bind<bool>("Delicate Watch (Broken)", "Enable Changes", false, "Allows this mod to make changes to the Delicate Watch (Broken) item.").Value;
			Watch_Indicator = ((BaseUnityPlugin)this).Config.Bind<bool>("Delicate Watch (Broken)", "Buff Indicator", true, "Enables a buff to help track how many hits the item needs.").Value;
			Watch_HitsToProc = ((BaseUnityPlugin)this).Config.Bind<int>("Delicate Watch (Broken)", "Hit To Proc", 12, "On this number hit, proc its effect.").Value;
			Watch_ProcsToDouble = ((BaseUnityPlugin)this).Config.Bind<int>("Delicate Watch (Broken)", "Proc to Double Proc", 12, "On this number proc, double the proc effect. (1 or less disables this)").Value;
			Watch_Damage = ((BaseUnityPlugin)this).Config.Bind<float>("Delicate Watch (Broken)", "Damage On Proc", 0.2f, "Damage bonus on procs.").Value;
			Watch_SlowBase = ((BaseUnityPlugin)this).Config.Bind<float>("Delicate Watch (Broken)", "Base Slow On Proc", 1f, "Base duration of the slow effect that this applies on proc.").Value;
			Watch_SlowStack = ((BaseUnityPlugin)this).Config.Bind<float>("Delicate Watch (Broken)", "Stack Slow On Proc", 0.25f, "Stack duration of the slow effect.").Value;
			VoidDio_Enable = ((BaseUnityPlugin)this).Config.Bind<bool>("Pluripotent Larva (Consumed)", "Enable Changes", false, "Allows this mod to make changes to the Pluripotent Larva (Consumed) item.").Value;
			VoidDio_BlockCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Pluripotent Larva (Consumed)", "Block Cooldown", 0.9f, "How much to multiply the block cooldown per stack. (Higher than 1 disables this)").Value;
			VoidDio_CollapseChance = ((BaseUnityPlugin)this).Config.Bind<float>("Pluripotent Larva (Consumed)", "Collapse Chance", 10f, "The chance to apply Collapse per stack.").Value;
			VoidDio_CollapseDamage = ((BaseUnityPlugin)this).Config.Bind<float>("Pluripotent Larva (Consumed)", "Collapse Damage", 4f, "How much damage each Collapse stack does.").Value;
			VoidDio_CollapseUseTotal = ((BaseUnityPlugin)this).Config.Bind<bool>("Pluripotent Larva (Consumed)", "Collapse Total Damage", false, "Should the Collapse stack deal total damage instead of base damage?").Value;
			VoidDio_Corrupt = ((BaseUnityPlugin)this).Config.Bind<bool>("Pluripotent Larva (Consumed)", "Corrupted Life", true, "Automatically corrupt new items and be classed as void while carrying this item?").Value;
			VoidDio_Curse = ((BaseUnityPlugin)this).Config.Bind<float>("Pluripotent Larva (Consumed)", "Health Curse", 0.1f, "Health curse per stack.").Value;
			Dio_Enable = ((BaseUnityPlugin)this).Config.Bind<bool>("Dios Best Friend (Consumed)", "Enable", false, "Allows this mod to make changes to the Dios Best Friend (Consumed) item.").Value;
			Dio_BlockChance = ((BaseUnityPlugin)this).Config.Bind<float>("Dios Best Friend (Consumed)", "Block Chance", 15f, "The chance per stack to block damage.").Value;
		}
	}
}
namespace ConsumedBuff.Modules
{
	public static class Buffs
	{
		internal static List<BuffDef> buffDefs = new List<BuffDef>();

		internal static BuffDef AddNewBuff(string buffName, Sprite buffIcon, Color buffColor, bool canStack, bool isDebuff, bool isCooldown, bool ignoreNectar = false)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			BuffDef val = ScriptableObject.CreateInstance<BuffDef>();
			((Object)val).name = buffName;
			val.buffColor = buffColor;
			val.canStack = canStack;
			val.isDebuff = isDebuff;
			val.eliteDef = null;
			val.iconSprite = buffIcon;
			val.ignoreGrowthNectar = ignoreNectar;
			val.isCooldown = isCooldown;
			((Object)val).name = ((Object)val).name;
			buffDefs.Add(val);
			return val;
		}
	}
	internal class ContentPacks : IContentPackProvider
	{
		internal ContentPack contentPack = new ContentPack();

		public string identifier => "com.kking117.ConsumedBuff";

		public void Initialize()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			ContentManager.collectContentPackProviders += new CollectContentPackProvidersDelegate(ContentManager_collectContentPackProviders);
		}

		private void ContentManager_collectContentPackProviders(AddContentPackProviderDelegate addContentPackProvider)
		{
			addContentPackProvider.Invoke((IContentPackProvider)(object)this);
		}

		public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
		{
			contentPack.identifier = identifier;
			contentPack.buffDefs.Add(Buffs.buffDefs.ToArray());
			args.ReportProgress(1f);
			yield break;
		}

		public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args)
		{
			ContentPack.Copy(contentPack, args.output);
			args.ReportProgress(1f);
			yield break;
		}

		public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
		{
			args.ReportProgress(1f);
			yield break;
		}
	}
}
namespace ConsumedBuff.ItemChanges
{
	public class DelicateWatchBroken
	{
		private static bool canDouble = true;

		public static BuffDef TrackerBuff;

		public static BuffDef TrackerDoubleBuff;

		private static Color buffColor = new Color(0.678f, 0.611f, 0.411f, 1f);

		private static Color buff2Color = new Color(0.96f, 0.623f, 0.282f, 1f);

		public static void Enable()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			MainPlugin.Watch_HitsToProc = Math.Max(1, MainPlugin.Watch_HitsToProc);
			if (MainPlugin.Watch_ProcsToDouble < 2)
			{
				canDouble = false;
			}
			HealthComponent.TakeDamageProcess += new hook_TakeDamageProcess(OnTakeDamage);
			if (MainPlugin.Watch_Indicator)
			{
				CreateBuff();
			}
			UpdateText();
		}

		private static void CreateBuff()
		{
			//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_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			Sprite iconSprite = Addressables.LoadAssetAsync<BuffDef>((object)"RoR2/Base/LaserTurbine/bdLaserTurbineKillCharge.asset").WaitForCompletion().iconSprite;
			TrackerBuff = Buffs.AddNewBuff("BrokenWatchCounter", iconSprite, buffColor, canStack: true, isDebuff: false, isCooldown: true);
			if (canDouble)
			{
				TrackerDoubleBuff = Buffs.AddNewBuff("BrokenWatchDoubleCounter", iconSprite, buff2Color, canStack: true, isDebuff: false, isCooldown: true, ignoreNectar: true);
			}
		}

		private static string GetNthString(int number)
		{
			string result = "th";
			if (number < 0)
			{
				number *= -1;
			}
			int num = number % 100;
			if (num < 11 || num > 19)
			{
				number %= 10;
				switch (number)
				{
				case 1:
					result = "st";
					break;
				case 2:
					result = "nd";
					break;
				case 3:
					result = "rd";
					break;
				}
			}
			return result;
		}

		private static void UpdateText()
		{
			string text = string.Format("");
			string text2 = string.Format("");
			bool flag = false;
			text = $"Every {MainPlugin.Watch_HitsToProc}{GetNthString(MainPlugin.Watch_HitsToProc)} hit";
			text2 = $"Every <style=cIsDamage>{MainPlugin.Watch_HitsToProc}{GetNthString(MainPlugin.Watch_HitsToProc)} hit</style>";
			if (MainPlugin.Watch_Damage > 0f)
			{
				text += $" deals bonus damage";
				text2 += string.Format(" deals <style=cIsDamage>{0}%</style> <style=cStack>(+{0}% per stack)</style> extra damage", MainPlugin.Watch_Damage * 100f);
				flag = true;
			}
			if (MainPlugin.Watch_SlowBase > 0f || MainPlugin.Watch_SlowStack > 0f)
			{
				if (flag)
				{
					text += $" and";
					text2 += $" and";
				}
				text += $" slows";
				text2 += $" applies <style=cIsUtility>slow</style> for <style=cIsUtility>-60% movement speed</style> for <style=cIsUtility>{MainPlugin.Watch_SlowBase}s</style> <style=cStack>(+{MainPlugin.Watch_SlowStack}s per stack)</style>";
			}
			text += $".";
			text2 += $".";
			LanguageAPI.Add("ITEM_FRAGILEDAMAGEBONUSCONSUMED_PICKUP", text);
			LanguageAPI.Add("ITEM_FRAGILEDAMAGEBONUSCONSUMED_DESC", text2);
			LanguageAPI.Add("ITEM_FRAGILEDAMAGEBONUSCONSUMED_PICKUP", text, "en");
			LanguageAPI.Add("ITEM_FRAGILEDAMAGEBONUSCONSUMED_DESC", text2, "en");
		}

		private static void OnTakeDamage(orig_TakeDamageProcess orig, HealthComponent self, DamageInfo damageInfo)
		{
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Expected O, but got Unknown
			if (NetworkServer.active && self.alive && !self.godMode && !damageInfo.rejected && self.ospTimer <= 0f && Object.op_Implicit((Object)(object)self.body) && Object.op_Implicit((Object)(object)damageInfo.attacker))
			{
				CharacterBody component = damageInfo.attacker.GetComponent<CharacterBody>();
				if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.inventory))
				{
					int itemCount = component.inventory.GetItemCount(Items.FragileDamageBonusConsumed);
					if (itemCount > 0)
					{
						AddWatchCounter(component);
						int watchPowerMult = GetWatchPowerMult(component);
						if (watchPowerMult > 0)
						{
							damageInfo.damage *= 1f + (float)itemCount * MainPlugin.Watch_Damage * (float)watchPowerMult;
							EffectData val = new EffectData
							{
								origin = self.body.transform.position
							};
							val.SetNetworkedObjectReference(((Component)self.body).gameObject);
							EffectManager.SpawnEffect(AssetReferences.fragileDamageBonusBreakEffectPrefab, val, true);
							float num = MainPlugin.Watch_SlowBase + (float)Math.Max(0, itemCount - 1) * MainPlugin.Watch_SlowStack * (float)watchPowerMult;
							if (num > 0f)
							{
								self.body.AddTimedBuff(Buffs.Slow60, num);
							}
						}
					}
				}
			}
			orig.Invoke(self, damageInfo);
		}

		private static void AddWatchCounter(CharacterBody body)
		{
			BrokenWatchCounter brokenWatchCounter = ((Component)body).GetComponent<BrokenWatchCounter>();
			if (!Object.op_Implicit((Object)(object)brokenWatchCounter))
			{
				brokenWatchCounter = ((Component)body).gameObject.AddComponent<BrokenWatchCounter>();
			}
			brokenWatchCounter.hits++;
			if (brokenWatchCounter.hits >= MainPlugin.Watch_HitsToProc)
			{
				brokenWatchCounter.hits -= MainPlugin.Watch_HitsToProc;
				brokenWatchCounter.hitmult = 1;
				if (canDouble)
				{
					brokenWatchCounter.procs++;
					if (brokenWatchCounter.procs % MainPlugin.Watch_ProcsToDouble == 0)
					{
						brokenWatchCounter.procs -= MainPlugin.Watch_ProcsToDouble;
						brokenWatchCounter.hitmult = 2;
					}
				}
			}
			else
			{
				brokenWatchCounter.hitmult = 0;
			}
			UpdateTrackerBuff(body);
		}

		private static int PredictWatchBoostMult(CharacterBody body)
		{
			BrokenWatchCounter component = ((Component)body).GetComponent<BrokenWatchCounter>();
			if (Object.op_Implicit((Object)(object)component))
			{
				int num = component.hits + 1;
				if (num % MainPlugin.Watch_HitsToProc == 0)
				{
					if (canDouble)
					{
						int num2 = component.procs + 1;
						if (num2 % MainPlugin.Watch_ProcsToDouble == 0)
						{
							return 2;
						}
					}
					return 1;
				}
			}
			return 0;
		}

		private static int GetWatchPowerMult(CharacterBody body)
		{
			BrokenWatchCounter component = ((Component)body).GetComponent<BrokenWatchCounter>();
			if (Object.op_Implicit((Object)(object)component))
			{
				return component.hitmult;
			}
			return 0;
		}

		private static void UpdateTrackerBuff(CharacterBody body)
		{
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			if (!MainPlugin.Watch_Indicator)
			{
				return;
			}
			int num = 0;
			int num2 = 0;
			BrokenWatchCounter component = ((Component)body).GetComponent<BrokenWatchCounter>();
			if (Object.op_Implicit((Object)(object)component))
			{
				num = component.hits;
				num2 = component.procs;
			}
			if (canDouble)
			{
				while (body.GetBuffCount(TrackerDoubleBuff.buffIndex) > 0)
				{
					body.RemoveBuff(TrackerDoubleBuff.buffIndex);
				}
			}
			while (body.GetBuffCount(TrackerBuff.buffIndex) > 0)
			{
				body.RemoveBuff(TrackerBuff.buffIndex);
			}
			num2++;
			if (canDouble && num2 % MainPlugin.Watch_ProcsToDouble == 0)
			{
				while (body.GetBuffCount(TrackerDoubleBuff.buffIndex) < num)
				{
					body.AddBuff(TrackerDoubleBuff.buffIndex);
				}
			}
			else
			{
				while (body.GetBuffCount(TrackerBuff.buffIndex) < num)
				{
					body.AddBuff(TrackerBuff.buffIndex);
				}
			}
		}
	}
	public class DiosBestFriendConsumed
	{
		public static void Enable()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			if (MainPlugin.Dio_BlockChance > 0f)
			{
				UpdateText();
				HealthComponent.TakeDamageProcess += new hook_TakeDamageProcess(OnTakeDamage);
			}
		}

		private static void UpdateText()
		{
			string text = "";
			string text2 = "";
			text = $"Chance to block incoming damage.";
			text2 = string.Format("<style=cIsHealing>{0}%</style> <style=cStack>(+{0}% per stack)</style> chance to <style=cIsHealing>block</style> incoming damage. <style=cIsUtility>Unaffected by luck</style>.", MainPlugin.Dio_BlockChance);
			LanguageAPI.Add("ITEM_EXTRALIFECONSUMED_PICKUP", text);
			LanguageAPI.Add("ITEM_EXTRALIFECONSUMED_DESC", text2);
		}

		private static void OnTakeDamage(orig_TakeDamageProcess orig, HealthComponent self, DamageInfo damageInfo)
		{
			//IL_004b: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Invalid comparison between Unknown and I4
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: 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_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Expected O, but got Unknown
			if (NetworkServer.active && self.alive && !self.godMode && !damageInfo.rejected && self.ospTimer <= 0f && (int)DamageTypeCombo.op_Implicit(damageInfo.damageType & DamageTypeCombo.op_Implicit((DamageType)64)) <= 0 && Object.op_Implicit((Object)(object)self.body) && Object.op_Implicit((Object)(object)self.body.master))
			{
				Inventory inventory = self.body.inventory;
				if (Object.op_Implicit((Object)(object)inventory))
				{
					int itemCount = inventory.GetItemCount(Items.ExtraLifeConsumed);
					if (itemCount > 0 && Util.CheckRoll(Util.ConvertAmplificationPercentageIntoReductionPercentage(MainPlugin.Dio_BlockChance * (float)itemCount), 0f, (CharacterMaster)null))
					{
						EffectData val = new EffectData
						{
							origin = damageInfo.position,
							rotation = Util.QuaternionSafeLookRotation((damageInfo.force != Vector3.zero) ? damageInfo.force : Random.onUnitSphere)
						};
						EffectManager.SpawnEffect(AssetReferences.bearEffectPrefab, val, true);
						damageInfo.rejected = true;
					}
				}
			}
			orig.Invoke(self, damageInfo);
		}
	}
	public class EmptyBottle
	{
		public static void Enable()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			UpdateText();
			if (MainPlugin.Elixir_Regen != 0f)
			{
				RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(CalculateStatsHook);
			}
			if (MainPlugin.Elixir_Buff > 0f)
			{
				CharacterMasterNotificationQueue.PushItemTransformNotification += new hook_PushItemTransformNotification(OnItemAdded);
			}
			UpdateText();
		}

		private static void UpdateText()
		{
			string text = string.Format("");
			string text2 = string.Format("");
			if (MainPlugin.Elixir_Regen != 0f)
			{
				text = $"Increases health regeneration.";
				text2 = string.Format("Increases <style=cIsHealing>base health regeneration</style> by <style=cIsHealing>+{0} hp/s</style> <style=cStack>(+{0} per stack)</style>.", MainPlugin.Elixir_Regen);
			}
			else
			{
				text = $"An empty container from an Elixir you consumed. Does nothing.";
				text2 = $"A spent item with no remaining power.";
			}
			LanguageAPI.Add("ITEM_HEALINGPOTIONCONSUMED_PICKUP", text);
			LanguageAPI.Add("ITEM_HEALINGPOTIONCONSUMED_DESC", text2);
			LanguageAPI.Add("ITEM_HEALINGPOTIONCONSUMED_PICKUP", text, "en");
			LanguageAPI.Add("ITEM_HEALINGPOTIONCONSUMED_DESC", text2, "en");
		}

		private static void OnItemAdded(orig_PushItemTransformNotification orig, CharacterMaster self, ItemIndex oldItem, ItemIndex newItem, TransformationType transformationType)
		{
			//IL_0003: 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_0005: 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_001a: Invalid comparison between Unknown and I4
			//IL_0031: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, oldItem, newItem, transformationType);
			if (NetworkServer.active && (int)transformationType == 0 && Object.op_Implicit((Object)(object)self.GetBody()) && oldItem == Items.HealingPotion.itemIndex && newItem == Items.HealingPotionConsumed.itemIndex)
			{
				self.GetBody().AddTimedBuff(Buffs.CrocoRegen, MainPlugin.Elixir_Buff);
			}
		}

		private static void CalculateStatsHook(CharacterBody sender, StatHookEventArgs args)
		{
			if (Object.op_Implicit((Object)(object)sender) && Object.op_Implicit((Object)(object)sender.inventory))
			{
				float num = Math.Max(0f, sender.level - 1f);
				int itemCount = sender.inventory.GetItemCount(Items.HealingPotionConsumed);
				if (itemCount > 0)
				{
					num = MainPlugin.Elixir_Regen * 0.2f * num;
					args.baseRegenAdd += (float)itemCount * (MainPlugin.Elixir_Regen + num);
				}
			}
		}
	}
	public class PluripotentLarvaConsumed
	{
		private static float StackDamage;

		public static void Enable()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			UpdateText();
			RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(CalculateStatsHook);
			if (MainPlugin.VoidDio_Corrupt)
			{
				CharacterMaster.OnInventoryChanged += new hook_OnInventoryChanged(OnInventoryChanged);
			}
			if (MainPlugin.VoidDio_BlockCooldown <= 1f)
			{
				CharacterBody.AddTimedBuff_BuffDef_float += new hook_AddTimedBuff_BuffDef_float(AddTimedBuff);
			}
			if (MainPlugin.VoidDio_CollapseChance > 0f)
			{
				GlobalEventManager.onServerDamageDealt += OnTakeDamagePost;
			}
		}

		private static void UpdateText()
		{
			string text = "";
			string text2 = "";
			if (MainPlugin.VoidDio_CollapseChance > 0f)
			{
				text += $"Chance to collapse enemies on hit.";
				text2 += string.Format("<style=cIsDamage>{0}%</style> <style=cStack>(+{0}% per stack)</style> chance to <style=cIsDamage>collapse</style> an enemy for <style=cIsDamage>{1}%</style> ", MainPlugin.VoidDio_CollapseChance, MainPlugin.VoidDio_CollapseDamage * 100f);
				text2 = ((!MainPlugin.VoidDio_CollapseUseTotal) ? (text2 + "base damage.") : (text2 + "TOTAL damage."));
			}
			if (MainPlugin.VoidDio_BlockCooldown <= 1f)
			{
				if (text.Length > 0)
				{
					text += " ";
					text2 += " ";
				}
				text += $"Block the next source of damage.";
				text2 += "<style=cIsHealing>Blocks</style> incoming damage once, recharging after <style=cIsUtility>15 ";
				if (MainPlugin.VoidDio_BlockCooldown < 1f)
				{
					text2 += $"<style=cStack>(-{(1f - MainPlugin.VoidDio_BlockCooldown) * 100f}% per stack)</style> ";
				}
				text2 += "seconds</style>.";
			}
			if (MainPlugin.VoidDio_Curse > 0f)
			{
				if (text.Length > 0)
				{
					text += " ";
					text2 += " ";
				}
				text += $"Reduced maximum health.";
				text2 += string.Format("<style=cIsHealth>Reduces maximum health by {0}%</style> <style=cStack>(+{0}% per stack)</style>.", MainPlugin.VoidDio_Curse * 100f);
			}
			if (MainPlugin.VoidDio_Corrupt)
			{
				if (text.Length > 0)
				{
					text += " ";
					text2 += " ";
				}
				text += "<style=cIsVoid>Corrupts ALL items</style>.";
				text2 += "<style=cIsVoid>Corrupts ALL items</style>.";
			}
			LanguageAPI.Add("ITEM_EXTRALIFEVOIDCONSUMED_PICKUP", text);
			LanguageAPI.Add("ITEM_EXTRALIFEVOIDCONSUMED_DESC", text2);
		}

		private static void CalculateStatsHook(CharacterBody sender, StatHookEventArgs args)
		{
			if (!Object.op_Implicit((Object)(object)sender) || !Object.op_Implicit((Object)(object)sender.inventory))
			{
				return;
			}
			int itemCount = sender.inventory.GetItemCount(Items.ExtraLifeVoidConsumed);
			if (MainPlugin.VoidDio_Corrupt)
			{
				ManageCorruption(sender, itemCount);
			}
			if (itemCount > 0)
			{
				if (MainPlugin.VoidDio_Curse > 0f)
				{
					args.baseCurseAdd += MainPlugin.VoidDio_Curse * (float)itemCount;
				}
				if (MainPlugin.VoidDio_BlockCooldown <= 1f && !sender.HasBuff(Buffs.BearVoidCooldown) && !sender.HasBuff(Buffs.BearVoidReady))
				{
					sender.AddBuff(Buffs.BearVoidReady);
				}
			}
		}

		private static void ManageCorruption(CharacterBody self, int itemCount)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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)
			if (itemCount > 0)
			{
				if (!((Enum)self.bodyFlags).HasFlag((Enum)(object)(BodyFlags)1024))
				{
					self.bodyFlags = (BodyFlags)(self.bodyFlags | 0x400);
					ExtraLifeVoidEffect component = ((Component)self).GetComponent<ExtraLifeVoidEffect>();
					if (!Object.op_Implicit((Object)(object)component))
					{
						((Component)self).gameObject.AddComponent<ExtraLifeVoidEffect>();
					}
				}
			}
			else
			{
				ExtraLifeVoidEffect component2 = ((Component)self).GetComponent<ExtraLifeVoidEffect>();
				if (Object.op_Implicit((Object)(object)component2))
				{
					Object.DestroyImmediate((Object)(object)component2);
					self.bodyFlags = (BodyFlags)(self.bodyFlags & -1025);
				}
			}
		}

		private static void AddTimedBuff(orig_AddTimedBuff_BuffDef_float orig, CharacterBody self, BuffDef buffDef, float duration)
		{
			if (NetworkServer.active && Object.op_Implicit((Object)(object)self.inventory) && (Object)(object)buffDef == (Object)(object)Buffs.BearVoidCooldown)
			{
				int itemCount = self.inventory.GetItemCount(Items.ExtraLifeVoidConsumed);
				if (itemCount > 0)
				{
					duration *= Mathf.Pow(MainPlugin.VoidDio_BlockCooldown, (float)itemCount);
				}
			}
			orig.Invoke(self, buffDef, duration);
		}

		private static void OnTakeDamagePost(DamageReport dr)
		{
			if (!NetworkServer.active || dr.damageInfo.rejected || dr.damageInfo.procCoefficient <= 0f || !Object.op_Implicit((Object)(object)dr.attacker))
			{
				return;
			}
			uint? num = null;
			if (Object.op_Implicit((Object)(object)dr.damageInfo.inflictor))
			{
				ProjectileDamage component = dr.damageInfo.inflictor.GetComponent<ProjectileDamage>();
				if (Object.op_Implicit((Object)(object)component) && component.useDotMaxStacksFromAttacker)
				{
					num = component.dotMaxStacksFromAttacker;
				}
			}
			CharacterBody attackerBody = dr.attackerBody;
			CharacterBody victimBody = dr.victimBody;
			if (!Object.op_Implicit((Object)(object)attackerBody))
			{
				return;
			}
			CharacterMaster master = attackerBody.master;
			if (!Object.op_Implicit((Object)(object)master) || !Object.op_Implicit((Object)(object)master.inventory))
			{
				return;
			}
			Inventory inventory = master.inventory;
			int itemCount = inventory.GetItemCount(Items.ExtraLifeVoidConsumed);
			if (itemCount > 0 && Util.CheckRoll(dr.damageInfo.procCoefficient * (float)itemCount * MainPlugin.VoidDio_CollapseChance, master))
			{
				DotDef dotDef = DotController.GetDotDef((DotIndex)8);
				float num2 = 0f;
				num2 = ((!MainPlugin.VoidDio_CollapseUseTotal) ? (MainPlugin.VoidDio_CollapseDamage / dotDef.damageCoefficient) : (MainPlugin.VoidDio_CollapseDamage * dr.damageDealt / dotDef.damageCoefficient / attackerBody.damage));
				if (num2 > 0f)
				{
					DotController.InflictDot(((Component)victimBody).gameObject, ((Component)attackerBody).gameObject, (DotIndex)8, dotDef.interval, num2, num);
				}
			}
		}

		private static void OnInventoryChanged(orig_OnInventoryChanged orig, CharacterMaster self)
		{
			orig.Invoke(self);
			int itemCount = self.inventory.GetItemCount(Items.ExtraLifeVoidConsumed);
			if (itemCount > 0)
			{
				CorruptAllItems(self.inventory);
			}
		}

		private static void CorruptAllItems(Inventory inventory)
		{
			//IL_0007: 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_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_0019: 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)
			Enumerator<TransformationInfo> enumerator = ContagiousItemManager.transformationInfos.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					TransformationInfo current = enumerator.Current;
					ContagiousItemManager.TryForceReplacement(inventory, current.originalItem);
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
		}
	}
}
namespace ConsumedBuff.Components
{
	public class BrokenWatchCounter : MonoBehaviour
	{
		public int hits = 0;

		public int procs = 0;

		public int hitmult = 0;
	}
	public class ExtraLifeVoidEffect : MonoBehaviour
	{
	}
}