Decompiled source of BetterHexes v1.1.2

BetterHexes.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BetterHexes.Changes;
using BetterHexes.Modules;
using EntityStates;
using EntityStates.Mimic.Devour;
using HG;
using HarmonyLib;
using IL.RoR2;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using On.RoR2;
using On.RoR2.Skills;
using R2API;
using RoR2;
using RoR2.ContentManagement;
using RoR2.Items;
using RoR2.Skills;
using RoR2BepInExPack.GameAssetPathsBetter;
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 = ".NET Standard 2.1")]
[assembly: AssemblyCompany("BetterHexes")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BetterHexes")]
[assembly: AssemblyTitle("BetterHexes")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 BetterHexes
{
	[BepInPlugin("com.Bloonjitsu7.BetterHexes", "BetterHexes", "1.1.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class MainPlugin : BaseUnityPlugin
	{
		public void Awake()
		{
			Log.Init(((BaseUnityPlugin)this).Logger);
			new ContentPacks().Initialize();
			Main main = new Main();
			Configs.SetupConfig(((BaseUnityPlugin)this).Config);
			main.Initialize();
		}
	}
	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);
		}
	}
}
namespace BetterHexes.Modules
{
	public static class DamageTypes
	{
	}
	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 isHidden)
		{
			//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.isCooldown = isCooldown;
			val.isHidden = isHidden;
			buffDefs.Add(val);
			return val;
		}
	}
	public static class Effects
	{
		private static GameObject finder = Addressables.LoadAssetAsync<GameObject>((object)RoR2_Base_DeathProjectile.DeathProjectileTickEffect_prefab).WaitForCompletion();

		public static List<EffectDef> effectDefs = new List<EffectDef>();

		internal static void RegisterEffects()
		{
			Main.hauntEffect = CreateHauntEffect();
		}

		private static GameObject CreateHauntEffect()
		{
			//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)
			return CloneObject(RoR2_Base_DeathProjectile.DeathProjectileTickEffect_prefab, "BloonHauntEffect", Color.green, Color.green, 4.5f);
		}

		private static GameObject CreateTracer()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CloneTracer("RoR2/Base/Huntress/TracerHuntressSnipe.prefab", "TracerStormboundAurelioniteLaser", Color.red, new Color(1f, 0.04f, 0.04f, 1f), 2f);
			Object.Destroy((Object)(object)((Component)val.transform.Find("TracerHead")).gameObject);
			return val;
		}

		private static GameObject CloneObject(string originalObjectName, string newObjectName, Color color1, Color color2, float scaleMult = 1f, float colorTemp = 0f, bool colorMesh = true, string soundName = "", bool parentToTransform = false, bool recolor = true)
		{
			//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)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Addressables.LoadAssetAsync<GameObject>((object)originalObjectName).WaitForCompletion();
			if ((Object)(object)val == (Object)null)
			{
				Log.Warning(originalObjectName + " is null!");
				return null;
			}
			Component[] componentsInChildren = val.GetComponentsInChildren(typeof(Component));
			foreach (Component data in componentsInChildren)
			{
				Log.Message(data);
			}
			GameObject val2 = PrefabAPI.InstantiateClone(val, newObjectName, false);
			if ((Object)(object)val2.GetComponent<EffectComponent>() == (Object)null)
			{
				val2.AddComponent<EffectComponent>();
			}
			if ((Object)(object)val2.GetComponent<VFXAttributes>() == (Object)null)
			{
				val2.AddComponent<VFXAttributes>();
			}
			val2.GetComponent<VFXAttributes>().vfxPriority = (VFXPriority)2;
			val2.GetComponent<VFXAttributes>().DoNotPool = true;
			if (recolor)
			{
				val2.Recolor(color1, color2, scaleMult, colorTemp, colorMesh);
			}
			CreateEffectFromObject(val2, soundName, parentToTransform);
			return val2;
		}

		private static GameObject CloneTracer(string originalTracerName, string newTracerName, Color color1, Color color2, float widthMult = 1f, float? speed = null, float? length = null)
		{
			//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)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Addressables.LoadAssetAsync<GameObject>((object)originalTracerName).WaitForCompletion();
			if ((Object)(object)val == (Object)null)
			{
				Log.Warning(originalTracerName + " is null!");
				return null;
			}
			GameObject val2 = PrefabAPI.InstantiateClone(val, newTracerName, false);
			if (!Object.op_Implicit((Object)(object)val2.GetComponent<EffectComponent>()))
			{
				val2.AddComponent<EffectComponent>();
			}
			if (!Object.op_Implicit((Object)(object)val2.GetComponent<VFXAttributes>()))
			{
				val2.AddComponent<VFXAttributes>();
			}
			val2.GetComponent<VFXAttributes>().vfxPriority = (VFXPriority)2;
			val2.GetComponent<VFXAttributes>().DoNotPool = true;
			if (!Object.op_Implicit((Object)(object)val2.GetComponent<NetworkIdentity>()))
			{
				val2.AddComponent<NetworkIdentity>();
			}
			val2.GetComponent<Tracer>().speed = (speed.HasValue ? speed.Value : val2.GetComponent<Tracer>().speed);
			val2.GetComponent<Tracer>().length = (length.HasValue ? length.Value : val2.GetComponent<Tracer>().length);
			val2.Recolor(color1, color2, widthMult);
			CreateAndAddEffectDef(val2);
			return val2;
		}

		private static void Recolor(this GameObject thingToColor, Color color1, Color color2, float widthMult = 1f, float colorTemp = 0f, bool colorMesh = true)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Expected O, but got Unknown
			//IL_00d7: 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_00f7: 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_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: 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_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			bool flag = true;
			LineRenderer[] componentsInChildren = thingToColor.GetComponentsInChildren<LineRenderer>();
			foreach (LineRenderer val in componentsInChildren)
			{
				bool flag2 = true;
				val.startColor = color1;
				val.endColor = color2;
				if (widthMult != 1f)
				{
					val.widthMultiplier *= widthMult;
				}
			}
			ParticleSystem[] componentsInChildren2 = thingToColor.GetComponentsInChildren<ParticleSystem>();
			foreach (ParticleSystem val2 in componentsInChildren2)
			{
				MainModule main = val2.main;
				MinMaxCurve startSize = ((MainModule)(ref main)).startSize;
				((MainModule)(ref main)).startSize = new MinMaxCurve(((MinMaxCurve)(ref startSize)).constant * widthMult);
				((MainModule)(ref main)).startColor = new MinMaxGradient(color1);
				TrailModule trails = val2.trails;
				if (((TrailModule)(ref trails)).enabled)
				{
					Gradient val3 = new Gradient();
					GradientColorKey[] array = (GradientColorKey[])(object)new GradientColorKey[2];
					array[0].color = color1;
					array[0].time = 0f;
					array[1].color = color2;
					array[1].time = 1f;
					GradientAlphaKey[] array2 = (GradientAlphaKey[])(object)new GradientAlphaKey[2];
					array2[0].alpha = color1.a;
					array2[0].time = 0f;
					array2[1].alpha = color2.a;
					array2[1].time = 1f;
					val3.SetKeys(array, array2);
					((TrailModule)(ref trails)).colorOverLifetime = new MinMaxGradient(val3);
				}
			}
			Light[] componentsInChildren3 = thingToColor.GetComponentsInChildren<Light>();
			foreach (Light val4 in componentsInChildren3)
			{
				if (colorTemp > 0f)
				{
					val4.colorTemperature = colorTemp;
					val4.useColorTemperature = true;
				}
				else
				{
					val4.useColorTemperature = false;
				}
				val4.color = color1;
				Transform transform = ((Component)val4).transform;
				transform.localScale *= widthMult;
			}
			ParticleSystemRenderer[] componentsInChildren4 = thingToColor.GetComponentsInChildren<ParticleSystemRenderer>();
			foreach (ParticleSystemRenderer val5 in componentsInChildren4)
			{
				((Renderer)val5).material.SetColor("_MainColor", color1);
				((Renderer)val5).material.SetColor("_Color", color1);
				((Renderer)val5).material.SetColor("_TintColor", color2);
			}
			if (colorMesh)
			{
				MeshRenderer[] componentsInChildren5 = thingToColor.GetComponentsInChildren<MeshRenderer>();
				foreach (MeshRenderer val6 in componentsInChildren5)
				{
					((Renderer)val6).material.SetColor("_MainColor", color1);
					((Renderer)val6).material.SetColor("_Color", color1);
					((Renderer)val6).material.SetColor("_TintColor", color2);
				}
			}
		}

		internal static void AddEffectDef(EffectDef effectDef)
		{
			effectDefs.Add(effectDef);
		}

		internal static EffectDef CreateAndAddEffectDef(GameObject effectPrefab, bool donotPool = false)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			if (donotPool)
			{
				VFXAttributes val = effectPrefab.GetComponent<VFXAttributes>();
				if ((Object)(object)val == (Object)null)
				{
					val = effectPrefab.AddComponent<VFXAttributes>();
				}
				val.DoNotPool = true;
			}
			EffectDef val2 = new EffectDef(effectPrefab);
			AddEffectDef(val2);
			return val2;
		}

		internal static void CreateEffectFromObject(GameObject newEffect, string soundName, bool parentToTransform)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			newEffect.AddComponent<DestroyOnTimer>().duration = 6f;
			newEffect.AddComponent<NetworkIdentity>();
			if (!Object.op_Implicit((Object)(object)newEffect.GetComponent<VFXAttributes>()))
			{
				newEffect.AddComponent<VFXAttributes>().vfxPriority = (VFXPriority)2;
			}
			EffectComponent component = newEffect.GetComponent<EffectComponent>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				component = newEffect.AddComponent<EffectComponent>();
				component.applyScale = true;
				component.effectIndex = (EffectIndex)(-1);
				component.parentToReferencedTransform = parentToTransform;
				component.positionAtReferencedTransform = true;
				component.soundName = soundName;
			}
			CreateAndAddEffectDef(newEffect);
		}
	}
	internal class ContentPacks : IContentPackProvider
	{
		internal ContentPack contentPack = new ContentPack();

		public string identifier => "com.Bloonjitsu7.BetterHexes";

		public void Initialize()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			Effects.RegisterEffects();
			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.effectDefs.Add(Effects.effectDefs.ToArray());
			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 BetterHexes.Changes
{
	public class BuffDefs
	{
		public static BuffDef PatienceCurse;

		public static BuffDef MimicHealthBuff;

		private static Sprite patienceIcon = Addressables.LoadAssetAsync<Sprite>((object)RoR2_Base_Common.texBuffCrippleIcon_tif).WaitForCompletion();

		public static void CreateBuffs()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			PatienceCurse = Buffs.AddNewBuff("BloonPatienceCurse", patienceIcon, Color.red, canStack: true, isDebuff: true, isCooldown: false, isHidden: false);
			MimicHealthBuff = Buffs.AddNewBuff("BloonMimicHealthBuff", patienceIcon, Color.red, canStack: false, isDebuff: false, isCooldown: false, isHidden: true);
		}
	}
	public class Configs
	{
		public static ConfigEntry<bool> painEnable { get; set; }

		public static ConfigEntry<bool> blindEnable { get; set; }

		public static ConfigEntry<bool> rainEnable { get; set; }

		public static ConfigEntry<bool> famineEnable { get; set; }

		public static ConfigEntry<bool> misfortuneEnable { get; set; }

		public static ConfigEntry<bool> patienceEnable { get; set; }

		public static ConfigEntry<bool> lossEnable { get; set; }

		public static ConfigEntry<bool> mimicryEnable { get; set; }

		public static ConfigEntry<bool> hauntingEnable { get; set; }

		public static ConfigEntry<bool> ossificationEnable { get; set; }

		public static void SetupConfig(ConfigFile cfg)
		{
			blindEnable = cfg.Bind<bool>("Hex of Blindness", "Enable Changes", true, "Enables the changes to this Hex.");
			painEnable = cfg.Bind<bool>("Hex of Pain", "Enable Changes", true, "Enables the changes to this Hex.");
			famineEnable = cfg.Bind<bool>("Hex of Famine", "Enable Changes", true, "Enables the changes to this Hex.");
			rainEnable = cfg.Bind<bool>("Hex of Rain", "Enable Changes", true, "Enables the changes to this Hex.");
			misfortuneEnable = cfg.Bind<bool>("Hex of Misfortune", "Enable Changes", true, "Enables the changes to this Hex.");
			patienceEnable = cfg.Bind<bool>("Hex of Patience", "Enable Changes", true, "Enables the changes to this Hex.");
			lossEnable = cfg.Bind<bool>("Hex of Loss", "Enable Changes", true, "Enables the changes to this Hex.");
			mimicryEnable = cfg.Bind<bool>("Hex of Mimicry", "Enable Changes", true, "Enables the changes to this Hex.");
			hauntingEnable = cfg.Bind<bool>("Hex of Haunting", "Enable Changes", true, "Enables the changes to this Hex.");
			ossificationEnable = cfg.Bind<bool>("Hex of Ossification", "Enable Changes", true, "Enables the changes to this Hex.");
		}
	}
	public class Main
	{
		private struct FogBuffControllerInstance
		{
			public FogBuffController fogBuffControllerInstance;
		}

		public class BlindnessHexBehaviour : ItemBehavior
		{
			public static float stopwatch;

			public float timer;

			public float blindnessRange = float.PositiveInfinity;

			public bool blindStopped;

			private void OnEnable()
			{
				if (Configs.blindEnable.Value)
				{
					Stage.onStageStartGlobal += OnBlindStart;
					TeleporterInteraction.onTeleporterBeginChargingGlobal += OnBlindClear;
				}
			}

			private void OnDisable()
			{
				if (Configs.blindEnable.Value)
				{
					Stage.onStageStartGlobal -= OnBlindStart;
					TeleporterInteraction.onTeleporterBeginChargingGlobal -= OnBlindClear;
				}
			}

			private void Start()
			{
				UpdateTimer();
			}

			private void UpdateTimer()
			{
				timer = 300f / ConvertReductionIntoStackingDivision(0.3f, base.stack);
			}

			public void FixedUpdate()
			{
				//IL_0066: Unknown result type (might be due to invalid IL or missing references)
				//IL_006c: Invalid comparison between Unknown and I4
				//IL_006f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0075: Invalid comparison between Unknown and I4
				if ((Object)(object)base.body == (Object)null || base.stack <= 0 || !Configs.blindEnable.Value || !Object.op_Implicit((Object)(object)Stage.instance) || !Object.op_Implicit((Object)(object)Stage.instance.sceneDef))
				{
					return;
				}
				SceneDef sceneDef = Stage.instance.sceneDef;
				if (!sceneDef.preventStageAdvanceCounter && (int)sceneDef.sceneType != 5 && (int)sceneDef.sceneType != 2 && !blindStopped)
				{
					if (blindnessRange > 150f)
					{
						UpdateTimer();
						stopwatch += Time.fixedDeltaTime;
						if (stopwatch >= timer)
						{
							Util.PlaySound("Play_Hex_Rain", ((Component)RoR2Application.instance).gameObject);
							blindnessRange = 150f;
						}
					}
					else
					{
						blindnessRange -= Time.fixedDeltaTime * GetStackedStats(0.5f, 0.15f, base.stack);
						blindnessRange = Mathf.Max(25f, blindnessRange);
					}
				}
				else
				{
					blindnessRange = float.PositiveInfinity;
				}
				base.body.visionDistance = blindnessRange;
			}

			private void OnBlindStart(Stage stage)
			{
				blindnessRange = float.PositiveInfinity;
				stopwatch = 0f;
				UpdateTimer();
				blindStopped = false;
			}

			private void OnBlindClear(TeleporterInteraction interaction)
			{
				blindStopped = true;
				stopwatch = 0f;
				if ((Object)(object)base.body != (Object)null)
				{
					base.body.visionDistance = float.PositiveInfinity;
				}
			}
		}

		public class LightningHexBehaviour : ItemBehavior
		{
			public static GameObject lightningPrefab = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)RoR2_DLC2_meridian_DisableSkillsLightning.LightningStrikeInstance_prefab).WaitForCompletion(), "BloonLightningHexPrefab");

			public float stopwatch;

			public float interval;

			private void Start()
			{
				stopwatch = 0f;
				UpdateInterval();
			}

			private void UpdateInterval()
			{
				interval = 6f / ConvertReductionIntoStackingDivision(0.25f, base.stack);
			}

			public void FixedUpdate()
			{
				if (!((Object)(object)base.body == (Object)null) && base.body.isPlayerControlled && base.stack > 0 && Configs.rainEnable.Value)
				{
					stopwatch += Time.fixedDeltaTime;
					if ((Object)(object)base.body != (Object)null && stopwatch >= interval)
					{
						stopwatch = 0f;
						UpdateInterval();
						FireLightning();
					}
				}
			}

			public void FireLightning()
			{
				//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_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_0051: Unknown result type (might be due to invalid IL or missing references)
				//IL_0057: Unknown result type (might be due to invalid IL or missing references)
				//IL_0063: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				//IL_006d: Unknown result type (might be due to invalid IL or missing references)
				//IL_006f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0074: 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_007d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0083: Expected O, but got Unknown
				//IL_0089: Unknown result type (might be due to invalid IL or missing references)
				//IL_0097: Unknown result type (might be due to invalid IL or missing references)
				//IL_009c: Unknown result type (might be due to invalid IL or missing references)
				//IL_009d: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d2: 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_0102: Unknown result type (might be due to invalid IL or missing references)
				//IL_0111: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
				BlastAttack val = new BlastAttack
				{
					attacker = lightningPrefab,
					baseDamage = 3f * base.body.damage,
					damageColorIndex = (DamageColorIndex)16,
					baseForce = 0f,
					procCoefficient = 0f,
					radius = 7f,
					damageType = new DamageTypeCombo(DamageTypeCombo.op_Implicit((DamageType)131072), (DamageTypeExtended)8192, (DamageSource)16),
					falloffModel = (FalloffModel)0,
					attackerFiltering = (AttackerFiltering)1,
					teamIndex = (TeamIndex)0
				};
				_ = base.body.footPosition;
				Vector3 val2 = base.body.footPosition;
				RaycastHit val3 = default(RaycastHit);
				if (Physics.Raycast(new Ray(val2 + Vector3.up * 2f, Vector3.down), ref val3, 200f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask) | LayerMask.op_Implicit(CommonMasks.characterBodiesOrDefault), (QueryTriggerInteraction)1))
				{
					val2 = ((RaycastHit)(ref val3)).point;
				}
				Object.Instantiate<GameObject>(lightningPrefab, val2, base.body.transform.rotation).GetComponent<LightningStrikeInstance>().Initialize(val2, val, 1.5f, true);
			}
		}

		public static List<Hook> hooks = new List<Hook>();

		public static List<ILHook> ILhooks = new List<ILHook>();

		public static GameObject hauntPrefab = Addressables.LoadAssetAsync<GameObject>((object)RoR2_DLC4_HexHaunting.PoltergeistBody_prefab).WaitForCompletion();

		public static GameObject hauntEffect;

		private static Dictionary<TeamIndex, FogBuffControllerInstance> _teamIndextoFogBuffController = new Dictionary<TeamIndex, FogBuffControllerInstance>();

		public void Initialize()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Expected O, but got Unknown
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Expected O, but got Unknown
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Expected O, but got Unknown
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Expected O, but got Unknown
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Expected O, but got Unknown
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Expected O, but got Unknown
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Expected O, but got Unknown
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Expected O, but got Unknown
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Expected O, but got Unknown
			//IL_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_033e: Expected O, but got Unknown
			//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ae: Expected O, but got Unknown
			//IL_0429: Unknown result type (might be due to invalid IL or missing references)
			//IL_0433: Expected O, but got Unknown
			//IL_045f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0469: Expected O, but got Unknown
			//IL_0490: Unknown result type (might be due to invalid IL or missing references)
			//IL_049a: Expected O, but got Unknown
			//IL_0495: Unknown result type (might be due to invalid IL or missing references)
			//IL_049f: Expected O, but got Unknown
			//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b1: Expected O, but got Unknown
			//IL_0627: Unknown result type (might be due to invalid IL or missing references)
			//IL_0631: Expected O, but got Unknown
			//IL_062c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0636: Expected O, but got Unknown
			//IL_0552: Unknown result type (might be due to invalid IL or missing references)
			//IL_055c: Expected O, but got Unknown
			//IL_0583: Unknown result type (might be due to invalid IL or missing references)
			//IL_058d: Expected O, but got Unknown
			//IL_0588: Unknown result type (might be due to invalid IL or missing references)
			//IL_0592: Expected O, but got Unknown
			//IL_05be: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c8: Expected O, but got Unknown
			//IL_05d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05da: Expected O, but got Unknown
			BuffDefs.CreateBuffs();
			CharacterBody.OnInventoryChanged += new hook_OnInventoryChanged(AddNewHexBehaviour);
			RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(OnRecalcStats);
			HealthComponent.TakeDamage += new hook_TakeDamage(OnTakeDamage);
			if (Configs.blindEnable.Value)
			{
				CharacterBody.RecalculateStats += new Manipulator(IL_RecalcStatsBlind);
				string text = "Spending too long in a stage causes your vision to <style=cDeath>rapidly decrease</style>.";
				LanguageAPI.Add("ITEM_BLINDNESS_PICKUP", text);
				string text2 = "After holding this item for <style=cIsUtility>5 minutes</style> <style=cStack>(-30% per stack)</style> in a single stage, your sight range is limited to <style=cDeath>150m</style>. This range is reduced by <style=cDeath>0.5m</style> <style=cStack>(+30% per stack)</style> every second, down to a minimum of <style=cDeath>25m</style>. Starting the teleporter event <style=cIsHealing>clears this effect for the rest of the stage</style>.";
				LanguageAPI.Add("ITEM_BLINDNESS_DESC", text2);
			}
			if (Configs.painEnable.Value)
			{
				CharacterBody.RecalculateStats += new Manipulator(IL_RecalcStatsPain);
				string text3 = "10% chance for incoming damage to <style=cDeath>bleed you</style> based on the amount of damage dealt.";
				LanguageAPI.Add("ITEM_HEXCURSE_PICKUP", text3);
				string text4 = "Any damage you take from foes has a <style=cIsDamage>10% chance</style> to <style=cDeath>bleed you</style>, dealing an additional <style=cIsDamage>120%</style> <style=cStack>(+60% per stack)</style> TOTAL damage over the course of <style=cIsUtility>3s</style>.";
				LanguageAPI.Add("ITEM_HEXCURSE_DESC", text4);
			}
			if (Configs.famineEnable.Value)
			{
				MethodInfo methodInfo = AccessTools.Method(typeof(LowerHealingUtils), "GetLowerHealingCoefficient", (Type[])null, (Type[])null);
				hooks.Add(new Hook((MethodBase)methodInfo, (Delegate)new Func<Func<int, float>, int, float>(RemoveOldFamineBehaviour)));
				string text5 = "For a brief time after taking damage, you <style=cDeath>cannot heal</style>.";
				LanguageAPI.Add("ITEM_LOWERHEALING_PICKUP", text5);
				string text6 = "Your <style=cIsHealing>healing</style> is <style=cDeath>disabled for 2.5s</style> <style=cStack>(+0.5s per stack)</style> after taking damage.";
				LanguageAPI.Add("ITEM_LOWERHEALING_DESC", text6);
			}
			if (Configs.rainEnable.Value)
			{
				Run.RecalculateDifficultyCoefficentInternal += new Manipulator(IL_RecalcDifficulty);
				CharacterBody.Start += new hook_Start(CheckRainElite);
				string text7 = "Elite monsters are <style=cDeath>more common</style> and <style=cDeath>more powerful</style>.";
				LanguageAPI.Add("ITEM_INCREASEDDIFFICULTY_PICKUP", text7);
				string text8 = "Enemies have an additional <style=cIsDamage>5% chance</style> to become elite, with a small chance to gain a <style=cDeath>powerful elite status</style> (scaling over time). All elites have an additional <style=cDeath>25% <style=cStack>(+25% per stack)</style> health and damage</style>.";
				LanguageAPI.Add("ITEM_INCREASEDDIFFICULTY_DESC", text8);
			}
			if (Configs.misfortuneEnable.Value)
			{
				MethodInfo methodInfo2 = AccessTools.Method(typeof(RandomDebuffOnInteractBehaviour), "GetItemDef", (Type[])null, (Type[])null);
				hooks.Add(new Hook((MethodBase)methodInfo2, (Delegate)new Func<Func<ItemDef>, ItemDef>(RemoveItemBehaviour)));
				SkillDef.OnExecute += new hook_OnExecute(OnSkillExecute);
				string text9 = "Your skills have a small chance to <style=cDeath>fail when used</style>.";
				LanguageAPI.Add("ITEM_RANDOMDEBUFFONSUCCESSFULROLL_PICKUP", text9);
				string text10 = "<style=cIsDamage>5%</style> <style=cStack>(+5% per stack)</style> chance for your skills to <style=cDeath>fail</style> when activated, using up <style=cIsDamage>half of the skill's cooldown</style> in the process. <style=cIsUtility>Does not trigger on skills without cooldowns</style>.";
				LanguageAPI.Add("ITEM_RANDOMDEBUFFONSUCCESSFULROLL_DESC", text10);
			}
			if (Configs.patienceEnable.Value)
			{
				MethodInfo methodInfo3 = AccessTools.Method(typeof(OutOfTPRadiusManager), "InstantiateDamagerForTeam", (Type[])null, (Type[])null);
				hooks.Add(new Hook((MethodBase)methodInfo3, (Delegate)new Action<Action<IZone, TeamIndex, int>, IZone, TeamIndex, int>(OnPatienceInstantiate)));
				MethodInfo methodInfo4 = AccessTools.Method(typeof(OutOfTPRadiusManager), "UpdateOrInstantiateFogDamager", (Type[])null, (Type[])null);
				hooks.Add(new Hook((MethodBase)methodInfo4, (Delegate)new Action<Action<Inventory>, Inventory>(OnPatienceIndecisive)));
				MethodInfo methodInfo5 = AccessTools.Method(typeof(OutOfTPRadiusManager), "DestroyFogDamagerForTeam", (Type[])null, (Type[])null);
				hooks.Add(new Hook((MethodBase)methodInfo5, (Delegate)new Action<Action<TeamIndex>, TeamIndex>(OnPatienceDestroy)));
				MethodInfo methodInfo6 = AccessTools.Method(typeof(OutOfTPRadiusManager), "DestroyFogDamagersForTeams", (Type[])null, (Type[])null);
				hooks.Add(new Hook((MethodBase)methodInfo6, (Delegate)new Action<Action>(OnPatienceDestroyAll)));
				MethodInfo methodInfo7 = AccessTools.Method(typeof(CharacterBody), "AddTimedBuffInternal", (Type[])null, (Type[])null);
				hooks.Add(new Hook((MethodBase)methodInfo7, (Delegate)new Action<Action<CharacterBody, BuffDef, float, float>, CharacterBody, BuffDef, float, float>(OnPatienceCurseDecay)));
				string text11 = "Standing outside of the Teleporter's radius <style=cDeath>reduces your maximum health</style>. <style=cHumanObjective>This effect applies to allies as well</style>.";
				LanguageAPI.Add("ITEM_OUTOFTPRADIUS_PICKUP", text11);
				string text12 = "Standing outside of the Teleporter's radius <style=cDeath>reduces your maximum health</style> by <style=cDeath>4%</style> <style=cStack>(+1% per stack)</style> every second. You regain <style=cIsHealing>1% of the lost health</style> every second while inside the Teleporter's radius. <style=cHumanObjective>This effect applies to your allies as well</style>.";
				LanguageAPI.Add("ITEM_OUTOFTPRADIUS_DESC", text12);
			}
			if (Configs.lossEnable.Value)
			{
				MethodInfo methodInfo8 = AccessTools.Method(typeof(RoamingItemDisableBehavior), "GetItemDef", (Type[])null, (Type[])null);
				hooks.Add(new Hook((MethodBase)methodInfo8, (Delegate)new Func<Func<ItemDef>, ItemDef>(RemoveItemBehaviour)));
				TeleporterInteraction.onTeleporterBeginChargingGlobal += OnLossCharge;
				string text13 = "Upon starting the teleporter event, a random item in your inventory is <style=cDeath>transformed into scrap</style>.";
				LanguageAPI.Add("ITEM_ROAMINGITEMDISABLE_PICKUP", text13);
				string text14 = "Upon starting the teleporter event, <style=cIsUtility>1 <style=cStack>(+1 per stack)</style> random items(s)</style> in your inventory are <style=cDeath>transformed into scrap</style>. Can only target <style=cSub>Common</style>, <style=cIsHealing>Uncommon</style>, and <style=cIsHealth>Legendary</style> items, with a higher chance to target <style=cIsUtility>lower rarity items</style>.";
				LanguageAPI.Add("ITEM_ROAMINGITEMDISABLE_DESC", text14);
			}
			if (Configs.mimicryEnable.Value)
			{
				MethodInfo methodInfo9 = AccessTools.Method(typeof(MimicryBehaviour), "GetCooldownValue", (Type[])null, (Type[])null);
				hooks.Add(new Hook((MethodBase)methodInfo9, (Delegate)new Func<Func<MimicryBehaviour, float>, MimicryBehaviour, float>(OnGetMimicCooldown)));
				MethodInfo methodInfo10 = AccessTools.Method(typeof(DevouredBody), "OnEnter", (Type[])null, (Type[])null);
				hooks.Add(new Hook((MethodBase)methodInfo10, (Delegate)new Action<Action<DevouredBody>, DevouredBody>(OnMimicDevourEnter)));
				MethodInfo methodInfo11 = AccessTools.Method(typeof(MimicryBehaviour), "TrySpawnMimic", (Type[])null, (Type[])null);
				ILhooks.Add(new ILHook((MethodBase)methodInfo11, new Manipulator(IL_MimicSpawn)));
				CharacterMaster.GetDeployableSameSlotLimit += new hook_GetDeployableSameSlotLimit(OnGetMimicCount);
				string text15 = "Summons a <style=cDeath>Mimic</style> every <style=cIsUtility>30s</style> with the ability to <style=cDeath>temporarily steal</style> up to <style=cIsUtility>2 <style=cStack>(+1 per stack)</style> items</style> from the user <style=cIsUtility>every second</style> while trapping them. The Mimic gains an additional <style=cIsHealth>20% health</style> for each item it has stolen. Up to <style=cDeath>1 <style=cStack>(+1 per stack)</style> Mimic</style> can be active at a time.";
				LanguageAPI.Add("ITEM_MIMICRY_DESC", text15);
			}
			if (Configs.hauntingEnable.Value)
			{
				CharacterBody component = hauntPrefab.GetComponent<CharacterBody>();
				if ((Object)(object)component != (Object)null)
				{
					component.baseMaxHealth = 100f;
					component.levelMaxHealth = 30f;
					component.baseDamage = 12.5f;
					component.levelDamage = 2.5f;
				}
				MethodInfo methodInfo12 = AccessTools.Method(typeof(HexHauntingBehaviour), "GetCooldownValue", (Type[])null, (Type[])null);
				hooks.Add(new Hook((MethodBase)methodInfo12, (Delegate)new Func<Func<HexHauntingBehaviour, float>, HexHauntingBehaviour, float>(OnGetHauntCooldown)));
				MethodInfo methodInfo13 = AccessTools.Method(typeof(HexHauntingBehaviour), "TryHauntNearbyInteractable", (Type[])null, (Type[])null);
				ILhooks.Add(new ILHook((MethodBase)methodInfo13, new Manipulator(IL_HauntInteractable)));
				MethodInfo methodInfo14 = AccessTools.Method(typeof(HexHauntingBehaviour), "ScheduleNextClearHauntMemory", (Type[])null, (Type[])null);
				hooks.Add(new Hook((MethodBase)methodInfo14, (Delegate)new Action<Action<HexHauntingBehaviour>, HexHauntingBehaviour>(OnHauntClear)));
				CharacterMaster.GetDeployableSameSlotLimit += new hook_GetDeployableSameSlotLimit(OnGetHauntCount);
				string text16 = "Summons a <style=cDeath>Poltergeist</style> every <style=cIsUtility>45s</style> <style=cStack>(-25% per stack)</style> that haunts an <style=cIsUtility>interactable</style> and makes all nearby enemies <style=cIsUtility>invisible</style>. Haunted interactables get thrown towards you, dealing damage.";
				LanguageAPI.Add("ITEM_HEXHAUNTING_DESC", text16);
			}
			if (Configs.ossificationEnable.Value)
			{
				MethodInfo methodInfo15 = AccessTools.Method(typeof(GlobalEventManager), "ProcBarrierEnemiesOnKill", (Type[])null, (Type[])null);
				ILhooks.Add(new ILHook((MethodBase)methodInfo15, new Manipulator(IL_ProcBarrier)));
				string text17 = "Killing an enemy grants <style=cIsHealing>100% <style=cStack>(+50% per stack)</style></style> of their maximum health as <style=cIsHealing>temporary barrier</style> to <style=cDeath>all enemies</style> within <style=cIsDamage>30m</style> <style=cStack>(+15m per stack)</style>.";
				LanguageAPI.Add("ITEM_BARRIERENEMIES_DESC", text17);
			}
		}

		private void OnRecalcStats(CharacterBody sender, StatHookEventArgs args)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Invalid comparison between Unknown and I4
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			GetTotalItemCountFromTeamArgs val = default(GetTotalItemCountFromTeamArgs);
			if (sender.isElite && Object.op_Implicit((Object)(object)sender.teamComponent) && (int)sender.teamComponent.teamIndex == 2 && Configs.rainEnable.Value)
			{
				((GetTotalItemCountFromTeamArgs)(ref val))..ctor(Items.IncreasedDifficulty.itemIndex);
				val.requiresAlive = false;
				val.requiredTeam = (TeamIndex)1;
				val.requiresConnected = true;
				val.onlyPlayerControlledCharacters = true;
				val.queryCountRegardlessOfInventoryOrItemDisabled = true;
				int totalItemCountFromTeam = Util.GetTotalItemCountFromTeam(val);
				if (totalItemCountFromTeam > 0)
				{
					args.healthTotalMult *= 1f + GetStackedStats(0.25f, 0.25f, totalItemCountFromTeam);
					args.damageTotalMult *= 1f + GetStackedStats(0.25f, 0.25f, totalItemCountFromTeam);
				}
			}
			if (sender.HasBuff(BuffDefs.PatienceCurse))
			{
				if (Object.op_Implicit((Object)(object)sender.teamComponent) && (int)sender.teamComponent.teamIndex == 1)
				{
					int buffCount = sender.GetBuffCount(BuffDefs.PatienceCurse);
					((GetTotalItemCountFromTeamArgs)(ref val))..ctor(Items.OutOfTPRadius.itemIndex);
					val.requiresAlive = false;
					val.requiredTeam = (TeamIndex)1;
					val.requiresConnected = true;
					val.onlyPlayerControlledCharacters = true;
					val.queryCountRegardlessOfInventoryOrItemDisabled = true;
					int totalItemCountFromTeam2 = Util.GetTotalItemCountFromTeam(val);
					float num = 0.01f;
					args.baseCurseAdd += (float)buffCount * num;
				}
				else
				{
					sender.RemoveBuff(BuffDefs.PatienceCurse);
				}
			}
			if (sender.HasBuff(BuffDefs.MimicHealthBuff))
			{
				ItemStealController component = ((Component)sender).GetComponent<ItemStealController>();
				if ((Object)(object)component != (Object)null)
				{
					float num2 = 0.2f * (float)component.totalStolenItems;
					Log.Message(num2);
					args.healthTotalMult *= 1f + num2;
				}
				else
				{
					sender.RemoveBuff(BuffDefs.MimicHealthBuff);
				}
			}
		}

		public void IL_ProcBarrier(ILContext il)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			MoveType val2 = (MoveType)2;
			int loc1 = -1;
			if (val.TryGotoNext(val2, new Func<Instruction, bool>[4]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 1),
				(Instruction x) => ILPatternMatchingExt.MatchConvR4(x),
				(Instruction x) => ILPatternMatchingExt.MatchMul(x),
				(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref loc1)
			}))
			{
				val.Emit(OpCodes.Ldarg_1);
				val.Emit(OpCodes.Ldarg_2);
				val.EmitDelegate<Func<int, CharacterBody, float>>((Func<int, CharacterBody, float>)((int itemStacks, CharacterBody victimBody) => victimBody.healthComponent.fullHealth * GetStackedStats(1f, 0.5f, itemStacks)));
				val.Emit(OpCodes.Stloc, loc1);
			}
			else
			{
				Log.Error(((MemberReference)il.Method).Name + " Hook 1 failed!");
			}
		}

		public void IL_HauntInteractable(ILContext il)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			MoveType val2 = (MoveType)2;
			int loc1 = -1;
			int num = default(int);
			EffectData val3 = default(EffectData);
			if (val.TryGotoNext(val2, new Func<Instruction, bool>[6]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num),
				(Instruction x) => ILPatternMatchingExt.MatchCall(x, ref val3),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld(x, typeof(Run), "spawnRng"),
				(Instruction x) => ILPatternMatchingExt.MatchCallvirt(x, ref val3),
				(Instruction x) => ILPatternMatchingExt.MatchCallvirt(x, ref val3),
				(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref loc1)
			}))
			{
				val.Emit(OpCodes.Ldarg_0);
				val.Emit(OpCodes.Ldloc, loc1);
				val.EmitDelegate<Action<HexHauntingBehaviour, HauntCandidate>>((Action<HexHauntingBehaviour, HauntCandidate>)delegate(HexHauntingBehaviour self, HauntCandidate candidate)
				{
					//IL_0001: 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_0012: Unknown result type (might be due to invalid IL or missing references)
					//IL_0017: Unknown result type (might be due to invalid IL or missing references)
					//IL_0018: 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_0020: Unknown result type (might be due to invalid IL or missing references)
					//IL_0025: Unknown result type (might be due to invalid IL or missing references)
					//IL_002b: Expected O, but got Unknown
					//IL_0038: Unknown result type (might be due to invalid IL or missing references)
					//IL_003e: Expected O, but got Unknown
					//IL_0055: 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_0061: Unknown result type (might be due to invalid IL or missing references)
					//IL_006f: Unknown result type (might be due to invalid IL or missing references)
					//IL_008d: Unknown result type (might be due to invalid IL or missing references)
					Vector3 position = candidate.gameObject.transform.position;
					val3 = new EffectData
					{
						origin = position,
						rotation = Quaternion.identity
					};
					EffectManager.SpawnEffect(hauntEffect, val3, true);
					SphereSearch val4 = new SphereSearch();
					List<HurtBox> list = CollectionPool<HurtBox, List<HurtBox>>.RentCollection();
					val4.radius = 30f;
					val4.mask = ((LayerIndex)(ref LayerIndex.entityPrecise)).mask;
					val4.origin = position;
					val4.RefreshCandidates();
					TeamMask val5 = default(TeamMask);
					((TeamMask)(ref val5)).AddTeam((TeamIndex)2);
					val4.FilterCandidatesByDistinctHurtBoxEntities();
					val4.OrderCandidatesByDistance();
					val4.FilterCandidatesByHurtBoxTeam(val5);
					val4.GetHurtBoxes(list);
					val4.ClearCandidates();
					foreach (HurtBox item in list)
					{
						if (Object.op_Implicit((Object)(object)item.healthComponent))
						{
							CharacterBody body = item.healthComponent.body;
							if ((Object)(object)body != (Object)null)
							{
								body.AddTimedBuff(Buffs.Cloak, 7.5f);
							}
						}
					}
					CollectionPool<HurtBox, List<HurtBox>>.ReturnCollection(list);
				});
			}
			else
			{
				Log.Error(((MemberReference)il.Method).Name + " Hook 1 failed!");
			}
		}

		private int OnGetHauntCount(orig_GetDeployableSameSlotLimit orig, CharacterMaster self, DeployableSlot slot)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Invalid comparison between Unknown and I4
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if ((int)slot == 38 && Object.op_Implicit((Object)(object)self.inventory))
			{
				return 10;
			}
			return orig.Invoke(self, slot);
		}

		private float OnGetHauntCooldown(Func<HexHauntingBehaviour, float> orig, HexHauntingBehaviour self)
		{
			if (((BaseItemBodyBehavior)self).stack > 0)
			{
				return 45f / ConvertReductionIntoStackingDivision(0.25f, ((BaseItemBodyBehavior)self).stack);
			}
			return 45f;
		}

		private void OnHauntClear(Action<HexHauntingBehaviour> orig, HexHauntingBehaviour self)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			self.hauntMemoryClearTimeStamp = FixedTimeStamp.now + 20f;
		}

		private void OnMimicDevourEnter(Action<DevouredBody> orig, DevouredBody self)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			ItemStealController component = ((EntityState)self).GetComponent<ItemStealController>();
			if ((Object)(object)component != (Object)null)
			{
				Log.Message("Steal Success!");
				GetTotalItemCountFromTeamArgs val = default(GetTotalItemCountFromTeamArgs);
				((GetTotalItemCountFromTeamArgs)(ref val))..ctor(Items.Mimicry.itemIndex);
				val.requiresAlive = false;
				val.requiredTeam = (TeamIndex)1;
				val.requiresConnected = true;
				val.onlyPlayerControlledCharacters = true;
				val.queryCountRegardlessOfInventoryOrItemDisabled = true;
				int totalItemCountFromTeam = Util.GetTotalItemCountFromTeam(val);
				component.amountToSteal = GetStackedStatsInt(2, 1, totalItemCountFromTeam);
				component.maxAmountToSteal = GetStackedStatsInt(6, 3, totalItemCountFromTeam);
			}
			orig(self);
		}

		private float OnGetMimicCooldown(Func<MimicryBehaviour, float> orig, MimicryBehaviour self)
		{
			return 30f;
		}

		private int OnGetMimicCount(orig_GetDeployableSameSlotLimit orig, CharacterMaster self, DeployableSlot slot)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Invalid comparison between Unknown and I4
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			if ((int)slot == 37 && Object.op_Implicit((Object)(object)self.inventory))
			{
				return self.inventory.GetItemCountEffective(Items.Mimicry);
			}
			return orig.Invoke(self, slot);
		}

		public void IL_MimicSpawn(ILContext il)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: 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_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			MoveType val2 = (MoveType)2;
			int loc1 = -1;
			if (val.TryGotoNext(val2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallvirt(x, typeof(Inventory), "GiveItemPermanent")
			}))
			{
				Instruction next = val.Next;
				if (val.TryGotoPrev(val2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref loc1)
				}))
				{
					val.Index -= 1;
					val.MoveAfterLabels();
					val.Emit(OpCodes.Ldarg_0);
					val.Emit(OpCodes.Ldloc, loc1);
					val.EmitDelegate<Action<MimicryBehaviour, CharacterMaster>>((Action<MimicryBehaviour, CharacterMaster>)delegate(MimicryBehaviour self, CharacterMaster master)
					{
						CharacterBody body = master.GetBody();
						if ((Object)(object)body != (Object)null)
						{
							Log.Message("Success!");
							body.AddBuff(BuffDefs.MimicHealthBuff);
						}
					});
					val.Emit(OpCodes.Br, next);
				}
				else
				{
					Log.Error(((MemberReference)il.Method).Name + " Hook 1.2 failed!");
				}
			}
			else
			{
				Log.Error(((MemberReference)il.Method).Name + " Hook 1.1 failed!");
			}
		}

		private void OnLossCharge(TeleporterInteraction interaction)
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Invalid comparison between Unknown and I4
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Expected I4, but got Unknown
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Invalid comparison between Unknown and I4
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Invalid comparison between Unknown and I4
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			TryTransformResult val6 = default(TryTransformResult);
			foreach (CharacterBody instances in CharacterBody.instancesList)
			{
				if (!Object.op_Implicit((Object)(object)instances.inventory))
				{
					continue;
				}
				int itemCountEffective = instances.inventory.GetItemCountEffective(Items.RoamingItemDisable);
				if (itemCountEffective <= 0)
				{
					continue;
				}
				for (int i = 0; i < itemCountEffective; i++)
				{
					List<ItemIndex> list = new List<ItemIndex>();
					List<ItemIndex> list2 = new List<ItemIndex>();
					((ItemCollection)(ref instances.inventory.permanentItemStacks)).GetNonZeroIndices(list2);
					foreach (ItemIndex item in list2)
					{
						ItemDef itemDef = ItemCatalog.GetItemDef(item);
						if (!Object.op_Implicit((Object)(object)itemDef) || ((int)itemDef.tier != 0 && (int)itemDef.tier != 1 && (int)itemDef.tier != 2) || itemDef.ContainsTag((ItemTag)10) || itemDef.ContainsTag((ItemTag)25) || list.Contains(item))
						{
							continue;
						}
						int num = 1;
						ItemTier tier = itemDef.tier;
						ItemTier val = tier;
						if ((int)val != 0)
						{
							if ((int)val == 1)
							{
								num = 3;
							}
						}
						else
						{
							num = 6;
						}
						for (int j = 0; j < num; j++)
						{
							list.Add(item);
						}
					}
					if (list.Count > 0)
					{
						int index = Random.Range(0, list.Count);
						ItemIndex val2 = list[index];
						ItemTier tier2 = ItemCatalog.GetItemDef(val2).tier;
						ItemIndex newItemIndex = (ItemIndex)(-1);
						ItemTier val3 = tier2;
						ItemTier val4 = val3;
						switch ((int)val4)
						{
						case 0:
							newItemIndex = Items.ScrapWhiteSuppressed.itemIndex;
							break;
						case 1:
							newItemIndex = Items.ScrapGreenSuppressed.itemIndex;
							break;
						case 2:
							newItemIndex = Items.ScrapRedSuppressed.itemIndex;
							break;
						}
						ItemTransformation val5 = default(ItemTransformation);
						((ItemTransformation)(ref val5)).originalItemIndex = val2;
						((ItemTransformation)(ref val5)).newItemIndex = newItemIndex;
						((ItemTransformation)(ref val5)).allowWhenDisabled = true;
						((ItemTransformation)(ref val5)).maxToTransform = 1;
						val5.transformationType = (ItemTransformationTypeIndex)3;
						((ItemTransformation)(ref val5)).TryTransform(instances.inventory, ref val6);
					}
				}
			}
		}

		private void OnPatienceCurseDecay(Action<CharacterBody, BuffDef, float, float> orig, CharacterBody self, BuffDef buffDef, float duration, float totalDurationOverride)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			orig(self, buffDef, duration, totalDurationOverride);
			if (!((Object)(object)buffDef == (Object)(object)BuffDefs.PatienceCurse))
			{
				return;
			}
			BuffIndex buffIndex = buffDef.buffIndex;
			int num = 0;
			for (int i = 0; i < self.timedBuffs.Count; i++)
			{
				TimedBuff val = self.timedBuffs[i];
				if (val.buffIndex == buffIndex)
				{
					num++;
					val.totalDuration = (val.timer = 0.5f + (float)num * 1f);
				}
			}
		}

		private void OnPatienceInstantiate(Action<IZone, TeamIndex, int> orig, IZone safeZone, TeamIndex affectedTeam, int itemCount)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)OutOfTPRadiusManager._fogDamageControllerPrefab.GetComponent<FogDamageController>()))
			{
				Object.Destroy((Object)(object)OutOfTPRadiusManager._fogDamageControllerPrefab.GetComponent<FogDamageController>());
			}
			if (!Object.op_Implicit((Object)(object)OutOfTPRadiusManager._fogDamageControllerPrefab.GetComponent<FogBuffController>()))
			{
				OutOfTPRadiusManager._fogDamageControllerPrefab.AddComponent<FogBuffController>();
			}
			if (!_teamIndextoFogBuffController.ContainsKey(affectedTeam) && itemCount > 0)
			{
				FogBuffController component = Object.Instantiate<GameObject>(OutOfTPRadiusManager._fogDamageControllerPrefab).GetComponent<FogBuffController>();
				component.AddSafeZone(safeZone);
				component.tickPeriodSeconds = 1f / GetStackedStats(4f, 1f, itemCount);
				component.damageTimer = -2f;
				component.gracePeriod = 0f;
				BuffInfo val = new BuffInfo
				{
					buffDef = BuffDefs.PatienceCurse,
					duration = 1f,
					removeWhenSafe = false
				};
				component.buffs = (BuffInfo[])(object)new BuffInfo[1] { val };
				FogBuffControllerInstance value = new FogBuffControllerInstance
				{
					fogBuffControllerInstance = component
				};
				_teamIndextoFogBuffController.Add(affectedTeam, value);
				TeamFilter val2 = default(TeamFilter);
				if (((Component)component).TryGetComponent<TeamFilter>(ref val2))
				{
					val2.teamIndex = affectedTeam;
				}
				NetworkServer.Spawn(((Component)component).gameObject);
			}
		}

		private void OnPatienceIndecisive(Action<Inventory> orig, Inventory obj)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			CharacterMaster val = default(CharacterMaster);
			if (!NetworkServer.active || !Object.op_Implicit((Object)(object)TeleporterInteraction.instance) || !TeleporterInteraction.instance.isCharging || !((Component)obj).TryGetComponent<CharacterMaster>(ref val))
			{
				return;
			}
			TeamIndex teamIndex = val.teamIndex;
			int outOfTPRadiusCountFromTeam = OutOfTPRadiusManager.GetOutOfTPRadiusCountFromTeam(teamIndex);
			if (!_teamIndextoFogBuffController.TryGetValue(teamIndex, out var _))
			{
				if (outOfTPRadiusCountFromTeam > 0)
				{
					OutOfTPRadiusManager.InstantiateDamagerForTeam((IZone)(object)TeleporterInteraction.instance.holdoutZoneController, teamIndex, outOfTPRadiusCountFromTeam);
				}
			}
			else if (outOfTPRadiusCountFromTeam <= 0)
			{
				OutOfTPRadiusManager.DestroyFogDamagerForTeam(teamIndex);
			}
		}

		private void OnPatienceDestroy(Action<TeamIndex> orig, TeamIndex teamIndex)
		{
			//IL_0006: 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)
			if (_teamIndextoFogBuffController.TryGetValue(teamIndex, out var value) && Object.op_Implicit((Object)(object)value.fogBuffControllerInstance))
			{
				NetworkServer.Destroy(((Component)value.fogBuffControllerInstance).gameObject);
			}
			_teamIndextoFogBuffController.Remove(teamIndex);
		}

		private void OnPatienceDestroyAll(Action orig)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Invalid comparison between Unknown and I4
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkServer.active)
			{
				TeamIndex val = (TeamIndex)0;
				while ((int)val < 6)
				{
					OutOfTPRadiusManager.DestroyFogDamagerForTeam(val);
					val = (TeamIndex)(sbyte)(val + 1);
				}
				_teamIndextoFogBuffController.Clear();
			}
		}

		private void OnSkillExecute(orig_OnExecute orig, SkillDef self, GenericSkill skillSlot)
		{
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			if ((Object)(object)skillSlot.characterBody.inventory != (Object)null)
			{
				num = skillSlot.characterBody.inventory.GetItemCountEffective(Items.RandomDebuffOnInteract);
			}
			bool flag = false;
			if (num > 0 && self.stockToConsume > 0 && self.baseRechargeInterval > 0f)
			{
				for (int i = 0; i < num; i++)
				{
					if (Util.CheckRoll(5f, 0f, (CharacterMaster)null))
					{
						flag = true;
						break;
					}
				}
			}
			if (flag)
			{
				skillSlot.stock -= self.stockToConsume;
				if (self.resetCooldownTimerOnUse)
				{
					skillSlot.rechargeStopwatch = 0f;
				}
				skillSlot.rechargeStopwatch += skillSlot.finalRechargeInterval * 0.5f;
				EffectManager.SimpleSoundEffect(RandomDebuffOnInteractBehaviour.nseRandomDebuff.index, skillSlot.characterBody.corePosition, true);
			}
			else
			{
				orig.Invoke(self, skillSlot);
			}
		}

		private void CheckRainElite(orig_Start orig, CharacterBody self)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Invalid comparison between Unknown and I4
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Expected I4, but got Unknown
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Expected I4, but got Unknown
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Expected I4, but got Unknown
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Expected I4, but got Unknown
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			GetTotalItemCountFromTeamArgs val = default(GetTotalItemCountFromTeamArgs);
			((GetTotalItemCountFromTeamArgs)(ref val))..ctor(Items.IncreasedDifficulty.itemIndex);
			val.requiresAlive = false;
			val.requiredTeam = (TeamIndex)1;
			val.requiresConnected = true;
			val.onlyPlayerControlledCharacters = true;
			val.queryCountRegardlessOfInventoryOrItemDisabled = true;
			int totalItemCountFromTeam = Util.GetTotalItemCountFromTeam(val);
			bool flag = self.isBoss && Object.op_Implicit((Object)(object)Stage.instance) && Object.op_Implicit((Object)(object)Stage.instance.sceneDef) && !Stage.instance.sceneDef.validForRandomSelection;
			if (flag)
			{
				Log.Message("Big boy detected!!11!!!!!1!");
			}
			if (!self.isElite && !flag && totalItemCountFromTeam > 0 && Util.CheckRoll(5f, 0f, (CharacterMaster)null) && Object.op_Implicit((Object)(object)self.teamComponent) && (int)self.teamComponent.teamIndex == 2 && Object.op_Implicit((Object)(object)self.inventory))
			{
				EquipmentIndex val2 = (EquipmentIndex)(-1);
				float num = Run.instance.fixedTime - 1200f;
				float num2 = ((num > 0f) ? (5f + 0.01f * num) : 0f);
				Log.Message(Run.instance.fixedTime);
				if (Util.CheckRoll(num2, 0f, (CharacterMaster)null))
				{
					int num3 = Random.Range(0, CombatDirector.eliteTiers[5].eliteTypes.Length);
					val2 = CombatDirector.eliteTiers[5].eliteTypes[num3].eliteEquipmentDef.equipmentIndex;
				}
				else
				{
					int num4 = Random.Range(0, 3);
					EquipmentIndex[] array = (EquipmentIndex[])(object)new EquipmentIndex[4]
					{
						(EquipmentIndex)(int)Equipment.AffixRed.equipmentIndex,
						(EquipmentIndex)(int)Equipment.AffixBlue.equipmentIndex,
						(EquipmentIndex)(int)Equipment.AffixWhite.equipmentIndex,
						(EquipmentIndex)(int)Equipment.EliteEarthEquipment.equipmentIndex
					};
					val2 = array[num4];
				}
				self.inventory.SetEquipmentIndex(val2, true);
				EliteMonsterUpgradeData val3 = default(EliteMonsterUpgradeData);
				((EliteMonsterUpgradeData)(ref val3))..ctor(self.master, val2);
				Util.UpdateMonsterStatsBasedOnEliteEquipment(val3);
			}
		}

		private void AddNewHexBehaviour(orig_OnInventoryChanged orig, CharacterBody self)
		{
			if (NetworkServer.active)
			{
				if (Configs.rainEnable.Value)
				{
				}
				if (Configs.blindEnable.Value)
				{
					self.AddItemBehavior<BlindnessHexBehaviour>(self.inventory.GetItemCountEffective(Items.Blindness));
				}
			}
			orig.Invoke(self);
		}

		private void OnTakeDamage(orig_TakeDamage orig, HealthComponent self, DamageInfo info)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Invalid comparison between Unknown and I4
			//IL_0055: 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_0064: Invalid comparison between Unknown and I4
			//IL_00ff: 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)
			orig.Invoke(self, info);
			if (Configs.painEnable.Value && info.damage > 0f && Object.op_Implicit((Object)(object)self.body) && Object.op_Implicit((Object)(object)self.body.inventory) && (int)DamageTypeCombo.op_Implicit(info.damageType) != 67108864 && (int)DamageTypeCombo.op_Implicit(info.damageType) != 2048 && (Object)(object)info.attacker != (Object)null)
			{
				CharacterBody component = info.attacker.GetComponent<CharacterBody>();
				int itemCountEffective = self.body.inventory.GetItemCountEffective(Items.HexCurse);
				if ((Object)(object)component != (Object)null && itemCountEffective > 0 && Util.CheckRoll(10f, 0f, (CharacterMaster)null))
				{
					float num = info.damage / component.damage;
					num *= 0.5f + 0.25f * (float)itemCountEffective;
					DotController.InflictDot(((Component)self).gameObject, info.attacker, self.body.mainHurtBox, default(ProcChainMask), (DotIndex)0, 3f, num, (uint?)null);
				}
			}
			if (Configs.famineEnable.Value && info.damage > 0f && Object.op_Implicit((Object)(object)self.body) && Object.op_Implicit((Object)(object)self.body.inventory) && (!Object.op_Implicit((Object)(object)info.attacker) || !((Object)(object)info.attacker.GetComponent<CharacterBody>() != (Object)null) || !((Object)(object)info.attacker.GetComponent<CharacterBody>() == (Object)(object)self.body)))
			{
				int itemCountEffective2 = self.body.inventory.GetItemCountEffective(Items.LowerHealing);
				if (itemCountEffective2 > 0)
				{
					float stackedStats = GetStackedStats(2.5f, 0.5f, itemCountEffective2);
					self.body.AddTimedBuff(Buffs.HealingDisabled, stackedStats);
				}
			}
		}

		public void IL_RecalcStatsPain(ILContext il)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			MoveType val2 = (MoveType)2;
			int loc1 = -1;
			if (val.TryGotoNext(val2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "HexCurse")
			}))
			{
				if (val.TryGotoNext(val2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref loc1)
				}))
				{
					val.Emit(OpCodes.Ldc_I4_0);
					val.Emit(OpCodes.Stloc, loc1);
				}
				else
				{
					Log.Error(((MemberReference)il.Method).Name + " Hook 2 failed!");
				}
			}
			else
			{
				Log.Error(((MemberReference)il.Method).Name + " Hook 1 failed!");
			}
		}

		public void IL_RecalcStatsBlind(ILContext il)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			MoveType val2 = (MoveType)2;
			int loc1 = -1;
			if (val.TryGotoNext(val2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "Blindness")
			}))
			{
				if (val.TryGotoNext(val2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref loc1)
				}))
				{
					val.Emit(OpCodes.Ldc_I4_0);
					val.Emit(OpCodes.Stloc, loc1);
				}
				else
				{
					Log.Error(((MemberReference)il.Method).Name + " Hook 2 failed!");
				}
			}
			else
			{
				Log.Error(((MemberReference)il.Method).Name + " Hook 1 failed!");
			}
		}

		public void IL_RecalcDifficulty(ILContext il)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			MoveType val2 = (MoveType)2;
			int loc1 = -1;
			if (val.TryGotoNext(val2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "IncreasedDifficulty")
			}))
			{
				if (val.TryGotoNext(val2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref loc1)
				}))
				{
					val.Emit(OpCodes.Ldc_I4_0);
					val.Emit(OpCodes.Stloc, loc1);
				}
				else
				{
					Log.Error(((MemberReference)il.Method).Name + " Hook 2 failed!");
				}
			}
			else
			{
				Log.Error(((MemberReference)il.Method).Name + " Hook 1 failed!");
			}
		}

		private ItemDef RemoveItemBehaviour(Func<ItemDef> orig)
		{
			return null;
		}

		private float RemoveOldFamineBehaviour(Func<int, float> orig, int count)
		{
			return 1f;
		}

		private void OnCreatePickup(orig_CreatePickupDroplet_CreatePickupInfo_Vector3_Vector3 orig, CreatePickupInfo pickupInfo, Vector3 position, Vector3 velocity)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0078: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Invalid comparison between Unknown and I4
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Invalid comparison between Unknown and I4
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Invalid comparison between Unknown and I4
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Invalid comparison between Unknown and I4
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Invalid comparison between Unknown and I4
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Invalid comparison between Unknown and I4
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: 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_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			if (!pickupInfo.duplicated && !pickupInfo.recycled)
			{
				GetTotalItemCountFromTeamArgs val = default(GetTotalItemCountFromTeamArgs);
				((GetTotalItemCountFromTeamArgs)(ref val))..ctor(Items.RandomDebuffOnInteract.itemIndex);
				val.requiresAlive = false;
				val.requiredTeam = (TeamIndex)1;
				val.requiresConnected = true;
				val.onlyPlayerControlledCharacters = true;
				val.queryCountRegardlessOfInventoryOrItemDisabled = true;
				int totalItemCountFromTeam = Util.GetTotalItemCountFromTeam(val);
				if (totalItemCountFromTeam > 0)
				{
					_ = ((CreatePickupInfo)(ref pickupInfo)).pickup;
					_ = ((CreatePickupInfo)(ref pickupInfo)).pickup;
					UniquePickup pickup = ((CreatePickupInfo)(ref pickupInfo)).pickup;
					if (!((UniquePickup)(ref pickup)).isTempItem && Util.CheckRoll(20f + 10f * (float)totalItemCountFromTeam, 0f, (CharacterMaster)null))
					{
						PickupDef pickupDef = PickupCatalog.GetPickupDef(((CreatePickupInfo)(ref pickupInfo)).pickup.pickupIndex);
						if (pickupDef != null)
						{
							_ = pickupDef.equipmentIndex;
							if ((int)pickupDef.equipmentIndex == -1)
							{
								_ = pickupDef.itemIndex;
								if ((int)pickupDef.itemIndex != -1)
								{
									if ((int)pickupDef.itemTier == 0)
									{
										pickup = ((CreatePickupInfo)(ref pickupInfo)).pickup;
										((CreatePickupInfo)(ref pickupInfo)).pickup = ((UniquePickup)(ref pickup)).WithPickupIndex(PickupCatalog.FindPickupIndex(Items.ScrapWhite.itemIndex));
										EffectManager.SimpleSoundEffect(RandomDebuffOnInteractBehaviour.nseRandomDebuff.index, position, true);
									}
									if ((int)pickupDef.itemTier == 1)
									{
										pickup = ((CreatePickupInfo)(ref pickupInfo)).pickup;
										((CreatePickupInfo)(ref pickupInfo)).pickup = ((UniquePickup)(ref pickup)).WithPickupIndex(PickupCatalog.FindPickupIndex(Items.ScrapGreen.itemIndex));
										EffectManager.SimpleSoundEffect(RandomDebuffOnInteractBehaviour.nseRandomDebuff.index, position, true);
									}
									if ((int)pickupDef.itemTier == 2)
									{
										pickup = ((CreatePickupInfo)(ref pickupInfo)).pickup;
										((CreatePickupInfo)(ref pickupInfo)).pickup = ((UniquePickup)(ref pickup)).WithPickupIndex(PickupCatalog.FindPickupIndex(Items.ScrapRed.itemIndex));
										EffectManager.SimpleSoundEffect(RandomDebuffOnInteractBehaviour.nseRandomDebuff.index, position, true);
									}
									if ((int)pickupDef.itemTier == 4)
									{
										pickup = ((CreatePickupInfo)(ref pickupInfo)).pickup;
										((CreatePickupInfo)(ref pickupInfo)).pickup = ((UniquePickup)(ref pickup)).WithPickupIndex(PickupCatalog.FindPickupIndex(Items.ScrapYellow.itemIndex));
										EffectManager.SimpleSoundEffect(RandomDebuffOnInteractBehaviour.nseRandomDebuff.index, position, true);
									}
								}
							}
						}
					}
				}
			}
			orig.Invoke(pickupInfo, position, velocity);
		}

		public static List<MethodInfo> GetAnonymousMethods(Type t, string methodName)
		{
			List<MethodInfo> list = new List<MethodInfo>();
			Type[] nestedTypes = t.GetNestedTypes((BindingFlags)(-1));
			Type[] array = nestedTypes;
			foreach (Type type in array)
			{
				if (!type.Name.Contains("<>"))
				{
					continue;
				}
				MethodInfo[] methods = type.GetMethods((BindingFlags)(-1));
				foreach (MethodInfo methodInfo in methods)
				{
					if (methodInfo.Name.Contains(methodName))
					{
						list.Add(methodInfo);
					}
				}
			}
			MethodInfo[] methods2 = t.GetMethods((BindingFlags)(-1));
			foreach (MethodInfo methodInfo2 in methods2)
			{
				if (methodInfo2.Name.Contains("<") && methodInfo2.Name.Contains(methodName))
				{
					list.Add(methodInfo2);
				}
			}
			return list.OrderBy((MethodInfo m) => m.Name).ToList();
		}

		public static string GetStackDesc(float num, string type)
		{
			if (num > 0f)
			{
				return $" <style=cStack>(+{num}{type} per stack)</style>";
			}
			if (num < 0f)
			{
				return $" <style=cStack>({num}{type} per stack)</style>";
			}
			return "";
		}

		public static float GetStackedStats(float baseStat, float stackStat, int itemCount)
		{
			return baseStat - stackStat + stackStat * (float)itemCount;
		}

		public static int GetStackedStatsInt(int baseStat, int stackStat, int itemCount)
		{
			return baseStat - stackStat + stackStat * itemCount;
		}

		public static float ConvertReductionIntoStackingDivision(float baseFraction, int itemCount)
		{
			float num = 1f - baseFraction;
			float num2 = (1f + num) / num - 2f;
			num2 *= (float)(itemCount - 1);
			return num2 + 1f;
		}

		public static void DumpComponents(GameObject gameObject)
		{
			Component[] componentsInChildren = gameObject.GetComponentsInChildren(typeof(Component));
			foreach (Component data in componentsInChildren)
			{
				Log.Message(data);
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}