Decompiled source of Nuxlars UmbralMithrix v2.5.29

plugins/UmbralMithrix.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.BrotherMonster;
using EntityStates.BrotherMonster.Weapon;
using EntityStates.Destructible;
using EntityStates.LunarWisp;
using EntityStates.Missions.BrotherEncounter;
using HG;
using HG.Reflection;
using IL.EntityStates.BrotherMonster;
using IL.EntityStates.BrotherMonster.Weapon;
using IL.EntityStates.Missions.BrotherEncounter;
using IL.RoR2;
using IL.RoR2.CharacterAI;
using KinematicCharacterController;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.EntityStates;
using On.EntityStates.BrotherMonster;
using On.EntityStates.Destructible;
using On.EntityStates.Missions.BrotherEncounter;
using On.RoR2;
using On.RoR2.CharacterAI;
using On.RoR2.Items;
using R2API;
using R2API.Utils;
using Rewired.ComponentControls.Effects;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.AsyncManagement;
using RoR2.CharacterAI;
using RoR2.ContentManagement;
using RoR2.Items;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2BepInExPack.GameAssetPathsBetter;
using ShaderSwapper;
using UmbralMithrix.Components;
using UmbralMithrix.EntityStates;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.ResourceManagement.AsyncOperations;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("UmbralMithrix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+62ea34e9363bb645b24c7344d6f828a72f1689cf")]
[assembly: AssemblyProduct("UmbralMithrix")]
[assembly: AssemblyTitle("UmbralMithrix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: UnverifiableCode]
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;
		}
	}
}
public class PullController : MonoBehaviour
{
	[NonSerialized]
	public GameObject owner;

	private CharacterBody ownerBody;

	private TeamFilter teamFilter;

	private CharacterLosTracker losTracker;

	public float losObstructionFactor = 0.5f;

	public AnimationCurve pullMagnitudeTimeCurve;

	public AnimationCurve pullMagnitudeDistanceCurve;

	public float durationOfMaxPull;

	public float distanceForMaxPull;

	[Tooltip("If true, affects every team EXCEPT the defined team.")]
	[SerializeField]
	private bool invertTeamFilter;

	private float age;

	private void Start()
	{
		//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_0059: Expected O, but got Unknown
		ProjectileController val = default(ProjectileController);
		if (((Component)((Component)this).transform.parent).TryGetComponent<ProjectileController>(ref val))
		{
			owner = val.owner;
			ownerBody = owner.GetComponent<CharacterBody>();
		}
		teamFilter = ((Component)((Component)this).transform.parent).GetComponent<TeamFilter>();
		losTracker = new CharacterLosTracker
		{
			enabled = true
		};
	}

	private void OnDisable()
	{
		losTracker.enabled = false;
		losTracker.Dispose();
		losTracker = null;
	}

	private void FixedUpdate()
	{
		//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_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: 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)
		age += Time.fixedDeltaTime;
		float num = Mathf.Clamp01(age / durationOfMaxPull);
		float num2 = pullMagnitudeTimeCurve.Evaluate(num);
		ReadOnlyCollection<CharacterBody> readOnlyInstancesList = CharacterBody.readOnlyInstancesList;
		IDisplacementReceiver val2 = default(IDisplacementReceiver);
		for (int i = 0; i < readOnlyInstancesList.Count; i++)
		{
			CharacterBody val = readOnlyInstancesList[i];
			if (!((Object)(object)val == (Object)(object)ownerBody) && !CheckTeamFilter(val))
			{
				float num3 = (losTracker.CheckBodyHasLos(val) ? 1f : losObstructionFactor);
				if (val.hasEffectiveAuthority && ((Component)val).TryGetComponent<IDisplacementReceiver>(ref val2))
				{
					Vector3 val3 = ((Component)this).transform.position - val.transform.position;
					val2.AddDisplacement(((Vector3)(ref val3)).normalized * (num2 * num3 * Time.fixedDeltaTime) * pullMagnitudeDistanceCurve.Evaluate(((Vector3)(ref val3)).magnitude / distanceForMaxPull));
				}
			}
		}
	}

	private bool CheckTeamFilter(CharacterBody body)
	{
		//IL_0008: 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)
		bool flag = false;
		if (body.teamComponent.teamIndex == teamFilter.teamIndex)
		{
			flag = true;
		}
		if (invertTeamFilter)
		{
			flag = !flag;
		}
		return flag;
	}
}
namespace UmbralMithrix
{
	public class ArbitraryCrystalComponent : MonoBehaviour
	{
		private BullseyeSearch bullseyeSearch;

		private void Start()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			TetherVfxOrigin val = ((Component)this).gameObject.AddComponent<TetherVfxOrigin>();
			val.tetherPrefab = UmbralMithrix.tether;
			bullseyeSearch = new BullseyeSearch();
			bullseyeSearch.searchOrigin = ((Component)this).transform.position;
			bullseyeSearch.teamMaskFilter = TeamMask.allButNeutral;
			((TeamMask)(ref bullseyeSearch.teamMaskFilter)).RemoveTeam((TeamIndex)1);
			bullseyeSearch.maxDistanceFilter = 200f;
			bullseyeSearch.sortMode = (SortMode)1;
			bullseyeSearch.filterByLoS = false;
			bullseyeSearch.filterByDistinctEntity = true;
			bullseyeSearch.RefreshCandidates();
			List<HurtBox> list = bullseyeSearch.GetResults().ToList();
			for (int i = 0; i < list.Count; i++)
			{
				HurtBox val2 = list[i];
				if (!Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)val2.healthComponent))
				{
					continue;
				}
				CharacterBody body = val2.healthComponent.body;
				if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)PhaseCounter.instance))
				{
					string text = ((!NetworkServer.active) ? ((PhaseCounter.instance.phase == 3) ? "BrotherBody(Clone)" : "BrotherHurtBodyP3(Clone)") : ((PhaseCounter.instance.phase == 2) ? "BrotherBody(Clone)" : "BrotherHurtBodyP3(Clone)"));
					if (((Object)body).name == text)
					{
						val.AddTether(body.transform);
					}
				}
			}
		}
	}
	public class CloneController : MonoBehaviour
	{
		private static SpawnCard _cloneCard;

		private static GameObject _phantomBody;

		private List<CharacterBody> playerBodies = new List<CharacterBody>();

		private float stopwatch;

		private float interval = 8f;

		public static void Init()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: 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)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			_phantomBody = AssetAsyncReferenceManager<GameObject>.LoadAsset(new AssetReferenceT<GameObject>(RoR2_Base_Brother.BrotherPhantomBody_prefab), (AsyncReferenceHandleUnloadType)2).WaitForCompletion();
			AssetReferenceT<SkinDef> originalSkinRef = new AssetReferenceT<SkinDef>(RoR2_Base_Brother.skinBrotherBodyDefault_asset);
			SkinDef originalSkin = AssetAsyncReferenceManager<SkinDef>.LoadAsset(originalSkinRef, (AsyncReferenceHandleUnloadType)2).WaitForCompletion();
			AsyncOperationHandle<SpawnCard> val = AssetAsyncReferenceManager<SpawnCard>.LoadAsset(new AssetReferenceT<SpawnCard>(RoR2_Junk_BrotherGlass.cscBrotherGlass_asset), (AsyncReferenceHandleUnloadType)2);
			val.Completed += delegate(AsyncOperationHandle<SpawnCard> x)
			{
				_cloneCard = x.Result;
			};
			AsyncOperationHandle<GameObject> val2 = AssetAsyncReferenceManager<GameObject>.LoadAsset(new AssetReferenceT<GameObject>(RoR2_Junk_BrotherGlass.BrotherGlassMaster_prefab), (AsyncReferenceHandleUnloadType)2);
			val2.Completed += delegate(AsyncOperationHandle<GameObject> x)
			{
				GameObject result = x.Result;
				foreach (AISkillDriver item3 in result.GetComponents<AISkillDriver>().ToList())
				{
					if (item3.customName == "CastUlt")
					{
						item3.requiredSkill = null;
					}
				}
				result.GetComponent<CharacterMaster>().bodyPrefab = _phantomBody;
			};
			_phantomBody.GetComponent<EntityStateMachine>().initialStateType = new SerializableEntityStateType(typeof(GlassSpawnState));
			CharacterBody component = _phantomBody.GetComponent<CharacterBody>();
			CharacterDirection component2 = _phantomBody.GetComponent<CharacterDirection>();
			CharacterMotor component3 = _phantomBody.GetComponent<CharacterMotor>();
			component.baseMaxHealth = ModConfig.basehealth.Value;
			component.levelMaxHealth = ModConfig.levelhealth.Value;
			component.baseDamage = ModConfig.basedamage.Value / 2f;
			component.levelDamage = ModConfig.leveldamage.Value / 2f;
			component3.airControl = ModConfig.aircontrol.Value;
			component2.turnSpeed = ModConfig.turningspeed.Value;
			SkillDef val3 = ScriptableObject.CreateInstance<SkillDef>();
			val3.skillName = "UmbralOrb";
			((Object)val3).name = "UmbralOrb";
			val3.activationState = new SerializableEntityStateType(typeof(GlassOrbAttack));
			val3.activationStateMachineName = "Body";
			val3.interruptPriority = (InterruptPriority)2;
			val3.baseMaxStock = 1;
			val3.baseRechargeInterval = 6f;
			val3.rechargeStock = 1;
			val3.requiredStock = 1;
			val3.stockToConsume = 1;
			val3.dontAllowPastMaxStocks = true;
			val3.beginSkillCooldownOnSkillEnd = false;
			val3.canceledFromSprinting = true;
			val3.forceSprintDuringState = false;
			val3.fullRestockOnAssign = true;
			val3.resetCooldownTimerOnUse = true;
			val3.isCombatSkill = true;
			val3.mustKeyPress = false;
			val3.cancelSprintingOnActivation = true;
			SkillFamily val4 = ScriptableObject.CreateInstance<SkillFamily>();
			((Object)val4).name = "UmbralPhantomPrimaryFamily";
			val4.variants = (Variant[])(object)new Variant[1]
			{
				new Variant
				{
					skillDef = val3
				}
			};
			SkillLocator val5 = default(SkillLocator);
			if (_phantomBody.TryGetComponent<SkillLocator>(ref val5))
			{
				GenericSkill val6 = _phantomBody.AddComponent<GenericSkill>();
				val6._skillFamily = val4;
				val5.special = val6;
				val5.primary = null;
			}
			RoR2Application.onNextUpdate += delegate
			{
				//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a8: 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)
				//IL_0228: 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_02a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_0310: Unknown result type (might be due to invalid IL or missing references)
				//IL_026f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0322: Unknown result type (might be due to invalid IL or missing references)
				//IL_0356: Unknown result type (might be due to invalid IL or missing references)
				//IL_035b: Unknown result type (might be due to invalid IL or missing references)
				//IL_035d: Unknown result type (might be due to invalid IL or missing references)
				//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
				//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
				//IL_0415: Unknown result type (might be due to invalid IL or missing references)
				//IL_041a: Unknown result type (might be due to invalid IL or missing references)
				//IL_041c: Unknown result type (might be due to invalid IL or missing references)
				//IL_048e: Unknown result type (might be due to invalid IL or missing references)
				//IL_04a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_0559: Unknown result type (might be due to invalid IL or missing references)
				//IL_055e: Unknown result type (might be due to invalid IL or missing references)
				Transform val7 = null;
				ModelLocator val8 = default(ModelLocator);
				if (Object.op_Implicit((Object)(object)_phantomBody) && _phantomBody.TryGetComponent<ModelLocator>(ref val8))
				{
					val7 = val8.modelTransform;
				}
				if (Object.op_Implicit((Object)(object)val7))
				{
					ModelSkinController val9 = UnityObjectExtensions.EnsureComponent<ModelSkinController>(((Component)val7).gameObject);
					ModelSkinController val10 = val9;
					if (val10.skins == null)
					{
						val10.skins = Array.Empty<SkinDef>();
					}
					int num = Array.IndexOf(val9.skins, originalSkin);
					SkinDef val11 = Object.Instantiate<SkinDef>(originalSkin);
					((Object)val11).name = "skinBrotherGlassBodyDefault";
					Transform transform = val11.rootObject.transform;
					val11.rootObject = ((Component)val7).gameObject;
					ValueTuple<AssetReferenceT<SkinDefParams>, SkinDefParams> skinParams = val11.GetSkinParams();
					AssetReferenceT<SkinDefParams> item = skinParams.Item1;
					SkinDefParams item2 = skinParams.Item2;
					AssetOrDirectReference<SkinDefParams> val12 = new AssetOrDirectReference<SkinDefParams>
					{
						address = item,
						directRef = item2
					};
					SkinDefParams val13 = Object.Instantiate<SkinDefParams>(val12.WaitForCompletion());
					((Object)val13).name = ((Object)val11).name + "_params";
					val11.skinDefParams = val13;
					val11.skinDefParamsAddress = new AssetReferenceT<SkinDefParams>(string.Empty);
					val11.optimizedSkinDefParams = val13;
					val11.optimizedSkinDefParamsAddress = new AssetReferenceT<SkinDefParams>(string.Empty);
					RendererInfo[] rendererInfos = val13.rendererInfos;
					List<RendererInfo> list = new List<RendererInfo>(rendererInfos.Length);
					list.AddRange(rendererInfos);
					List<RendererInfo> list2 = list;
					GameObjectActivation[] gameObjectActivations = val13.gameObjectActivations;
					List<GameObjectActivation> list3 = new List<GameObjectActivation>(gameObjectActivations.Length);
					list3.AddRange(gameObjectActivations);
					List<GameObjectActivation> list4 = list3;
					MeshReplacement[] meshReplacements = val13.meshReplacements;
					List<MeshReplacement> list5 = new List<MeshReplacement>(meshReplacements.Length);
					list5.AddRange(meshReplacements);
					List<MeshReplacement> list6 = list5;
					LightInfo[] lightReplacements = val13.lightReplacements;
					List<LightInfo> list7 = new List<LightInfo>(lightReplacements.Length);
					list7.AddRange(lightReplacements);
					List<LightInfo> list8 = list7;
					for (int num2 = list2.Count - 1; num2 >= 0; num2--)
					{
						RendererInfo val14 = list2[num2];
						Renderer renderer = val14.renderer;
						val14.renderer = null;
						if (Object.op_Implicit((Object)(object)renderer) && ((Component)renderer).transform.IsChildOf(transform))
						{
							string text = Util.BuildPrefabTransformPath(transform, ((Component)renderer).transform, false, false);
							if (!string.IsNullOrEmpty(text))
							{
								Transform val15 = val7.Find(text);
								if (Object.op_Implicit((Object)(object)val15))
								{
									Component component4 = ((Component)val15).GetComponent(((object)renderer).GetType());
									val14.renderer = (Renderer)(object)((component4 is Renderer) ? component4 : null);
								}
							}
						}
						if (Object.op_Implicit((Object)(object)val14.renderer))
						{
							string name = ((Object)val14.renderer).name;
							if (name == "BrotherHammerConcrete" || name == "BrotherBodyMesh")
							{
								val14.defaultMaterial = null;
								val14.defaultMaterialAddress = new AssetReferenceT<Material>(RoR2_Base_Brother.maBrotherGlassOverlay_mat);
							}
							list2[num2] = val14;
						}
						else
						{
							list2.RemoveAt(num2);
						}
					}
					for (int num3 = list4.Count - 1; num3 >= 0; num3--)
					{
						GameObjectActivation val16 = list4[num3];
						GameObject gameObject = val16.gameObject;
						val16.gameObject = null;
						if (Object.op_Implicit((Object)(object)gameObject) && gameObject.transform.IsChildOf(transform))
						{
							string text2 = Util.BuildPrefabTransformPath(transform, gameObject.transform, false, false);
							if (!string.IsNullOrEmpty(text2))
							{
								Transform val17 = val7.Find(text2);
								if (Object.op_Implicit((Object)(object)val17))
								{
									val16.gameObject = ((Component)val17).gameObject;
								}
							}
						}
						if (Object.op_Implicit((Object)(object)val16.gameObject))
						{
							list4[num3] = val16;
						}
						else
						{
							list4.RemoveAt(num3);
						}
					}
					for (int num4 = list6.Count - 1; num4 >= 0; num4--)
					{
						MeshReplacement val18 = list6[num4];
						Renderer renderer2 = val18.renderer;
						val18.renderer = null;
						if (Object.op_Implicit((Object)(object)renderer2) && ((Component)renderer2).transform.IsChildOf(transform))
						{
							string text3 = Util.BuildPrefabTransformPath(transform, ((Component)renderer2).transform, false, false);
							if (!string.IsNullOrEmpty(text3))
							{
								Transform val19 = val7.Find(text3);
								if (Object.op_Implicit((Object)(object)val19))
								{
									Component component5 = ((Component)val19).GetComponent(((object)renderer2).GetType());
									val18.renderer = (Renderer)(object)((component5 is Renderer) ? component5 : null);
								}
							}
						}
						if (Object.op_Implicit((Object)(object)val18.renderer))
						{
							list6[num4] = val18;
						}
						else
						{
							list6.RemoveAt(num4);
						}
					}
					for (int num5 = list8.Count - 1; num5 >= 0; num5--)
					{
						LightInfo val20 = list8[num5];
						Light light = val20.light;
						val20.light = null;
						if (Object.op_Implicit((Object)(object)light) && ((Component)light).transform.IsChildOf(transform))
						{
							string text4 = Util.BuildPrefabTransformPath(transform, ((Component)light).transform, false, false);
							if (!string.IsNullOrEmpty(text4))
							{
								Transform val21 = val7.Find(text4);
								if (Object.op_Implicit((Object)(object)val21))
								{
									Component component6 = ((Component)val21).GetComponent(((object)light).GetType());
									val20.light = (Light)(object)((component6 is Light) ? component6 : null);
								}
							}
						}
						if (Object.op_Implicit((Object)(object)val20.light))
						{
							list8[num5] = val20;
						}
						else
						{
							list8.RemoveAt(num5);
						}
					}
					val13.rendererInfos = list2.ToArray();
					val13.gameObjectActivations = list4.ToArray();
					val13.meshReplacements = list6.ToArray();
					val13.lightReplacements = list8.ToArray();
					if (ArrayUtils.IsInBounds<SkinDef>(val9.skins, num))
					{
						val9.skins[num] = val11;
					}
					else
					{
						ArrayUtils.ArrayAppend<SkinDef>(ref val9.skins, ref val11);
					}
					UnityObjectExtensions.EnsureComponent<PersistentOverlayController>(((Component)val7).gameObject).OverlayMaterialReference = new AssetReferenceT<Material>(RoR2_Base_Brother.matBrotherGlassDistortion_mat);
					val12.Reset();
					AssetAsyncReferenceManager<SkinDef>.UnloadAsset(originalSkinRef);
					AsyncOperationHandle<SkinDefParams> val22 = AssetAsyncReferenceManager<SkinDefParams>.LoadAsset(val9.skins[0].skinDefParamsAddress, (AsyncReferenceHandleUnloadType)2);
					val22.Completed += delegate(AsyncOperationHandle<SkinDefParams> x)
					{
						//IL_0023: 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_0029: Unknown result type (might be due to invalid IL or missing references)
						//IL_0036: Unknown result type (might be due to invalid IL or missing references)
						//IL_0087: Unknown result type (might be due to invalid IL or missing references)
						//IL_0088: Unknown result type (might be due to invalid IL or missing references)
						for (int num6 = x.Result.rendererInfos.Count() - 1; num6 >= 0; num6--)
						{
							RendererInfo val23 = x.Result.rendererInfos[num6];
							if (Object.op_Implicit((Object)(object)val23.renderer))
							{
								string name2 = ((Object)val23.renderer).name;
								if (name2 == "BrotherHammerConcrete" || name2 == "BrotherBodyMesh")
								{
									val23.defaultMaterial = UmbralMithrix.Bundle.LoadAsset<Material>("Assets/Assets/Materials/matNewPhantom.mat");
									val23.defaultMaterialAddress = null;
								}
								x.Result.rendererInfos[num6] = val23;
							}
						}
					};
				}
			};
			ContentAddition.AddSkillFamily(val4);
			ContentAddition.AddSkillDef(val3);
		}

		private void Start()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Invalid comparison between Unknown and I4
			foreach (CharacterMaster readOnlyInstances in CharacterMaster.readOnlyInstancesList)
			{
				if ((int)readOnlyInstances.teamIndex == 1)
				{
					CharacterBody body = readOnlyInstances.GetBody();
					if (Object.op_Implicit((Object)(object)body) && body.isPlayerControlled)
					{
						playerBodies.Add(body);
					}
				}
			}
		}

		private void FixedUpdate()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Invalid comparison between Unknown and I4
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			//IL_009f: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: 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_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Expected O, but got Unknown
			stopwatch += Time.deltaTime;
			if (stopwatch < interval)
			{
				return;
			}
			playerBodies.Clear();
			foreach (CharacterMaster readOnlyInstances in CharacterMaster.readOnlyInstancesList)
			{
				if ((int)readOnlyInstances.teamIndex == 1)
				{
					CharacterBody body = readOnlyInstances.GetBody();
					if (Object.op_Implicit((Object)(object)body) && body.isPlayerControlled)
					{
						playerBodies.Add(body);
					}
				}
			}
			stopwatch %= interval;
			DirectorPlacementRule val = new DirectorPlacementRule();
			val.placementMode = (PlacementMode)3;
			val.minDistance = 8f;
			val.maxDistance = 16f;
			val.position = playerBodies[Random.Range(0, playerBodies.Count)].corePosition;
			Xoroshiro128Plus rng = RoR2Application.rng;
			DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest(_cloneCard, val, rng)
			{
				summonerBodyObject = ((Component)this).gameObject,
				onSpawnedServer = delegate(SpawnResult spawnResult)
				{
					//IL_0000: 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_0016: Unknown result type (might be due to invalid IL or missing references)
					Inventory val2 = default(Inventory);
					if (spawnResult.success && Object.op_Implicit((Object)(object)spawnResult.spawnedInstance) && spawnResult.spawnedInstance.TryGetComponent<Inventory>(ref val2))
					{
						val2.GiveItemPermanent(Items.HealthDecay, 10);
					}
				}
			});
		}
	}
	public class DeathZoneController : MonoBehaviour
	{
		private SphereZone zone;

		private float stopwatch;

		private float interval = 1f;

		private float zoneRadius = 100f;

		private void Start()
		{
			zone = ((Component)this).GetComponent<SphereZone>();
		}

		private void FixedUpdate()
		{
			stopwatch += Time.deltaTime;
			if (!(stopwatch < interval))
			{
				stopwatch %= interval;
				if (zone.Networkradius > zoneRadius)
				{
					SphereZone obj = zone;
					obj.Networkradius -= 10f;
				}
			}
		}
	}
	public class OrbDelayController : MonoBehaviour
	{
		private float delay = 2f;

		private float stopwatch;

		private ProjectileSimple projectileSimple;

		private void Start()
		{
			projectileSimple = ((Component)this).GetComponent<ProjectileSimple>();
		}

		private void FixedUpdate()
		{
			stopwatch += Time.deltaTime;
			if (stopwatch >= delay)
			{
				projectileSimple.desiredForwardSpeed = 50f;
				Object.Destroy((Object)(object)this);
			}
		}
	}
	public class P4Controller : MonoBehaviour
	{
		public bool finishedItemSteal;

		private CharacterBody body;

		private float shockwaveStopwatch;

		private float pizzaStopwatch;

		private float missileStopwatch;

		private float shockwaveInterval = 3.75f;

		private float pizzaInterval = 1.5f;

		private float missileInterval = 1.25f;

		private readonly List<CharacterBody> _trackedPlayers = new List<CharacterBody>();

		private void Start()
		{
			body = ((Component)this).GetComponent<CharacterBody>();
		}

		private void OnEnable()
		{
			foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
			{
				if (Object.op_Implicit((Object)(object)instance) && instance.isConnected && Object.op_Implicit((Object)(object)instance.master))
				{
					CharacterBody val = instance.master.GetBody();
					if (Object.op_Implicit((Object)(object)val))
					{
						handlePlayerBody(val);
					}
				}
			}
			CharacterBody.onBodyStartGlobal += onBodyStartGlobal;
			CharacterBody.onBodyDestroyGlobal += onBodyDestroyGlobal;
		}

		private void OnDisable()
		{
			CharacterBody.onBodyStartGlobal -= onBodyStartGlobal;
			CharacterBody.onBodyDestroyGlobal -= onBodyDestroyGlobal;
			foreach (CharacterBody trackedPlayer in _trackedPlayers)
			{
				trackedPlayer.RemoveBuff(Buffs.TeamWarCry);
			}
			_trackedPlayers.Clear();
		}

		private void FixedUpdate()
		{
			//IL_01f6: 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_03bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0406: Unknown result type (might be due to invalid IL or missing references)
			//IL_0408: Unknown result type (might be due to invalid IL or missing references)
			//IL_040a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: 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_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: 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_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active)
			{
				return;
			}
			if (finishedItemSteal && Object.op_Implicit((Object)(object)body.healthComponent) && body.healthComponent.alive)
			{
				missileStopwatch += Time.deltaTime;
				pizzaStopwatch += Time.deltaTime;
				shockwaveStopwatch += Time.deltaTime;
				if (missileStopwatch >= missileInterval)
				{
					missileStopwatch %= 1f;
					int num = 8;
					int num2 = 8;
					Vector3 val = (Object.op_Implicit((Object)(object)body.inputBank) ? body.inputBank.aimDirection : body.transform.forward);
					float num3 = 180f / (float)num;
					float num4 = (float)(3.0 + (double)(int)body.radius * 1.0);
					float damage = body.damage * 0.5f;
					Quaternion rotation = Util.QuaternionSafeLookRotation(val);
					for (int i = 0; i < num; i++)
					{
						Vector3 position = body.aimOrigin + Quaternion.AngleAxis((float)((double)(num2 - 1) * (double)num3 - (double)num3 * (double)(num - 1) / 2.0), val) * Vector3.up * num4;
						ProjectileManager.instance.FireProjectile(new FireProjectileInfo
						{
							projectilePrefab = UmbralMithrix.lunarMissile,
							position = position,
							rotation = rotation,
							owner = ((Component)this).gameObject,
							damage = damage,
							force = 100f
						});
						num2--;
					}
				}
			}
			if (pizzaStopwatch >= pizzaInterval)
			{
				pizzaStopwatch %= 1f;
				Vector3 val2 = Vector3.ProjectOnPlane(body.inputBank.aimDirection, Vector3.up);
				float num5 = 40f;
				Vector3 val3 = default(Vector3);
				((Vector3)(ref val3))..ctor((float)Random.Range(-45, -25), 0f, (float)Random.Range(-45, -25));
				if ((double)Random.value <= 0.5)
				{
					((Vector3)(ref val3))..ctor((float)Random.Range(25, 45), 0f, (float)Random.Range(25, 45));
				}
				GameObject val4 = UmbralMithrix.leftP4Line;
				if ((double)Random.value <= 0.5)
				{
					val4 = UmbralMithrix.rightP4Line;
				}
				Vector3 val5 = body.footPosition;
				if (_trackedPlayers.Count > 0)
				{
					Vector3 footPosition = _trackedPlayers[Random.Range(0, _trackedPlayers.Count)].footPosition;
					footPosition.y = 491f;
					val5 = footPosition;
				}
				val5 += val3;
				for (int j = 0; j < 9; j++)
				{
					Vector3 val6 = Quaternion.AngleAxis(num5 * (float)j, Vector3.up) * val2;
					ProjectileManager.instance.FireProjectile(val4, val5, Util.QuaternionSafeLookRotation(val6), ((Component)this).gameObject, body.damage * (UltChannelState.waveProjectileDamageCoefficient * 0.5f), UltChannelState.waveProjectileForce / 8f, Util.CheckRoll(body.crit, body.master), (DamageColorIndex)0, (GameObject)null, -1f, (DamageTypeCombo?)null);
				}
			}
			if (shockwaveStopwatch >= shockwaveInterval)
			{
				shockwaveStopwatch %= 1f;
				Util.PlaySound(ExitSkyLeap.soundString, ((Component)this).gameObject);
				float num6 = 360f / (float)ExitSkyLeap.waveProjectileCount;
				Vector3 val7 = Vector3.ProjectOnPlane(body.inputBank.aimDirection, Vector3.up);
				Vector3 footPosition2 = body.footPosition;
				for (int k = 0; k < ExitSkyLeap.waveProjectileCount; k++)
				{
					Vector3 val8 = Quaternion.AngleAxis(num6 * (float)k, Vector3.up) * val7;
					ProjectileManager.instance.FireProjectile(ExitSkyLeap.waveProjectilePrefab, footPosition2, Util.QuaternionSafeLookRotation(val8), ((Component)this).gameObject, body.damage * (ExitSkyLeap.waveProjectileDamageCoefficient * 0.75f), ExitSkyLeap.waveProjectileForce / 4f, Util.CheckRoll(body.crit, body.master), (DamageColorIndex)0, (GameObject)null, -1f, (DamageTypeCombo?)null);
				}
			}
		}

		private void onBodyStartGlobal(CharacterBody body)
		{
			if (body.isPlayerControlled)
			{
				handlePlayerBody(body);
			}
		}

		private void onBodyDestroyGlobal(CharacterBody body)
		{
			_trackedPlayers.Remove(body);
		}

		private void handlePlayerBody(CharacterBody playerBody)
		{
			if (!_trackedPlayers.Contains(playerBody))
			{
				_trackedPlayers.Add(playerBody);
				if (NetworkServer.active)
				{
					playerBody.AddBuff(Buffs.TeamWarCry);
				}
			}
		}
	}
	public class SelfDestructController : MonoBehaviour
	{
		private void Start()
		{
			((MonoBehaviour)this).StartCoroutine(SelfDestruct());
		}

		private IEnumerator SelfDestruct()
		{
			yield return (object)new WaitForSeconds(ModConfig.CrushingLeap.Value);
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}
	public class UmbralMissionController : MonoBehaviour
	{
		public static UmbralMissionController instance;

		public CharacterBody currentPhaseBody;

		public CharacterBody p3CloneBody;

		public bool practiceModeEnabled;

		public bool spawnedClone;

		public bool finishedItemSteal;

		public bool p2ThresholdReached;

		public bool p3ThresholdReached;

		public List<GameObject> timeCrystals = new List<GameObject>();

		private void Start()
		{
			instance = this;
		}
	}
	[RequireComponent(typeof(CharacterController))]
	public class WaveController : MonoBehaviour
	{
		private CharacterController _characterController;

		private void Start()
		{
			_characterController = ((Component)this).GetComponent<CharacterController>();
		}

		private void FixedUpdate()
		{
			//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)
			Vector3 velocity = _characterController.velocity;
			if (((Vector3)(ref velocity)).magnitude <= 10f)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
	}
	public class MiscHooks
	{
		public MiscHooks()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Expected O, but got Unknown
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Expected O, but got Unknown
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Expected O, but got Unknown
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Expected O, but got Unknown
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Expected O, but got Unknown
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Expected O, but got Unknown
			BaseAI.FindEnemyHurtBox += new Manipulator(TargetOnlyPlayers);
			CharacterBody.UpdateAllTemporaryVisualEffects += new Manipulator(AddUmbralParticles);
			CharacterModel.UpdateOverlays += new Manipulator(AddUmbralOverlay);
			BaseAI.FindEnemyHurtBox += new hook_FindEnemyHurtBox(ChangeP3CloneTargeting);
			CharacterMaster.OnBodyDeath += new hook_OnBodyDeath(CharacterMaster_OnBodyDeath);
			PurchaseInteraction.OnInteractionBegin += new hook_OnInteractionBegin(PurchaseInteraction_OnInteractionBegin);
			CombatDirector.OnEnable += new hook_OnEnable(CombatDirector_OnEnable);
			HealthComponent.SendDamageDealt += new hook_SendDamageDealt(ThresholdCheck);
			SceneCatalog.onMostRecentSceneDefChanged += onMostRecentSceneDefChanged;
			CharacterMaster.OnBodyStart += new hook_OnBodyStart(CharacterMaster_OnBodyStart);
			FrozenState.OnEnter += new hook_OnEnter(FrozenState_OnEnter);
			CharacterBody.AddTimedBuff_BuffDef_float += new hook_AddTimedBuff_BuffDef_float(AddTimedBuff_BuffDef_float);
			TimeCrystalDeath.OnEnter += new hook_OnEnter(RemoveUmbralImmune);
			ItemStealController.BrotherItemFilter += new hook_BrotherItemFilter(ItemStealController_BrotherItemFilter);
			PhysicsProjectileBehavior.canSpawnAlly += new hook_canSpawnAlly(PhysicsProjectileBehavior_canSpawnAlly);
		}

		private bool PhysicsProjectileBehavior_canSpawnAlly(orig_canSpawnAlly orig, PhysicsProjectileBehavior self)
		{
			if (orig.Invoke(self))
			{
				if (Object.op_Implicit((Object)(object)PhaseCounter.instance) && PhaseCounter.instance.phase == 4)
				{
					return !Object.op_Implicit((Object)(object)UmbralMissionController.instance);
				}
				return true;
			}
			return false;
		}

		private bool ItemStealController_BrotherItemFilter(orig_BrotherItemFilter orig, ItemIndex itemIndex)
		{
			return false;
		}

		private void RemoveUmbralImmune(orig_OnEnter orig, TimeCrystalDeath self)
		{
			if (Object.op_Implicit((Object)(object)PhaseCounter.instance) && (PhaseCounter.instance.phase == 2 || PhaseCounter.instance.phase == 3))
			{
				TimeCrystalDeath.explosionDamageCoefficient = 0f;
				TimeCrystalDeath.explosionForce = 0f;
				if (Object.op_Implicit((Object)(object)UmbralMissionController.instance))
				{
					CharacterBody currentPhaseBody = UmbralMissionController.instance.currentPhaseBody;
					if (Object.op_Implicit((Object)(object)currentPhaseBody) && currentPhaseBody.HasBuff(Buffs.Immune) && UmbralMissionController.instance.timeCrystals.Count == 1)
					{
						UmbralMissionController.instance.timeCrystals.RemoveAt(0);
						currentPhaseBody.RemoveBuff(Buffs.Immune);
					}
					else if (UmbralMissionController.instance.timeCrystals.Count > 0)
					{
						UmbralMissionController.instance.timeCrystals.RemoveAt(0);
					}
				}
			}
			else
			{
				TimeCrystalDeath.explosionForce = 4000f;
				TimeCrystalDeath.explosionDamageCoefficient = 2f;
			}
			orig.Invoke(self);
		}

		private void TargetOnlyPlayers(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<BullseyeSearch>(x, "GetResults")
			}))
			{
				return;
			}
			val.Emit(OpCodes.Ldarg_0);
			val.EmitDelegate<Func<IEnumerable<HurtBox>, BaseAI, IEnumerable<HurtBox>>>((Func<IEnumerable<HurtBox>, BaseAI, IEnumerable<HurtBox>>)delegate(IEnumerable<HurtBox> results, BaseAI instance)
			{
				if (Object.op_Implicit((Object)(object)instance) && (((Object)instance.body).name == "BrotherBody(Clone)" || ((Object)instance.body).name == "BrotherGlassBody(Clone)" || ((Object)instance.body).name == "BrotherHurtBody(Clone)"))
				{
					IEnumerable<HurtBox> enumerable = results.Where(delegate(HurtBox hurtBox)
					{
						GameObject val2 = HurtBox.FindEntityObject(hurtBox);
						CharacterBody val3 = default(CharacterBody);
						return Object.op_Implicit((Object)(object)val2) && val2.TryGetComponent<CharacterBody>(ref val3) && val3.isPlayerControlled;
					});
					if (!enumerable.Any())
					{
						return results;
					}
					return enumerable;
				}
				return results;
			});
		}

		private HurtBox ChangeP3CloneTargeting(orig_FindEnemyHurtBox orig, BaseAI self, float maxDistance, bool full360Vision, bool filterByLoS)
		{
			if (Object.op_Implicit((Object)(object)self) && (((Object)self.body).name == "BrotherBody(Clone)" || ((Object)self.body).name == "BrotherGlassBody(Clone)" || ((Object)self.body).name == "BrotherHurtBody(Clone)") && Object.op_Implicit((Object)(object)PhaseCounter.instance) && PhaseCounter.instance.phase == 3)
			{
				maxDistance = float.PositiveInfinity;
				filterByLoS = false;
				full360Vision = true;
			}
			return orig.Invoke(self, maxDistance, full360Vision, filterByLoS);
		}

		private void AddUmbralParticles(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			val.GotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "InvadingDoppelganger")
			});
			val.Index += 2;
			val.Emit(OpCodes.Ldarg_0);
			val.EmitDelegate<Func<int, CharacterBody, int>>((Func<int, CharacterBody, int>)delegate(int vengeanceCount, CharacterBody self)
			{
				if (((Object)self).name.Contains("Brother") && Object.op_Implicit((Object)(object)self.inventory) && self.inventory.GetItemCountPermanent(UmbralMithrix.UmbralItem) > 0 && ModConfig.purpleMithrix.Value)
				{
					vengeanceCount++;
				}
				return vengeanceCount;
			});
		}

		private void AddUmbralOverlay(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			ILCursor[] array = default(ILCursor[]);
			if (!val.TryFindNext(ref array, new Func<Instruction, bool>[2]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "InvadingDoppelganger"),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Inventory>(x, "GetItemCountEffective")
			}))
			{
				Log.Error("Failed to find patch location", "/home/tizian/Documents/GitHub/UmbralMithrix/UmbralMithrix/Hooks/MiscHooks.cs", "AddUmbralOverlay", 144);
				return;
			}
			val.Goto(array[1].Next, (MoveType)2, false);
			val.Emit(OpCodes.Ldarg_0);
			val.EmitDelegate<Func<int, CharacterModel, int>>((Func<int, CharacterModel, int>)getDoppelGangerCount);
			static int getDoppelGangerCount(int doppelgangerCount, CharacterModel characterModel)
			{
				if (Object.op_Implicit((Object)(object)characterModel) && Object.op_Implicit((Object)(object)characterModel.body))
				{
					if (((Object)characterModel.body).name.Contains("Brother") && Object.op_Implicit((Object)(object)characterModel.body.inventory) && characterModel.body.inventory.GetItemCountPermanent(UmbralMithrix.UmbralItem) > 0 && ModConfig.purpleMithrix.Value)
					{
						doppelgangerCount++;
					}
					if (Object.op_Implicit((Object)(object)((Component)characterModel.body).GetComponent<ArbitraryCrystalComponent>()))
					{
						doppelgangerCount++;
					}
				}
				return doppelgangerCount;
			}
		}

		private void ThresholdCheck(orig_SendDamageDealt orig, DamageReport damageReport)
		{
			if (Object.op_Implicit((Object)(object)PhaseCounter.instance) && Object.op_Implicit((Object)(object)UmbralMissionController.instance))
			{
				HealthComponent component = ((Component)damageReport.victim).gameObject.GetComponent<HealthComponent>();
				CharacterBody body = component.body;
				if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)component) && ((Object)body).name == "BrotherBody(Clone)" && PhaseCounter.instance.phase == 2 && !UmbralMissionController.instance.p2ThresholdReached && component.health - damageReport.damageDealt <= component.fullHealth * 0.75f)
				{
					UmbralMissionController.instance.p2ThresholdReached = true;
					P2ThresholdEvent(((Component)body).gameObject);
					component.health = component.fullHealth * 0.75f;
					UmbralMissionController.instance.currentPhaseBody.AddBuff(Buffs.Immune);
					damageReport.damageDealt = 1f;
				}
				if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)component) && ((Object)body).name == "BrotherHurtBodyP3(Clone)" && PhaseCounter.instance.phase == 3 && !UmbralMissionController.instance.p3ThresholdReached && component.health - damageReport.damageDealt <= component.fullHealth * 0.75f)
				{
					UmbralMissionController.instance.p3ThresholdReached = true;
					((Component)UmbralMissionController.instance.p3CloneBody).GetComponent<HealthComponent>().health = 1f;
					P3ThresholdEvent(((Component)body).gameObject);
					component.health = component.fullHealth * 0.75f;
					UmbralMissionController.instance.currentPhaseBody.AddBuff(Buffs.Immune);
					damageReport.damageDealt = 1f;
				}
			}
			orig.Invoke(damageReport);
		}

		private void CharacterMaster_OnBodyStart(orig_OnBodyStart orig, CharacterMaster self, CharacterBody body)
		{
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, body);
			if (!Object.op_Implicit((Object)(object)PhaseCounter.instance))
			{
				return;
			}
			if (Object.op_Implicit((Object)(object)Run.instance) && Run.instance.nameToken == "Judgement" && body.isPlayerControlled)
			{
				body.baseMoveSpeed *= 1.35f;
			}
			if (((Object)body).name == "BrotherHurtBodyP3(Clone)")
			{
				if (ModConfig.purpleMithrix.Value)
				{
					self.inventory.GiveItemPermanent(UmbralMithrix.UmbralItem, 1);
				}
				if (Object.op_Implicit((Object)(object)UmbralMissionController.instance))
				{
					UmbralMissionController.instance.currentPhaseBody = body;
				}
				self.inventory.GiveItemPermanent(Items.AdaptiveArmor, 1);
			}
			if (((Object)body).name == "BrotherBody(Clone)" && ModConfig.purpleMithrix.Value)
			{
				self.inventory.GiveItemPermanent(UmbralMithrix.UmbralItem, 1);
			}
			if (((Object)body).name == "BrotherBody(Clone)")
			{
				if (PhaseCounter.instance.phase == 3 && Object.op_Implicit((Object)(object)UmbralMissionController.instance))
				{
					UmbralMissionController.instance.p3CloneBody = body;
				}
				if (PhaseCounter.instance.phase != 3)
				{
					if (Object.op_Implicit((Object)(object)UmbralMissionController.instance))
					{
						UmbralMissionController.instance.currentPhaseBody = body;
					}
					((Component)body).gameObject.AddComponent<CloneController>();
				}
			}
			if (((Object)body).name == "BrotherHurtBody(Clone)" && PhaseCounter.instance.phase == 4)
			{
				if (ModConfig.skipPhase4.Value)
				{
					body.healthComponent.Suicide((GameObject)null, (GameObject)null, default(DamageTypeCombo));
					return;
				}
				body.inventory.GiveItemPermanent(UmbralMithrix.UmbralItem, 1);
				body.AddBuff(Buffs.Immune);
				body.inventory.GiveItemPermanent(Items.HealthDecay, 40);
			}
		}

		private void CharacterMaster_OnBodyDeath(orig_OnBodyDeath orig, CharacterMaster self, CharacterBody body)
		{
			orig.Invoke(self, body);
			if (NetworkServer.active && body.isPlayerControlled && Object.op_Implicit((Object)(object)UmbralMissionController.instance) && UmbralMissionController.instance.practiceModeEnabled && !self.IsExtraLifePendingServer() && Object.op_Implicit((Object)(object)PhaseCounter.instance))
			{
				self.RespawnExtraLife();
			}
		}

		private void CombatDirector_OnEnable(orig_OnEnable orig, CombatDirector self)
		{
			if (Object.op_Implicit((Object)(object)PhaseCounter.instance) && (PhaseCounter.instance.phase == 2 || PhaseCounter.instance.phase == 3))
			{
				((Component)self).gameObject.SetActive(false);
			}
			else
			{
				orig.Invoke(self);
			}
		}

		private void P2ThresholdEvent(GameObject summoner)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)UmbralMissionController.instance))
			{
				UmbralMissionController.instance.timeCrystals.Clear();
				int num = 4;
				for (int i = 0; i < num; i++)
				{
					GameObject val = Object.Instantiate<GameObject>(UmbralMithrix.timeCrystal, UmbralMithrix.p23PizzaPoints[i], Quaternion.identity);
					UmbralMissionController.instance.timeCrystals.Add(val);
					val.GetComponent<TeamComponent>().teamIndex = (TeamIndex)2;
					NetworkServer.Spawn(val);
				}
			}
		}

		private void P3ThresholdEvent(GameObject summoner)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)UmbralMissionController.instance))
			{
				UmbralMissionController.instance.timeCrystals.Clear();
				int num = 4;
				for (int i = 0; i < num; i++)
				{
					GameObject val = Object.Instantiate<GameObject>(UmbralMithrix.timeCrystal, UmbralMithrix.p23PizzaPoints[i], Quaternion.identity);
					UmbralMissionController.instance.timeCrystals.Add(val);
					val.GetComponent<TeamComponent>().teamIndex = (TeamIndex)2;
					NetworkServer.Spawn(val);
				}
			}
		}

		private static void onMostRecentSceneDefChanged(SceneDef sceneDef)
		{
			if (sceneDef.cachedName == "moon2")
			{
				UmbralMithrix.ArenaSetup();
				UmbralMithrix.SpawnPracticeModeShrine();
			}
		}

		private void PurchaseInteraction_OnInteractionBegin(orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator)
		{
			if (((Object)self).name == "PracticeModeShrine" && Object.op_Implicit((Object)(object)UmbralMissionController.instance))
			{
				UmbralMissionController.instance.practiceModeEnabled = true;
			}
			orig.Invoke(self, activator);
		}

		private void FrozenState_OnEnter(orig_OnEnter orig, FrozenState self)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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)
			if (((Object)((EntityState)self).characterBody).name == "BrotherBody(Clone)" && Random.value > 0.5f)
			{
				Ray aimRay = ((BaseState)self).GetAimRay();
				for (int i = 0; i < 6; i++)
				{
					Util.PlaySound(FireLunarShards.fireSound, ((EntityState)self).gameObject);
					ProjectileManager.instance.FireProjectile(FireLunarShards.projectilePrefab, ((Ray)(ref aimRay)).origin, Quaternion.LookRotation(((Ray)(ref aimRay)).direction), ((EntityState)self).gameObject, (float)((double)((EntityState)self).characterBody.damage * 0.100000001490116 / 12.0), 0f, Util.CheckRoll(((EntityState)self).characterBody.crit, ((EntityState)self).characterBody.master), (DamageColorIndex)0, (GameObject)null, -1f, (DamageTypeCombo?)null);
				}
			}
			orig.Invoke(self);
		}

		private void AddTimedBuff_BuffDef_float(orig_AddTimedBuff_BuffDef_float orig, CharacterBody self, BuffDef buffDef, float duration)
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: 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_005c: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			if (((Object)self).name == "BrotherBody(Clone)" && (Object)(object)buffDef == (Object)(object)Buffs.Nullified && Random.value < 0.25f)
			{
				duration /= 2f;
				Ray val = (Object.op_Implicit((Object)(object)self.inputBank) ? new Ray(self.inputBank.aimOrigin, self.inputBank.aimDirection) : new Ray(self.transform.position, self.transform.forward));
				for (int i = 0; i < 6; i++)
				{
					Util.PlaySound(FireLunarShards.fireSound, ((Component)self).gameObject);
					ProjectileManager.instance.FireProjectile(FireLunarShards.projectilePrefab, ((Ray)(ref val)).origin, Quaternion.LookRotation(((Ray)(ref val)).direction), ((Component)self).gameObject, (float)((double)self.damage * 0.100000001490116 / 12.0), 0f, Util.CheckRoll(self.crit, self.master), (DamageColorIndex)0, (GameObject)null, -1f, (DamageTypeCombo?)null);
				}
			}
			orig.Invoke(self, buffDef, duration);
		}

		private void SetPosition(Vector3 newPosition, CharacterBody body)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)body.characterMotor))
			{
				((BaseCharacterController)body.characterMotor).Motor.SetPositionAndRotation(newPosition, Quaternion.identity, true);
			}
		}
	}
	public class MissionHooks
	{
		public MissionHooks()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Expected O, but got Unknown
			BrotherEncounterPhaseBaseState.OnEnter += new hook_OnEnter(BrotherEncounterPhaseBaseStateOnEnter);
			Phase1.OnEnter += new hook_OnEnter(Phase1OnEnter);
			Phase2.OnEnter += new hook_OnEnter(Phase2OnEnter);
			Phase3.OnEnter += new hook_OnEnter(Phase3OnEnter);
			Phase4.OnEnter += new hook_OnEnter(Phase4OnEnter);
			BossDeath.OnEnter += new hook_OnEnter(BossDeathOnEnter);
		}

		private void Phase1OnEnter(orig_OnEnter orig, Phase1 self)
		{
			//IL_0014: 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)
			UmbralMithrix.mithrix.GetComponent<EntityStateMachine>().initialStateType = new SerializableEntityStateType(typeof(ThroneSpawnState));
			orig.Invoke(self);
		}

		private void Phase2OnEnter(orig_OnEnter orig, Phase2 self)
		{
			//IL_0014: 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)
			UmbralMithrix.mithrix.GetComponent<EntityStateMachine>().initialStateType = new SerializableEntityStateType(typeof(SkySpawnState));
			((BrotherEncounterBaseState)self).KillAllMonsters();
			orig.Invoke(self);
		}

		private void Phase3OnEnter(orig_OnEnter orig, Phase3 self)
		{
			((BrotherEncounterBaseState)self).KillAllMonsters();
			orig.Invoke(self);
		}

		private void Phase4OnEnter(orig_OnEnter orig, Phase4 self)
		{
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_00c9: Expected O, but got Unknown
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Expected O, but got Unknown
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Expected O, but got Unknown
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.Find("EscapeSequenceController");
			if (Object.op_Implicit((Object)(object)val))
			{
				Transform val2 = val.transform.Find("EscapeSequenceObjects/Mega Glows");
				if (Object.op_Implicit((Object)(object)val2))
				{
					Object.Instantiate<GameObject>(((Component)val2).gameObject, new Vector3(-88.5f, 491.5f, -0.3f), Quaternion.Euler(270f, 0f, 0f)).transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
				}
			}
			GameObject obj = Object.Instantiate<GameObject>(UmbralMithrix.voidling, new Vector3(-88.5f, 520f, -0.3f), Quaternion.identity);
			obj.AddComponent<DeathZoneController>();
			obj.GetComponent<TeamComponent>().teamIndex = (TeamIndex)2;
			SkillLocator skillLocator = obj.GetComponent<CharacterBody>().skillLocator;
			skillLocator.primary = new GenericSkill();
			skillLocator.secondary = new GenericSkill();
			skillLocator.utility = new GenericSkill();
			skillLocator.special = new GenericSkill();
			NetworkServer.Spawn(obj);
			orig.Invoke(self);
		}

		private void BossDeathOnEnter(orig_OnEnter orig, BossDeath self)
		{
			//IL_001a: 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)
			orig.Invoke(self);
			GameObject.Find("InactiveVoidling(Clone)").GetComponent<HealthComponent>().Suicide((GameObject)null, (GameObject)null, default(DamageTypeCombo));
		}

		private void BrotherEncounterPhaseBaseStateOnEnter(orig_OnEnter orig, BrotherEncounterPhaseBaseState self)
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: 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)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			if (!NetworkServer.active || (Object)(object)self.phaseScriptedCombatEncounter == (Object)null || !Object.op_Implicit((Object)(object)PhaseCounter.instance))
			{
				return;
			}
			((BrotherEncounterBaseState)self).childLocator = ((EntityState)self).GetComponent<ChildLocator>();
			Transform val = ((BrotherEncounterBaseState)self).childLocator.FindChild("ArenaWalls");
			Material doppelMat = UmbralMithrix.doppelMat;
			if (Object.op_Implicit((Object)(object)val))
			{
				((Component)val).gameObject.SetActive(((BrotherEncounterBaseState)self).shouldEnableArenaWalls);
				if (ModConfig.purpleArena.Value)
				{
					Renderer[] componentsInChildren = ((Component)val).GetComponentsInChildren<Renderer>();
					for (int i = 0; i < componentsInChildren.Length; i++)
					{
						componentsInChildren[i].material = doppelMat;
					}
				}
			}
			if (PhaseCounter.instance.phase == 2)
			{
				Transform transform = new GameObject().transform;
				transform.position = new Vector3(-88.5f, 491.5f, -0.3f);
				SpawnInfo val2 = new SpawnInfo
				{
					explicitSpawnPosition = transform,
					spawnCard = UmbralMithrix.mithrixCard
				};
				self.phaseScriptedCombatEncounter.spawns = (SpawnInfo[])(object)new SpawnInfo[1] { val2 };
			}
			if (PhaseCounter.instance.phase == 3)
			{
				Transform transform2 = new GameObject().transform;
				transform2.position = new Vector3(-88.5f, 491.5f, -0.3f);
				SpawnInfo val3 = new SpawnInfo
				{
					explicitSpawnPosition = transform2,
					spawnCard = UmbralMithrix.mithrixHurtP3Card
				};
				self.phaseScriptedCombatEncounter.spawns = (SpawnInfo[])(object)new SpawnInfo[1] { val3 };
			}
			if (PhaseCounter.instance.phase == 4)
			{
				Transform transform3 = new GameObject().transform;
				transform3.position = new Vector3(-88.5f, 491.5f, -0.3f);
				SpawnInfo val4 = new SpawnInfo
				{
					explicitSpawnPosition = transform3,
					spawnCard = UmbralMithrix.mithrixHurtCard
				};
				self.phaseScriptedCombatEncounter.spawns = (SpawnInfo[])(object)new SpawnInfo[1] { val4 };
			}
		}
	}
	public class MithrixMiscHooks
	{
		public MithrixMiscHooks()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			SkyLeapDeathState.OnEnter += new hook_OnEnter(SkyLeapDeathState_OnEnter);
			SpellBaseState.InitItemStealer += new hook_InitItemStealer(PreventTempItemSteal);
			SpellChannelExitState.OnEnter += new hook_OnEnter(SpellChannelExitState_OnEnter);
			StaggerEnter.OnEnter += new hook_OnEnter(StaggerEnter_OnEnter);
			TrueDeathState.OnEnter += new hook_OnEnter(TrueDeathState_OnEnter);
		}

		private void PreventTempItemSteal(orig_InitItemStealer orig, SpellBaseState self)
		{
			//IL_0026: 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)
			if (NetworkServer.active && (Object)(object)self.itemStealController == (Object)null)
			{
				GameObject val = Object.Instantiate<GameObject>(LegacyResourcesAPI.Load<GameObject>("Prefabs/NetworkedObjects/ItemStealController"), ((EntityState)self).transform.position, Quaternion.identity);
				self.itemStealController = val.GetComponent<ItemStealController>();
				self.itemStealController.itemLendFilter = ItemStealController.BrotherItemFilter;
				self.itemStealController.itemLendTempFilter = ItemStealController.BrotherItemFilter;
				val.GetComponent<NetworkedBodyAttachment>().AttachToGameObjectAndSpawn(((EntityState)self).gameObject, (string)null);
				((EntityState)self).gameObject.GetComponent<ReturnStolenItemsOnGettingHit>().itemStealController = self.itemStealController;
				NetworkServer.Spawn(val);
			}
		}

		private void SkyLeapDeathState_OnEnter(orig_OnEnter orig, SkyLeapDeathState self)
		{
			if (((Object)((EntityState)self).characterBody).name == "BrotherGlassBody(Clone)")
			{
				((GenericCharacterDeath)self).DestroyModel();
				if (NetworkServer.active)
				{
					((GenericCharacterDeath)self).DestroyBodyAsapServer();
				}
			}
			else
			{
				orig.Invoke(self);
			}
		}

		private void SpellChannelExitState_OnEnter(orig_OnEnter orig, SpellChannelExitState self)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Invalid comparison between Unknown and I4
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)UmbralMissionController.instance))
			{
				UmbralMissionController.instance.finishedItemSteal = true;
			}
			((Component)((EntityState)self).characterBody).gameObject.GetComponent<P4Controller>().finishedItemSteal = true;
			bool flag = false;
			foreach (CharacterMaster readOnlyInstances in CharacterMaster.readOnlyInstancesList)
			{
				if ((int)readOnlyInstances.teamIndex == 1)
				{
					CharacterBody body = readOnlyInstances.GetBody();
					if (Object.op_Implicit((Object)(object)body) && !body.isPlayerControlled && Object.op_Implicit((Object)(object)body.healthComponent))
					{
						body.healthComponent.Suicide((GameObject)null, (GameObject)null, default(DamageTypeCombo));
					}
				}
			}
			if (flag)
			{
				Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
				{
					baseToken = "UMBRAL_KILLED_ALL_ALLIES_MESAAGE"
				});
			}
			orig.Invoke(self);
		}

		private void StaggerEnter_OnEnter(orig_OnEnter orig, StaggerEnter self)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Expected O, but got Unknown
			((StaggerBaseState)self).duration = 0f;
			if (Object.op_Implicit((Object)(object)PhaseCounter.instance) && PhaseCounter.instance.phase == 4)
			{
				((EntityState)self).outer.SetNextState((EntityState)new SpellChannelEnterState());
			}
			if (Object.op_Implicit((Object)(object)UmbralMissionController.instance) && Object.op_Implicit((Object)(object)PhaseCounter.instance) && PhaseCounter.instance.phase == 3 && Object.op_Implicit((Object)(object)UmbralMissionController.instance) && !UmbralMissionController.instance.spawnedClone)
			{
				UmbralMissionController.instance.spawnedClone = true;
				DirectorPlacementRule val = new DirectorPlacementRule();
				val.placementMode = (PlacementMode)3;
				val.minDistance = 3f;
				val.maxDistance = 20f;
				val.position = new Vector3(-88.5f, 491.5f, -0.3f);
				Xoroshiro128Plus rng = RoR2Application.rng;
				DirectorSpawnRequest val2 = new DirectorSpawnRequest(UmbralMithrix.mithrixCard, val, rng);
				val2.summonerBodyObject = ((EntityState)self).gameObject;
				val2.onSpawnedServer = (Action<SpawnResult>)Delegate.Combine(val2.onSpawnedServer, (Action<SpawnResult>)delegate(SpawnResult spawnResult)
				{
					//IL_0000: Unknown result type (might be due to invalid IL or missing references)
					CharacterMaster component = spawnResult.spawnedInstance.GetComponent<CharacterMaster>();
					component.GetBody().AddBuff(Buffs.Immune);
					component.GetBody().AddBuff(Buffs.Intangible);
					BaseAI[] components = ((Component)component).GetComponents<BaseAI>();
					foreach (BaseAI val3 in components)
					{
						if (Object.op_Implicit((Object)(object)val3))
						{
							val3.fullVision = true;
							val3.neverRetaliateFriendlies = true;
						}
					}
				});
				DirectorCore.instance.TrySpawnObject(val2);
			}
			orig.Invoke(self);
		}

		private void TrueDeathState_OnEnter(orig_OnEnter orig, TrueDeathState self)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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_0065: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			TrueDeathState.dissolveDuration = 3f;
			if (Object.op_Implicit((Object)(object)UmbralMissionController.instance))
			{
				if (!UmbralMissionController.instance.practiceModeEnabled)
				{
					Vector3 val = Vector3.up * 40f + Vector3.forward * 2f;
					PickupDropletController.CreatePickupDroplet(new UniquePickup(PickupCatalog.FindPickupIndex(UmbralMithrix.UmbralItem.itemIndex)), ((EntityState)self).characterBody.footPosition + Vector3.up * 1.5f, val, false);
				}
				UmbralMissionController.instance.practiceModeEnabled = false;
			}
			orig.Invoke(self);
		}
	}
	public class KarmicChanges
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Manipulator <0>__RecalculateStats;

			public static Manipulator <1>__BaseSlideState_OnEnter;

			public static Manipulator <2>__BaseSlideState_AttemptFireHomingBombAuthority;

			public static Manipulator <3>__BaseSlideState_AttemptFireCrystalsAuthority;

			public static Manipulator <4>__FistSlam_FireCrystalsAuthority;

			public static Manipulator <5>__BrotherSuperArmorController_OnDamageDealtServer;

			public static hook_OnEnter <6>__ThroneSpawnState_OnEnter;

			public static Manipulator <7>__SkySpawnState_AttemptSpawnSpireServer;

			public static Manipulator <8>__SkySpawnState_DeployGolemServer;

			public static Manipulator <9>__DisableP2Throne;

			public static Func<BaseSlideState, bool> <10>__applyForceImmunity;

			public static Func<CharacterBody, bool> <11>__applyCooldownReduction;

			public static Func<CharacterBody, bool> <12>__applyDamageBoost;

			public static Func<CharacterBody, bool> <13>__applySpeedBoost;

			public static Func<CharacterBody, bool> <14>__applyKarmaHealthBoost;
		}

		[SystemInitializer(new Type[] { })]
		public static void Init()
		{
			//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_0047: 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_0052: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Expected O, but got Unknown
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Expected O, but got Unknown
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Expected O, but got Unknown
			//IL_0107: 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)
			//IL_0112: Expected O, but got Unknown
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Expected O, but got Unknown
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Expected O, but got Unknown
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Expected O, but got Unknown
			AsyncOperationHandle<GameObject> val = AssetAsyncReferenceManager<GameObject>.LoadAsset(new AssetReferenceT<GameObject>(RoR2_Base_Brother.BrotherGravityWell_prefab), (AsyncReferenceHandleUnloadType)2);
			val.Completed += delegate(AsyncOperationHandle<GameObject> x)
			{
				CharacterBodyDisplacementProvider val12 = default(CharacterBodyDisplacementProvider);
				if (x.Result.TryGetComponent<CharacterBodyDisplacementProvider>(ref val12))
				{
					Object.Destroy((Object)(object)val12);
				}
				UmbralMithrix.Bundle.LoadAsset<GameObject>("Assets/Assets/Objects/PullController.prefab").transform.parent = x.Result.transform;
			};
			object obj = <>O.<0>__RecalculateStats;
			if (obj == null)
			{
				Manipulator val2 = RecalculateStats;
				<>O.<0>__RecalculateStats = val2;
				obj = (object)val2;
			}
			CharacterBody.RecalculateStats += (Manipulator)obj;
			object obj2 = <>O.<1>__BaseSlideState_OnEnter;
			if (obj2 == null)
			{
				Manipulator val3 = BaseSlideState_OnEnter;
				<>O.<1>__BaseSlideState_OnEnter = val3;
				obj2 = (object)val3;
			}
			BaseSlideState.OnEnter += (Manipulator)obj2;
			object obj3 = <>O.<2>__BaseSlideState_AttemptFireHomingBombAuthority;
			if (obj3 == null)
			{
				Manipulator val4 = BaseSlideState_AttemptFireHomingBombAuthority;
				<>O.<2>__BaseSlideState_AttemptFireHomingBombAuthority = val4;
				obj3 = (object)val4;
			}
			BaseSlideState.AttemptFireHomingBombAuthority += (Manipulator)obj3;
			object obj4 = <>O.<3>__BaseSlideState_AttemptFireCrystalsAuthority;
			if (obj4 == null)
			{
				Manipulator val5 = BaseSlideState_AttemptFireCrystalsAuthority;
				<>O.<3>__BaseSlideState_AttemptFireCrystalsAuthority = val5;
				obj4 = (object)val5;
			}
			BaseSlideState.AttemptFireCrystalsAuthority += (Manipulator)obj4;
			object obj5 = <>O.<4>__FistSlam_FireCrystalsAuthority;
			if (obj5 == null)
			{
				Manipulator val6 = FistSlam_FireCrystalsAuthority;
				<>O.<4>__FistSlam_FireCrystalsAuthority = val6;
				obj5 = (object)val6;
			}
			FistSlam.FireCrystalsAuthority += (Manipulator)obj5;
			object obj6 = <>O.<5>__BrotherSuperArmorController_OnDamageDealtServer;
			if (obj6 == null)
			{
				Manipulator val7 = BrotherSuperArmorController_OnDamageDealtServer;
				<>O.<5>__BrotherSuperArmorController_OnDamageDealtServer = val7;
				obj6 = (object)val7;
			}
			BrotherSuperArmorController.OnDamageDealtServer += (Manipulator)obj6;
			object obj7 = <>O.<6>__ThroneSpawnState_OnEnter;
			if (obj7 == null)
			{
				hook_OnEnter val8 = ThroneSpawnState_OnEnter;
				<>O.<6>__ThroneSpawnState_OnEnter = val8;
				obj7 = (object)val8;
			}
			ThroneSpawnState.OnEnter += (hook_OnEnter)obj7;
			object obj8 = <>O.<7>__SkySpawnState_AttemptSpawnSpireServer;
			if (obj8 == null)
			{
				Manipulator val9 = SkySpawnState_AttemptSpawnSpireServer;
				<>O.<7>__SkySpawnState_AttemptSpawnSpireServer = val9;
				obj8 = (object)val9;
			}
			SkySpawnState.AttemptSpawnSpireServer += (Manipulator)obj8;
			object obj9 = <>O.<8>__SkySpawnState_DeployGolemServer;
			if (obj9 == null)
			{
				Manipulator val10 = SkySpawnState_DeployGolemServer;
				<>O.<8>__SkySpawnState_DeployGolemServer = val10;
				obj9 = (object)val10;
			}
			LunarGolemLaserBarrage.DeployGolemServer += (Manipulator)obj9;
			object obj10 = <>O.<9>__DisableP2Throne;
			if (obj10 == null)
			{
				Manipulator val11 = DisableP2Throne;
				<>O.<9>__DisableP2Throne = val11;
				obj10 = (object)val11;
			}
			Phase2.PreEncounterBegin += (Manipulator)obj10;
		}

		private static void DisableP2Throne(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			ILLabel label = null;
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)Reflection.GetPropertyGetter(typeof(NetworkServer), "active")),
				(Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref label)
			}))
			{
				val.Emit(OpCodes.Br, (object)label);
			}
		}

		private static void SkySpawnState_DeployGolemServer(ILContext il)
		{
			SkipStateFuncContent(il, (EntityState self) => ModConfig.Karma6.Value);
		}

		private static void SkySpawnState_FireMortarAuthority(ILContext il)
		{
			SkipStateFuncContent(il, (EntityState self) => ModConfig.Karma6.Value);
		}

		private static void SkySpawnState_AttemptSpawnSpireServer(ILContext il)
		{
			SkipStateFuncContent(il, (EntityState self) => ModConfig.Karma5.Value);
		}

		private static void ThroneSpawnState_OnEnter(orig_OnEnter orig, ThroneSpawnState self)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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_0090: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Expected O, but got Unknown
			//IL_00da: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: 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_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: 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_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: 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_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Expected O, but got Unknown
			orig.Invoke(self);
			if (!ModConfig.Karma5.Value)
			{
				return;
			}
			CharacterMaster master = ((EntityState)self).characterBody.master;
			if (!Object.op_Implicit((Object)(object)master) || !NetworkServer.active || KarmaManager.instance.GetEffectiveKarma() < SkySpawnState.requiredKarmaForSpires)
			{
				return;
			}
			Vector3 val = Vector3.ProjectOnPlane(Random.onUnitSphere, Vector3.up);
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			DirectorSpawnRequest val2 = new DirectorSpawnRequest(SkySpawnState.spireSpawnCard, (DirectorPlacementRule)null, Run.instance.spawnRng)
			{
				summonerBodyObject = ((Component)((EntityState)self).characterBody).gameObject,
				teamIndexOverride = ((EntityState)self).teamComponent.teamIndex,
				ignoreTeamMemberLimit = true
			};
			val2.onSpawnedServer = delegate(SpawnResult result)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				GameObject spawnedInstance = result.spawnedInstance;
				if (Object.op_Implicit((Object)(object)spawnedInstance))
				{
					Deployable val4 = default(Deployable);
					if (spawnedInstance.TryGetComponent<Deployable>(ref val4))
					{
						master.AddDeployable(val4, (DeployableSlot)44);
					}
					MinionOwnership val5 = default(MinionOwnership);
					if (spawnedInstance.TryGetComponent<MinionOwnership>(ref val5))
					{
						val5.SetOwner(master);
					}
				}
			};
			for (int num = master.GetDeployableCount((DeployableSlot)44); num < 6; num++)
			{
				Vector3 val3 = Quaternion.AngleAxis(60f * (float)num, Vector3.up) * normalized;
				val2.placementRule = new DirectorPlacementRule
				{
					placementMode = (PlacementMode)0,
					maxDistance = SkySpawnState.maxSpawnOffset,
					position = ((EntityState)self).characterBody.footPosition + val3 * SkySpawnState.spireSpawnRadius
				};
				DirectorCore.instance.TrySpawnObject(val2);
			}
		}

		private static void SkipStateFuncContent(ILContext il, Func<EntityState, bool> skipReq)
		{
			//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_0007: 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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			val.Emit(OpCodes.Ldarg_0);
			val.EmitDelegate<Func<EntityState, bool>>(skipReq);
			val.Emit(OpCodes.Ret);
			ILLabel val2 = val.MarkLabel();
			int index = val.Index;
			val.Index = index - 1;
			val.Emit(OpCodes.Brtrue, (object)val2);
		}

		private static void FistSlam_FireCrystalsAuthority(ILContext il)
		{
			SkipStateFuncContent(il, (EntityState self) => ModConfig.Karma4.Value);
		}

		private static void BrotherSuperArmorController_OnDamageDealtServer(ILContext il)
		{
			SkipStateFuncContent(il, (EntityState self) => ModConfig.Karma1.Value);
		}

		private static void BaseSlideState_AttemptFireCrystalsAuthority(ILContext il)
		{
			SkipStateFuncContent(il, (EntityState self) => false);
		}

		private static void BaseSlideState_AttemptFireHomingBombAuthority(ILContext il)
		{
			SkipStateFuncContent(il, delegate(EntityState self)
			{
				if (!Object.op_Implicit((Object)(object)self.characterBody))
				{
					return false;
				}
				return (BrotherKarmaUtils.IsBrotherStrict(self.characterBody) && ModConfig.Karma6.Value) ? true : false;
			});
		}

		private static void BaseSlideState_OnEnter(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			ILLabel skipForceImmunityPos = null;
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(BaseSlideState), "requiredKarmaForPhysForceImmunity"),
				(Instruction x) => ILPatternMatchingExt.MatchBlt(x, ref skipForceImmunityPos)
			}))
			{
				val.Emit(OpCodes.Ldarg_0);
				val.EmitDelegate<Func<BaseSlideState, bool>>((Func<BaseSlideState, bool>)applyForceImmunity);
				val.Emit(OpCodes.Brfalse, (object)skipForceImmunityPos);
			}
			else
			{
				Log.Error("Failed to find patch location", "/home/tizian/Documents/GitHub/UmbralMithrix/UmbralMithrix/KarmicChanges.cs", "BaseSlideState_OnEnter", 198);
			}
			static bool applyForceImmunity(BaseSlideState self)
			{
				return false;
			}
		}

		private static void RecalculateStats(ILContext il)
		{
			int karmaLevelLoc = GetKarmaLevelLoc(il);
			CooldownReductionToggle(il, karmaLevelLoc);
			DamageBoostToggle(il, karmaLevelLoc);
			SpeedBoostToggle(il, karmaLevelLoc);
			HealthBoostToggle(il);
		}

		private static int GetKarmaLevelLoc(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			int karmaLevelLoc = 0;
			if (val.TryGotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, typeof(KarmaManager), "GetEffectiveKarma")
			}))
			{
				val.TryGotoNext(new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref karmaLevelLoc)
				});
			}
			if (karmaLevelLoc == 0)
			{
				Log.Error("Failed to find patch location", "/home/tizian/Documents/GitHub/UmbralMithrix/UmbralMithrix/KarmicChanges.cs", "GetKarmaLevelLoc", 230);
			}
			return karmaLevelLoc;
		}

		private static void CooldownReductionToggle(ILContext il, int karmaLevelLoc)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			ILLabel skipReductionPos = null;
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[3]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, karmaLevelLoc),
				(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 6),
				(Instruction x) => ILPatternMatchingExt.MatchBlt(x, ref skipReductionPos)
			}))
			{
				val.Emit(OpCodes.Ldarg_0);
				val.EmitDelegate<Func<CharacterBody, bool>>((Func<CharacterBody, bool>)applyCooldownReduction);
				val.Emit(OpCodes.Brfalse, (object)skipReductionPos);
			}
			else
			{
				Log.Error("Failed to find patch location", "/home/tizian/Documents/GitHub/UmbralMithrix/UmbralMithrix/KarmicChanges.cs", "CooldownReductionToggle", 251);
			}
			static bool applyCooldownReduction(CharacterBody self)
			{
				if (ModConfig.KarmaStatChanges.Value && BrotherKarmaUtils.IsBrotherStrict(self))
				{
					return true;
				}
				return false;
			}
		}

		private static void DamageBoostToggle(ILContext il, int karmaLevelLoc)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_00d7: 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)
			ILCursor val = new ILCursor(il);
			if (!val.TryGotoNext(new Func<Instruction, bool>[2]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdcR8(x, 0.01),
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, karmaLevelLoc)
			}) || !val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)Reflection.GetPropertySetter(typeof(CharacterBody), "damage"))
			}))
			{
				Log.Error("Failed to find patch location", "/home/tizian/Documents/GitHub/UmbralMithrix/UmbralMithrix/KarmicChanges.cs", "DamageBoostToggle", 276);
				return;
			}
			ILLabel val2 = val.MarkLabel();
			ILLabel val3 = default(ILLabel);
			if (val.TryGotoPrev((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref val3)
			}))
			{
				val.Emit(OpCodes.Ldarg_0);
				val.EmitDelegate<Func<CharacterBody, bool>>((Func<CharacterBody, bool>)applyDamageBoost);
				val.Emit(OpCodes.Brfalse, (object)val2);
			}
			else
			{
				Log.Error("Failed to find patch location", "/home/tizian/Documents/GitHub/UmbralMithrix/UmbralMithrix/KarmicChanges.cs", "DamageBoostToggle", 291);
			}
			static bool applyDamageBoost(CharacterBody self)
			{
				if (ModConfig.KarmaStatChanges.Value && BrotherKarmaUtils.IsBrotherStrict(self))
				{
					return true;
				}
				return false;
			}
		}

		private static void SpeedBoostToggle(ILContext il, int karmaLevelLoc)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			ILLabel skipBoostPos = null;
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[3]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, karmaLevelLoc),
				(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 2),
				(Instruction x) => ILPatternMatchingExt.MatchBlt(x, ref skipBoostPos)
			}))
			{
				val.Emit(OpCodes.Ldarg_0);
				val.EmitDelegate<Func<CharacterBody, bool>>((Func<CharacterBody, bool>)applySpeedBoost);
				val.Emit(OpCodes.Brfalse, (object)skipBoostPos);
			}
			else
			{
				Log.Error("Failed to find patch location", "/home/tizian/Documents/GitHub/UmbralMithrix/UmbralMithrix/KarmicChanges.cs", "SpeedBoostToggle", 320);
			}
			static bool applySpeedBoost(CharacterBody self)
			{
				if (ModConfig.KarmaStatChanges.Value && BrotherKarmaUtils.IsBrotherStrict(self))
				{
					return true;
				}
				return false;
			}
		}

		private static void HealthBoostToggle(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			ILLabel label = null;
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(KarmaManager), "maxKarma"),
				(Instruction x) => ILPatternMatchingExt.MatchBlt(x, ref label)
			}))
			{
				val.Emit(OpCodes.Ldarg_0);
				val.EmitDelegate<Func<CharacterBody, bool>>((Func<CharacterBody, bool>)applyKarmaHealthBoost);
				val.Emit(OpCodes.Brfalse, (object)label);
			}
			else
			{
				Log.Error("Failed to find patch location", "/home/tizian/Documents/GitHub/UmbralMithrix/UmbralMithrix/KarmicChanges.cs", "HealthBoostToggle", 348);
			}
			static bool applyKarmaHealthBoost(CharacterBody self)
			{
				if (ModConfig.Karma8.Value && PhaseCounter.instance.phase != 4 && BrotherKarmaUtils.IsBrotherStrict(self))
				{
					return true;
				}
				return false;
			}
		}
	}
	internal static class LanguageManager
	{
		public static void Register(string searchFolder, string langFolderName = "lang")
		{
			string langFolderPath = Path.Combine(searchFolder, langFolderName);
			if (Directory.Exists(langFolderPath))
			{
				Language.collectLanguageRootFolders += delegate(List<string> folders)
				{
					folders.Add(langFolderPath);
				};
			}
			else
			{
				Log.Error("Lang folder not found: " + langFolderPath, "/home/tizian/Documents/GitHub/UmbralMithrix/UmbralMithrix/LanguageManager.cs", "Register", 20);
			}
		}
	}
	internal static class Log
	{
		private static readonly StringBuilder _sharedStringBuilder;

		private static readonly int _cachedCallerPathPrefixLength;

		private static ManualLogSource _logSource;

		static Log()
		{
			_sharedStringBuilder = new StringBuilder(256);
			_cachedCallerPathPrefixLength = getCallerPathPrefixLength("/home/tizian/Documents/GitHub/UmbralMithrix/UmbralMithrix/Log.cs");
			static int getCallerPathPrefixLength([CallerFilePath] string callerPath = null)
			{
				int num = callerPath.LastIndexOf("UmbralMithrix\\");
				if (num >= 0)
				{
					return num + "UmbralMithrix\\".Length;
				}
				Debug.LogError((object)"[UmbralMithrix] Logger failed to determine caller path prefix length");
				return 0;
			}
		}

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

		private static StringBuilder AppendCallerPrefix(this StringBuilder stringBuilder, string callerPath, string callerMemberName, int callerLineNumber)
		{
			return stringBuilder.Append(callerPath, _cachedCallerPathPrefixLength, callerPath.Length - _cachedCallerPathPrefixLength).Append(':').Append(callerLineNumber)
				.Append(" (")
				.Append(callerMemberName)
				.Append("):");
		}

		private static StringBuilder buildCallerLogString(string callerPath, string callerMemberName, int callerLineNumber, object data)
		{
			return _sharedStringBuilder.Clear().AppendCallerPrefix(callerPath, callerMemberName, callerLineNumber).Append(' ')
				.Append(data);
		}

		[Conditional("DEBUG")]
		internal static void Debug(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogDebug((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data));
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		[Conditional("DEBUG")]
		internal static void Debug_NoCallerPrefix(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogError((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data));
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static void Error_NoCallerPrefix(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogFatal((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data));
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		internal static void Fatal_NoCallerPrefix(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1)
		{
			_logSource.LogInfo((object)buildCallerLogString(callerPath, callerMe