Decompiled source of EggsUtils v1.2.8

plugins/EggsUtils.dll

Decompiled 2 months ago
using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EggsUtils.Buffs;
using EggsUtils.Buffs.BuffComponents;
using EggsUtils.Helpers;
using EggsUtils.Properties;
using EntityStates;
using On.RoR2;
using R2API;
using RoR2;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("EggsUtils")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+8745066c43a58b66e9978faccc5c43604765d406")]
[assembly: AssemblyProduct("EggsUtils")]
[assembly: AssemblyTitle("EggsUtils")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace EggsUtils
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.Egg.EggsUtils", "EggsUtils", "1.2.8")]
	public class EggsUtils : BaseUnityPlugin
	{
		public const string COMPAT_NAME = "com.Egg.EggsUtils";

		public const string COMPAT_TITLE = "EggsUtils";

		public const string COMPAT_VERS = "1.2.8";

		public const string API_NAME = "com.bepis.r2api";

		private void Awake()
		{
			Log.Init(((BaseUnityPlugin)this).Logger);
			BuffsLoading.SetupBuffs();
			EggAssets.RegisterAssets();
			BuffHooks();
		}

		private void BuffHooks()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: 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
			CharacterBody.RecalculateStats += new hook_RecalculateStats(CharacterBody_RecalculateStats);
			HealthComponent.TakeDamage += new hook_TakeDamage(HealthComponent_TakeDamage);
		}

		private void CharacterBody_RecalculateStats(orig_RecalculateStats orig, CharacterBody self)
		{
			orig.Invoke(self);
			if (!Object.op_Implicit((Object)(object)self))
			{
				return;
			}
			if (self.HasBuff(BuffsLoading.buffDefTemporalChains))
			{
				TemporalChainHandler temporalChainHandler = default(TemporalChainHandler);
				if (!((Component)self).gameObject.TryGetComponent<TemporalChainHandler>(ref temporalChainHandler))
				{
					temporalChainHandler = ((Component)self).gameObject.AddComponent<TemporalChainHandler>();
				}
				float num = temporalChainHandler.GetSlowcount();
				self.moveSpeed -= self.moveSpeed / 2f * (num / 8f);
				self.attackSpeed -= self.attackSpeed / 3f * (num / 8f);
			}
			if (self.HasBuff(BuffsLoading.buffDefTracking))
			{
				self.moveSpeed /= 2f;
			}
			if (self.HasBuff(BuffsLoading.buffDefCunning))
			{
				self.moveSpeed *= 1.25f;
			}
		}

		private void HealthComponent_TakeDamage(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo)
		{
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Invalid comparison between Unknown and I4
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)self) && self.alive && Object.op_Implicit((Object)(object)self.body))
			{
				float num = 1f - self.body.armor / (100f + Mathf.Abs(self.body.armor));
				if (self.body.HasBuff(BuffsLoading.buffDefTracking))
				{
					DamageInfo obj = damageInfo;
					obj.damage *= 1.5f;
				}
				float num2 = damageInfo.damage * num;
				if (self.body.HasBuff(BuffsLoading.buffDefAdaptive))
				{
					float num3 = self.fullCombinedHealth / 5f;
					if (num2 > num3)
					{
						damageInfo.damage = num3 / num;
					}
					damageInfo.force = Vector3.zero;
				}
				if (self.body.HasBuff(BuffsLoading.buffDefUndying))
				{
					float health = self.health;
					if (damageInfo.damage >= health)
					{
						damageInfo.damage = (health - 1f) / num;
					}
				}
				if (Object.op_Implicit((Object)(object)damageInfo.attacker) && Object.op_Implicit((Object)(object)damageInfo.inflictor))
				{
					CharacterBody component = damageInfo.attacker.GetComponent<CharacterBody>();
					if (Object.op_Implicit((Object)(object)component) && component.HasBuff(BuffsLoading.buffDefCunning))
					{
						DamageInfo obj2 = damageInfo;
						obj2.damage *= 1.75f;
					}
					if (Object.op_Implicit((Object)(object)component) && component.HasBuff(BuffsLoading.buffDefStackingDamage))
					{
						float num4 = 1f + 0.1f * (float)component.GetBuffCount(BuffsLoading.buffDefStackingDamage);
						DamageInfo obj3 = damageInfo;
						obj3.damage *= num4;
					}
					float num5 = BuffsLoading.ProcToDamageTypeDecoder(damageInfo.procCoefficient);
					damageInfo.procCoefficient = BuffsLoading.ReturnProcToNormal(damageInfo.procCoefficient);
					int num6 = Convert.ToInt32(System.Math.Floor(num5 * 10000f));
					if ((damageInfo.damageType.damageType & 1) == 1)
					{
						foreach (BuffsLoading.CustomDamageType damageTypes in BuffsLoading.damageTypesList)
						{
							if (damageTypes.onHitIndex != num6)
							{
								continue;
							}
							if (Object.op_Implicit((Object)(object)damageTypes.buffDef))
							{
								if (damageTypes.buffDuration > 0f)
								{
									self.body.AddTimedBuff(damageTypes.buffDef, damageTypes.buffDuration);
								}
								else
								{
									self.body.AddBuff(damageTypes.buffDef);
								}
								DamageInfo obj4 = damageInfo;
								obj4.damageType ^= DamageTypeCombo.op_Implicit((DamageType)1);
							}
							if (damageTypes.callOnHit != null)
							{
								damageInfo = damageTypes.callOnHit(self, damageInfo);
								ref DamageType damageType = ref damageInfo.damageType.damageType;
								damageType = (DamageType)((uint)damageType ^ 1u);
							}
						}
					}
				}
			}
			orig.Invoke(self, damageInfo);
		}
	}
	internal static class Log
	{
		internal static ManualLogSource _logSource;

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

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

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

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

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

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

		internal static void LogWarning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
}
namespace EggsUtils.Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	internal class Resources
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static ResourceManager ResourceManager
		{
			get
			{
				if (resourceMan == null)
				{
					ResourceManager resourceManager = new ResourceManager("EggsUtils.Properties.Resources", typeof(Resources).Assembly);
					resourceMan = resourceManager;
				}
				return resourceMan;
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		internal static CultureInfo Culture
		{
			get
			{
				return resourceCulture;
			}
			set
			{
				resourceCulture = value;
			}
		}

		internal Resources()
		{
		}
	}
	public static class EggAssets
	{
		internal static string trackingDefPath = "RoR2/Base/CritOnUse/bdFullCrit.asset";

		internal static string armorDefPath = "RoR2/Base/Common/bdArmorBoost.asset";

		internal static Sprite doesNotExist;

		internal const string LangFolder = "egmods_languages";

		internal static string RootLangFolderPath => Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "egmods_languages");

		internal static void RegisterAssets()
		{
			if (Directory.Exists(RootLangFolderPath))
			{
				Language.collectLanguageRootFolders += RegisterTokensFolder;
			}
			else
			{
				Log.LogError("Could not find eggmods language folder");
			}
			Log.LogMessage("Tokens registered");
			RegisterSprites();
			Log.LogMessage("Buff Icons registered");
		}

		private static void RegisterSprites()
		{
			//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_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			BuffDef val = Addressables.LoadAssetAsync<BuffDef>((object)trackingDefPath).WaitForCompletion();
			BuffDef val2 = Addressables.LoadAssetAsync<BuffDef>((object)armorDefPath).WaitForCompletion();
			BuffsLoading.buffDefAdaptive.iconSprite = val2.iconSprite;
			BuffsLoading.buffDefCunning.iconSprite = val.iconSprite;
			BuffsLoading.buffDefTracking.iconSprite = val.iconSprite;
		}

		private static void RegisterTokensFolder(List<string> list)
		{
			list.Add(RootLangFolderPath);
		}

		public static Sprite TexToSprite(Texture2D tex)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			return Sprite.Create(tex, new Rect(0f, 0f, (float)((Texture)tex).width, (float)((Texture)tex).height), new Vector2(0.5f, 0.5f));
		}

		public static AssetBundle LoadAssetBundle(byte[] resourceBytes)
		{
			if (resourceBytes == null)
			{
				throw new ArgumentNullException("Resource");
			}
			return AssetBundle.LoadFromMemory(resourceBytes);
		}
	}
}
namespace EggsUtils.Helpers
{
	public class Conversions
	{
		public const string CHARS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

		public static string ToBase62(int num)
		{
			string text = string.Empty;
			int num2 = num;
			while (num2 > 0)
			{
				int index = num2 % 62;
				num2 /= 62;
				text = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"[index] + text;
			}
			while (text.Length < 2)
			{
				text = "0" + text;
			}
			return text;
		}

		public static int FromBase62(string str)
		{
			int num = 0;
			for (int i = 0; i < str.Length; i++)
			{
				char value = str[i];
				int num3;
				if (str.Contains(value))
				{
					int num2 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".IndexOf(value);
					num3 = Convert.ToInt32((double)num2 * System.Math.Pow(62.0, str.Length - 1 - i));
				}
				else
				{
					num3 = 0;
				}
				num += num3;
			}
			return num;
		}
	}
	public class Math
	{
		public static float ConvertToRange(float oldMin, float oldMax, float newMin, float newMax, float valueToConvert)
		{
			float num = oldMax - oldMin;
			float num2 = newMax - newMin;
			return (valueToConvert - oldMin) * num2 / num + newMin;
		}

		public static Vector3 GetDirection(Vector3 startPos, Vector3 endPos)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = endPos - startPos;
			return ((Vector3)(ref val)).normalized;
		}
	}
}
namespace EggsUtils.Config
{
	public static class Config
	{
		public static string PrepareConfigCode(ConfigFile file)
		{
			string text = string.Empty;
			int num = 0;
			foreach (KeyValuePair<ConfigDefinition, ConfigEntryBase> item in file)
			{
				ConfigEntryBase value = item.Value;
				string text2 = string.Empty;
				string text3;
				if (value.BoxedValue.Equals(value.DefaultValue))
				{
					num++;
					text3 = ((!((IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)file).Last().Equals(item)) ? string.Empty : num.ToString());
				}
				else
				{
					if (num > 0)
					{
						text += num;
						num = 0;
					}
					text3 = value.BoxedValue.GetType().Name[0].ToString().ToLower();
					switch (text3)
					{
					case "b":
						text2 = (((bool)value.BoxedValue) ? "1" : "0");
						break;
					case "s":
					{
						float num4 = (float)value.BoxedValue;
						if (num4 > 3843f)
						{
							Log.LogWarning("Value of config field : " + value.Definition.Key + " too high, resetting to default)");
							value.BoxedValue = value.DefaultValue;
							num++;
							text3 = ((!((IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)file).Last().Equals(item)) ? string.Empty : num.ToString());
						}
						else if (num4 < 0f)
						{
							Log.LogWarning("Value of config field : " + value.Definition.Key + " below zero, resetting to default)");
							value.BoxedValue = value.DefaultValue;
							num++;
							text3 = ((!((IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)file).Last().Equals(item)) ? string.Empty : num.ToString());
						}
						else
						{
							int num5 = Convert.ToInt32(System.Math.Floor(num4));
							text2 = Conversions.ToBase62(num5);
							int num6 = Convert.ToInt32((num4 - (float)num5) * 100f);
							value.BoxedValue = (float)num5 + Convert.ToSingle(System.Math.Round((float)num6 / 100f, 2));
							text2 += Conversions.ToBase62(num6);
						}
						break;
					}
					case "i":
					{
						int num3 = (int)value.BoxedValue;
						if (num3 > 3843)
						{
							Log.LogWarning("Value of config field : " + value.Definition.Key + " too high, resetting to default)");
							value.BoxedValue = value.DefaultValue;
							num++;
							text3 = ((!((IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)file).Last().Equals(item)) ? string.Empty : num.ToString());
						}
						else if (num3 < 0)
						{
							Log.LogWarning("Value of config field : " + value.Definition.Key + " below zero, resetting to default)");
							value.BoxedValue = value.DefaultValue;
							num++;
							text3 = ((!((IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)file).Last().Equals(item)) ? string.Empty : num.ToString());
						}
						else
						{
							text2 = Conversions.ToBase62(num3);
						}
						break;
					}
					case "u":
					{
						uint num2 = (uint)value.BoxedValue;
						if (num2 > 3843)
						{
							Log.LogWarning("Value of config field : " + value.Definition.Key + " too high, resetting to default)");
							value.BoxedValue = value.DefaultValue;
							num++;
							text3 = ((!((IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)file).Last().Equals(item)) ? string.Empty : num.ToString());
						}
						else if (num2 < 0)
						{
							Log.LogWarning("Value of config field : " + value.Definition.Key + " below zero, resetting to default)");
							value.BoxedValue = value.DefaultValue;
							num++;
							text3 = ((!((IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)file).Last().Equals(item)) ? string.Empty : num.ToString());
						}
						else
						{
							text2 = Conversions.ToBase62(Convert.ToInt32(num2));
						}
						break;
					}
					}
				}
				text = text + text3 + text2;
			}
			file.Reload();
			return text;
		}

		public static void LoadConfigCode(string code, ref ConfigFile file)
		{
			int length = code.Length;
			int num = 0;
			int num2 = 0;
			int num3 = 0;
			foreach (KeyValuePair<ConfigDefinition, ConfigEntryBase> item in file)
			{
				ConfigEntryBase value = item.Value;
				char c = code[num];
				bool flag = false;
				if (num3 == 0)
				{
					int result;
					while (int.TryParse(code.Substring(num, num2 + 1), out result))
					{
						num2++;
						num3 = result;
						if (num + num2 >= code.Length)
						{
							flag = true;
							break;
						}
					}
					if (num2 > 0)
					{
						num += num2 - (flag ? 1 : 0);
						num2 = 0;
					}
				}
				if (num3 > 0)
				{
					num3--;
					value.BoxedValue = value.DefaultValue;
					continue;
				}
				num++;
				if (c == Convert.ToChar("b"))
				{
					num2 = 1;
					value.BoxedValue = code.Substring(num, num2) == "1";
				}
				else if (c == Convert.ToChar("s"))
				{
					num2 = 2;
					int num4 = Conversions.FromBase62(code.Substring(num, num2));
					int num5 = Conversions.FromBase62(code.Substring(num + num2, num2));
					float num6 = (float)num4 + (float)num5 / 100f;
					value.BoxedValue = num6;
					num2 += 2;
				}
				else if (c == Convert.ToChar("i"))
				{
					num2 = 2;
					value.BoxedValue = Conversions.FromBase62(code.Substring(num, num2));
				}
				else
				{
					if (c != Convert.ToChar("u"))
					{
						Log.LogError("Invalid code section, process aborted");
						return;
					}
					num2 = 2;
					uint num7 = (uint)Conversions.FromBase62(code.Substring(num, num2));
					value.BoxedValue = num7;
				}
				num += num2;
				num2 = 0;
			}
			Log.LogMessage("Config code loaded, restart game for it to take effect");
			file.Save();
			file.Reload();
		}
	}
}
namespace EggsUtils.Buffs
{
	public class BuffsLoading
	{
		public struct CustomDamageType
		{
			public BuffDef buffDef { get; private set; }

			public float buffDuration { get; private set; }

			public float procIndex { get; private set; }

			public int onHitIndex { get; private set; }

			public Func<HealthComponent, DamageInfo, DamageInfo> callOnHit { get; private set; }

			internal CustomDamageType(BuffDef buff, float duration, int index)
			{
				buffDef = buff;
				onHitIndex = index;
				procIndex = Convert.ToSingle(System.Math.Round((float)index / 10000f, 4));
				callOnHit = null;
				buffDuration = duration;
			}

			internal CustomDamageType(Func<HealthComponent, DamageInfo, DamageInfo> call, int index)
			{
				buffDef = null;
				onHitIndex = index;
				procIndex = Convert.ToSingle(System.Math.Round((float)index / 10000f, 4));
				callOnHit = call;
				buffDuration = 0f;
			}

			internal CustomDamageType(BuffDef buff, float duration, Func<HealthComponent, DamageInfo, DamageInfo> call, int index)
			{
				buffDef = buff;
				onHitIndex = index;
				procIndex = Convert.ToSingle(System.Math.Round((float)index / 10000f, 4));
				callOnHit = call;
				buffDuration = duration;
			}
		}

		public static BuffDef buffDefTemporalChains;

		public static BuffDef buffDefTracking;

		public static BuffDef buffDefAdaptive;

		public static BuffDef buffDefUndying;

		public static BuffDef buffDefCunning;

		public static BuffDef buffDefStackingDamage;

		public static CustomDamageType temporalChainsOnHit;

		public static CustomDamageType trackingOnHit;

		private static List<BuffDef> defList = new List<BuffDef>();

		public static List<CustomDamageType> damageTypesList = new List<CustomDamageType>();

		internal static void SetupBuffs()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			buffDefTemporalChains = BuffBuilder(Color.blue, canStack: true, EggAssets.doesNotExist, isDebuff: true, "Temporal Chains");
			temporalChainsOnHit = AssignNewDamageType(buffDefTemporalChains, 0f, TemporalChainHandler);
			defList.Add(buffDefTemporalChains);
			buffDefTracking = BuffBuilder(Color.magenta, canStack: false, EggAssets.doesNotExist, isDebuff: true, "Tracked");
			trackingOnHit = AssignNewDamageType(buffDefTracking, 5f);
			defList.Add(buffDefTracking);
			buffDefAdaptive = BuffBuilder(Color.blue, canStack: false, EggAssets.doesNotExist, isDebuff: false, "Adaptive Armor");
			defList.Add(buffDefAdaptive);
			buffDefUndying = BuffBuilder(Color.red, canStack: false, EggAssets.doesNotExist, isDebuff: false, "Undying");
			defList.Add(buffDefUndying);
			buffDefCunning = BuffBuilder(Color.blue, canStack: false, EggAssets.doesNotExist, isDebuff: false, "Cunning");
			defList.Add(buffDefCunning);
			buffDefStackingDamage = BuffBuilder(Color.red, canStack: false, EggAssets.doesNotExist, isDebuff: false, "StackingDamage");
			defList.Add(buffDefStackingDamage);
			foreach (BuffDef def in defList)
			{
				ContentAddition.AddBuffDef(def);
			}
		}

		internal static CustomDamageType AssignNewDamageType(BuffDef buffToApply, float duration)
		{
			int index = damageTypesList.Count + 1;
			CustomDamageType customDamageType = new CustomDamageType(buffToApply, duration, index);
			damageTypesList.Add(customDamageType);
			return customDamageType;
		}

		private static CustomDamageType AssignNewDamageType(Func<HealthComponent, DamageInfo, DamageInfo> method)
		{
			int index = damageTypesList.Count + 1;
			CustomDamageType customDamageType = new CustomDamageType(method, index);
			damageTypesList.Add(customDamageType);
			return customDamageType;
		}

		private static CustomDamageType AssignNewDamageType(BuffDef buffToApply, float duration, Func<HealthComponent, DamageInfo, DamageInfo> method)
		{
			int index = damageTypesList.Count + 1;
			CustomDamageType customDamageType = new CustomDamageType(buffToApply, duration, method, index);
			damageTypesList.Add(customDamageType);
			return customDamageType;
		}

		private static BuffDef BuffBuilder(Color color, bool canStack, Sprite icon, bool isDebuff, string buffName)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			BuffDef val = ScriptableObject.CreateInstance<BuffDef>();
			((Object)val).name = buffName;
			val.buffColor = color;
			val.canStack = canStack;
			val.eliteDef = null;
			val.iconSprite = icon;
			val.isDebuff = isDebuff;
			return val;
		}

		private static DamageInfo TemporalChainHandler(HealthComponent component, DamageInfo info)
		{
			TemporalChainHandler temporalChainHandler = default(TemporalChainHandler);
			if (!((Component)component.body).gameObject.TryGetComponent<TemporalChainHandler>(ref temporalChainHandler))
			{
				temporalChainHandler = ((Component)component.body).gameObject.AddComponent<TemporalChainHandler>();
			}
			component.body.AddBuff(buffDefTemporalChains);
			temporalChainHandler.inflictor = info.attacker;
			temporalChainHandler.ResetTimer();
			return info;
		}

		internal static float ReturnProcToNormal(float procCoeff)
		{
			float num = procCoeff * 10f;
			double value = System.Math.Floor(num) / 10.0;
			return Convert.ToSingle(value);
		}

		internal static float ProcToDamageTypeDecoder(float procCoeff)
		{
			float num = procCoeff * 10f;
			double num2 = System.Math.Floor(num);
			double value = (double)num - num2;
			return Convert.ToSingle(value);
		}

		public static float ProcToDamageTypeEncoder(float damageIndex, float procCoeffToEncode)
		{
			float num = procCoeffToEncode * 10f;
			double num2 = System.Math.Floor(num);
			double value = (num2 + (double)damageIndex) / 10.0;
			return Convert.ToSingle(value);
		}
	}
}
namespace EggsUtils.Buffs.BuffStates
{
	internal class StasisState : BaseState
	{
	}
}
namespace EggsUtils.Buffs.BuffComponents
{
	[RequireComponent(typeof(CharacterBody))]
	internal class TemporalChainHandler : MonoBehaviour
	{
		private CharacterBody characterBody;

		private float coolDownTimer;

		private float removeStacksTimer;

		public GameObject inflictor;

		private int slowCount;

		private SetStateOnHurt targetStateOnHurt;

		private void Awake()
		{
			removeStacksTimer = 8f;
			coolDownTimer = 0f;
			characterBody = ((Component)this).GetComponent<CharacterBody>();
		}

		private void FixedUpdate()
		{
			if (characterBody.GetBuffCount(BuffsLoading.buffDefTemporalChains) > 8)
			{
				for (int i = 0; i < characterBody.GetBuffCount(BuffsLoading.buffDefTemporalChains) - 8; i++)
				{
					characterBody.RemoveBuff(BuffsLoading.buffDefTemporalChains);
				}
			}
			slowCount = characterBody.GetBuffCount(BuffsLoading.buffDefTemporalChains);
			if (slowCount == 8 && CanStun())
			{
				Detonate();
				for (int j = 0; j < slowCount; j++)
				{
					characterBody.RemoveBuff(BuffsLoading.buffDefTemporalChains);
				}
				SetCooldown(3f);
			}
			if (removeStacksTimer > 0f)
			{
				removeStacksTimer -= Time.fixedDeltaTime;
			}
			else
			{
				characterBody.RemoveBuff(BuffsLoading.buffDefTemporalChains);
				removeStacksTimer = 1f;
			}
			if (coolDownTimer > 0f)
			{
				coolDownTimer -= Time.fixedDeltaTime;
			}
		}

		public void ResetTimer()
		{
			removeStacksTimer = 8f;
		}

		public bool CanStun()
		{
			return coolDownTimer == 0f;
		}

		public void SetCooldown(float cooldownLength)
		{
			coolDownTimer = cooldownLength;
		}

		public int GetSlowcount()
		{
			return slowCount;
		}

		public GameObject GetInflictor()
		{
			if (Object.op_Implicit((Object)(object)inflictor))
			{
				return inflictor;
			}
			return null;
		}

		public void Detonate()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: 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)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			DamageInfo val = new DamageInfo
			{
				attacker = GetInflictor(),
				damage = 0.1f * characterBody.healthComponent.fullCombinedHealth,
				damageType = DamageTypeCombo.op_Implicit((DamageType)0),
				damageColorIndex = (DamageColorIndex)0,
				position = characterBody.corePosition,
				crit = false,
				procCoefficient = 0f,
				procChainMask = default(ProcChainMask),
				force = Vector3.zero,
				inflictor = GetInflictor()
			};
			characterBody.healthComponent.TakeDamage(val);
			targetStateOnHurt = ((Component)characterBody).gameObject.GetComponent<SetStateOnHurt>();
			if (Object.op_Implicit((Object)(object)targetStateOnHurt))
			{
				targetStateOnHurt.SetStun(2f);
			}
		}
	}
}