Decompiled source of DamageSourceForEquipment v1.0.2

plugins/DamageSourceForEquipment.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using IL.EntityStates.GoldGat;
using IL.EntityStates.QuestVolatileBattery;
using IL.RoR2;
using IL.RoR2.Orbs;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.RoR2;
using R2API;
using RoR2;
using RoR2.Projectile;
using RoR2BepInExPack.Utilities;
using UnityEngine;
using UnityEngine.AddressableAssets;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("DamageSourceForEquipment")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+9355b7645dd914fd8b8aff1e090a4bb6d7432331")]
[assembly: AssemblyProduct("DamageSourceForEquipment")]
[assembly: AssemblyTitle("DamageSourceForEquipment")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace DamageSourceForEquipment
{
	internal static class AssetEdits
	{
		internal static void LoadAndEditAssets()
		{
			EditMoltovAssets();
			EditPreonAsset();
			if (ConfigOptions.AspectPassiveDamageIsEquipment.Value)
			{
				EditMalachiteSpikeAsset();
				EditTwistedProjectile();
			}
		}

		private static void EditMoltovAssets()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/Molotov/MolotovSingleProjectile.prefab").WaitForCompletion().GetComponent<ProjectileDamage>()
				.damageType.damageSource = (DamageSource)64;
			Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC1/Molotov/MolotovProjectileDotZone.prefab").WaitForCompletion().GetComponent<ProjectileDamage>()
				.damageType.damageSource = (DamageSource)64;
		}

		private static void EditPreonAsset()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/BFG/BeamSphere.prefab").WaitForCompletion().GetComponent<ProjectileProximityBeamController>()
				.inheritDamageType = true;
		}

		private static void EditMalachiteSpikeAsset()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/ElitePoison/PoisonStakeProjectile.prefab").WaitForCompletion().GetComponent<ProjectileDamage>()
				.damageType.damageSource = (DamageSource)64;
		}

		private static void EditTwistedProjectile()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC2/Elites/EliteBead/BeadProjectileTrackingBomb.prefab").WaitForCompletion().GetComponent<ProjectileDamage>()
				.damageType.damageSource = (DamageSource)64;
		}
	}
	public static class ConfigOptions
	{
		public static ConfigEntry<bool> AspectPassiveDamageIsEquipment;

		internal static void BindConfigOptions(ConfigFile config)
		{
			AspectPassiveDamageIsEquipment = config.Bind<bool>("Aspects", "Aspect passive effect damage", false, "Should damage from aspect's passive effects (i.e blazing fire trail, malachite spikes) count as equipment damage? This is configurable since Wake of Vultures makes the aspect effects not tied to an equipment.");
		}
	}
	[HarmonyPatch]
	internal class HarmonyPatches
	{
		[HarmonyPatch(typeof(EquipmentSlot), "<FireSaw>g__FireSingleSaw|86_0")]
		[HarmonyILManipulator]
		internal static void AddSawmerangDamageSource(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchStloc(x, 1)
			}))
			{
				ILHooks.LogILError("<FireSaw>g__FireSingleSaw|86_0", il, val);
				return;
			}
			val.Emit(OpCodes.Ldloc_1);
			val.EmitDelegate<Func<FireProjectileInfo, FireProjectileInfo>>((Func<FireProjectileInfo, FireProjectileInfo>)delegate(FireProjectileInfo fireProjectileInfo)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				fireProjectileInfo.damageTypeOverride = Main.GenericEquipment;
				return fireProjectileInfo;
			});
			val.Emit(OpCodes.Stloc_1);
		}
	}
	internal static class ILHooks
	{
		private static class DisposableMissileLauncher
		{
			[CompilerGenerated]
			private static class <>O
			{
				public static Manipulator <0>__EquipmentSlot_FireMissile;

				public static Manipulator <1>__MissileUtils_FireMissle;
			}

			internal static void SetupHooks()
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Expected O, but got Unknown
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Expected O, but got Unknown
				object obj = <>O.<0>__EquipmentSlot_FireMissile;
				if (obj == null)
				{
					Manipulator val = EquipmentSlot_FireMissile;
					<>O.<0>__EquipmentSlot_FireMissile = val;
					obj = (object)val;
				}
				EquipmentSlot.FireMissile += (Manipulator)obj;
				object obj2 = <>O.<1>__MissileUtils_FireMissle;
				if (obj2 == null)
				{
					Manipulator val2 = MissileUtils_FireMissle;
					<>O.<1>__MissileUtils_FireMissle = val2;
					obj2 = (object)val2;
				}
				MissileUtils.FireMissile_Vector3_CharacterBody_ProcChainMask_GameObject_float_bool_GameObject_DamageColorIndex_Vector3_float_bool += (Manipulator)obj2;
			}

			private static void EquipmentSlot_FireMissile(ILContext il)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Expected O, but got Unknown
				ILCursor val = new ILCursor(il);
				if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[3]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdloca(x, 3),
					(Instruction x) => ILPatternMatchingExt.MatchInitobj<ProcChainMask>(x),
					(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 3)
				}))
				{
					LogILError(((MemberReference)il.Method).Name, il, val);
					return;
				}
				val.EmitDelegate<Func<ProcChainMask, ProcChainMask>>((Func<ProcChainMask, ProcChainMask>)delegate(ProcChainMask procChainMask)
				{
					//IL_0002: Unknown result type (might be due to invalid IL or missing references)
					//IL_000c: Unknown result type (might be due to invalid IL or missing references)
					ProcTypeAPI.AddModdedProc(ref procChainMask, Main.AddEquipmentDamageSource);
					return procChainMask;
				});
			}

			private static void MissileUtils_FireMissle(ILContext il)
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Expected O, but got Unknown
				//IL_008a: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
				int ldLocNumber = 0;
				ILCursor val = new ILCursor(il);
				if (!val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[3]
				{
					(Instruction x) => ILPatternMatchingExt.MatchCall<ProjectileManager>(x, "get_instance"),
					(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref ldLocNumber),
					(Instruction x) => ILPatternMatchingExt.MatchCallvirt<ProjectileManager>(x, "FireProjectile")
				}))
				{
					LogILError(((MemberReference)il.Method).Name, il, val);
					return;
				}
				val.Emit(OpCodes.Ldloc, ldLocNumber);
				val.EmitDelegate<Func<FireProjectileInfo, FireProjectileInfo>>((Func<FireProjectileInfo, FireProjectileInfo>)delegate(FireProjectileInfo fireProjectileInfo)
				{
					//IL_0000: Unknown result type (might be due to invalid IL or missing references)
					//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_001b: Unknown result type (might be due to invalid IL or missing references)
					//IL_0027: 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_0012: Unknown result type (might be due to invalid IL or missing references)
					if (!ProcTypeAPI.HasModdedProc(fireProjectileInfo.procChainMask, Main.AddEquipmentDamageSource))
					{
						return fireProjectileInfo;
					}
					ProcTypeAPI.RemoveModdedProc(ref fireProjectileInfo.procChainMask, Main.AddEquipmentDamageSource);
					fireProjectileInfo.damageTypeOverride = Main.GenericEquipment;
					return fireProjectileInfo;
				});
				val.Emit(OpCodes.Stloc, 4);
			}
		}

		private static class FuelArray
		{
			[CompilerGenerated]
			private static class <>O
			{
				public static Manipulator <0>__CountDown_Detonate;
			}

			internal static void SetupHook()
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Expected O, but got Unknown
				object obj = <>O.<0>__CountDown_Detonate;
				if (obj == null)
				{
					Manipulator val = CountDown_Detonate;
					<>O.<0>__CountDown_Detonate = val;
					obj = (object)val;
				}
				CountDown.Detonate += (Manipulator)obj;
			}

			private static void CountDown_Detonate(ILContext il)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Expected O, but got Unknown
				//IL_004c: 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.MatchStfld<BlastAttack>(x, "falloffModel")
				}))
				{
					LogILError(((MemberReference)il.Method).Name, il, val);
					return;
				}
				val.Emit(OpCodes.Dup);
				val.EmitDelegate<Action<BlastAttack>>((Action<BlastAttack>)delegate(BlastAttack blastAttack)
				{
					//IL_0008: Unknown result type (might be due to invalid IL or missing references)
					blastAttack.damageType.damageSource = (DamageSource)64;
				});
			}
		}

		private static class Molotov
		{
			[CompilerGenerated]
			private static class <>O
			{
				public static Manipulator <0>__EquipmentSlot_FireMolotov;
			}

			internal static void SetupHook()
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Expected O, but got Unknown
				object obj = <>O.<0>__EquipmentSlot_FireMolotov;
				if (obj == null)
				{
					Manipulator val = EquipmentSlot_FireMolotov;
					<>O.<0>__EquipmentSlot_FireMolotov = val;
					obj = (object)val;
				}
				EquipmentSlot.FireMolotov += (Manipulator)obj;
			}

			private static void EquipmentSlot_FireMolotov(ILContext il)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Expected O, but got Unknown
				ILCursor c = new ILCursor(il);
				VariableDefinition[] requiredMethodParameters = CreateArrayForParametersAsLocalILVariables(il);
				AssignValuesToLocalILParametersArray(il, c, requiredMethodParameters);
				ReplaceBadFireProjectileLine(il, c, requiredMethodParameters);
			}

			private static void AssignValuesToLocalILParametersArray(ILContext il, ILCursor c, VariableDefinition[] requiredMethodParameters)
			{
				//IL_0079: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_014b: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
				//IL_021d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0242: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ab: 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_02f5: Unknown result type (might be due to invalid IL or missing references)
				//IL_031a: Unknown result type (might be due to invalid IL or missing references)
				int num = 1;
				if (!c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2]
				{
					(Instruction x) => ILPatternMatchingExt.MatchCall<ProjectileManager>(x, "get_instance"),
					(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 1)
				}))
				{
					LogILError($"{((MemberReference)il.Method).Name} PART {num}", il, c);
					return;
				}
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				if (!c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchCall<Ray>(x, "get_origin")
				}))
				{
					LogILError($"{((MemberReference)il.Method).Name} PART {num}", il, c);
					return;
				}
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				if (!c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchCall<Quaternion>(x, "LookRotation")
				}))
				{
					LogILError($"{((MemberReference)il.Method).Name} PART {num}", il, c);
					return;
				}
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				if (!c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchCall<Component>(x, "get_gameObject")
				}))
				{
					LogILError($"{((MemberReference)il.Method).Name} PART {num}", il, c);
					return;
				}
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				if (!c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchCallvirt<CharacterBody>(x, "get_damage")
				}))
				{
					LogILError($"{((MemberReference)il.Method).Name} PART {num}", il, c);
					return;
				}
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				int index = c.Index;
				c.Index = index + 1;
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				if (!c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchCall(x, "RoR2.Util", "CheckRoll")
				}))
				{
					LogILError($"{((MemberReference)il.Method).Name} PART {num}", il, c);
					return;
				}
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				index = c.Index;
				c.Index = index + 1;
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				index = c.Index;
				c.Index = index + 1;
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				index = c.Index;
				c.Index = index + 1;
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
			}
		}

		private static class GildedAspect
		{
			[CompilerGenerated]
			private static class <>O
			{
				public static Manipulator <0>__AffixAurelioniteBehavior_FireAurelioniteAttack;
			}

			internal static void SetupHook()
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Expected O, but got Unknown
				object obj = <>O.<0>__AffixAurelioniteBehavior_FireAurelioniteAttack;
				if (obj == null)
				{
					Manipulator val = AffixAurelioniteBehavior_FireAurelioniteAttack;
					<>O.<0>__AffixAurelioniteBehavior_FireAurelioniteAttack = val;
					obj = (object)val;
				}
				AffixAurelioniteBehavior.FireAurelioniteAttack += (Manipulator)obj;
			}

			private static void AffixAurelioniteBehavior_FireAurelioniteAttack(ILContext il)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Expected O, but got Unknown
				ILCursor c = new ILCursor(il);
				ReplaceBadFireProjectileLine(il, c);
				ReplaceBadFireProjectileLine(il, c);
			}

			private static void ReplaceBadFireProjectileLine(ILContext il, ILCursor c)
			{
				//IL_0022: 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_0071: 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_009a: Unknown result type (might be due to invalid IL or missing references)
				ILLabel val = il.DefineLabel();
				VariableDefinition[] array = CreateArrayForParametersAsLocalILVariables(il);
				AssignValuesToLocalILParametersArray(il, c, array);
				VariableDefinition[] array2 = array;
				foreach (VariableDefinition val2 in array2)
				{
					c.Emit(OpCodes.Ldloc, val2);
				}
				c.EmitDelegate<Func<DamageTypeCombo?>>((Func<DamageTypeCombo?>)(() => Main.GenericEquipment));
				c.Emit<ProjectileManager>(OpCodes.Callvirt, "FireProjectile");
				c.Emit(OpCodes.Br, (object)val);
				c.Emit<ProjectileManager>(OpCodes.Call, "get_instance");
				array2 = array;
				foreach (VariableDefinition val3 in array2)
				{
					c.Emit(OpCodes.Ldloc, val3);
				}
				int i = c.Index;
				c.Index = i + 1;
				c.MarkLabel(val);
			}

			private static void AssignValuesToLocalILParametersArray(ILContext il, ILCursor c, VariableDefinition[] requiredMethodParameters)
			{
				//IL_008e: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0163: Unknown result type (might be due to invalid IL or missing references)
				//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
				//IL_025a: Unknown result type (might be due to invalid IL or missing references)
				//IL_027f: Unknown result type (might be due to invalid IL or missing references)
				//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
				int num = 1;
				FieldReference val = default(FieldReference);
				if (!c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2]
				{
					(Instruction x) => ILPatternMatchingExt.MatchCall<ProjectileManager>(x, "get_instance"),
					(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, ref val)
				}))
				{
					LogILError($"{((MemberReference)il.Method).Name} PART {num}", il, c);
					return;
				}
				if (ModSupport.ItemStatisticsMod.ModIsRunning)
				{
					c.Index += 4;
				}
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				int index = c.Index;
				c.Index = index + 1;
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				index = c.Index;
				c.Index = index + 1;
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				if (!c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 2),
					(Instruction x) => ILPatternMatchingExt.MatchCallvirt<Component>(x, "get_gameObject")
				}))
				{
					LogILError($"{((MemberReference)il.Method).Name} PART {num}", il, c);
					return;
				}
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				if (!c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchMul(x)
				}))
				{
					LogILError($"{((MemberReference)il.Method).Name} PART {num}", il, c);
					return;
				}
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				index = c.Index;
				c.Index = index + 1;
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				if (!c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchCall(x, "RoR2.Util", "CheckRoll")
				}))
				{
					LogILError($"{((MemberReference)il.Method).Name} PART {num}", il, c);
					return;
				}
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				index = c.Index;
				c.Index = index + 1;
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				index = c.Index;
				c.Index = index + 1;
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				index = c.Index;
				c.Index = index + 1;
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
			}
		}

		private static class PreonAccumulator
		{
			[CompilerGenerated]
			private static class <>O
			{
				public static Manipulator <0>__EquipmentSlot_MyFixedUpdate;
			}

			internal static void SetupHook()
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Expected O, but got Unknown
				object obj = <>O.<0>__EquipmentSlot_MyFixedUpdate;
				if (obj == null)
				{
					Manipulator val = EquipmentSlot_MyFixedUpdate;
					<>O.<0>__EquipmentSlot_MyFixedUpdate = val;
					obj = (object)val;
				}
				EquipmentSlot.MyFixedUpdate += (Manipulator)obj;
			}

			private static void EquipmentSlot_MyFixedUpdate(ILContext il)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Expected O, but got Unknown
				ILCursor c = new ILCursor(il);
				il.DefineLabel();
				VariableDefinition[] requiredMethodParameters = CreateArrayForParametersAsLocalILVariables(il);
				AssignValuesToLocalILParametersArray(il, c, requiredMethodParameters);
				ReplaceBadFireProjectileLine(il, c, requiredMethodParameters);
			}

			private static void AssignValuesToLocalILParametersArray(ILContext il, ILCursor c, VariableDefinition[] requiredMethodParameters)
			{
				//IL_0079: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_014b: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
				//IL_021d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0242: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ab: 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_02f5: Unknown result type (might be due to invalid IL or missing references)
				//IL_031a: Unknown result type (might be due to invalid IL or missing references)
				int num = 1;
				MethodReference val = default(MethodReference);
				if (!c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdstr(x, "Prefabs/Projectiles/BeamSphere"),
					(Instruction x) => ILPatternMatchingExt.MatchCall(x, ref val)
				}))
				{
					LogILError($"{((MemberReference)il.Method).Name} PART {num}", il, c);
					return;
				}
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				if (!c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchCall<Ray>(x, "get_origin")
				}))
				{
					LogILError($"{((MemberReference)il.Method).Name} PART {num}", il, c);
					return;
				}
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				if (!c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchCall(x, "RoR2.Util", "QuaternionSafeLookRotation")
				}))
				{
					LogILError($"{((MemberReference)il.Method).Name} PART {num}", il, c);
					return;
				}
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				if (!c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchCall<Component>(x, "get_gameObject")
				}))
				{
					LogILError($"{((MemberReference)il.Method).Name} PART {num}", il, c);
					return;
				}
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				if (!c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchMul(x)
				}))
				{
					LogILError($"{((MemberReference)il.Method).Name} PART {num}", il, c);
					return;
				}
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				int index = c.Index;
				c.Index = index + 1;
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				if (!c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchCall(x, "RoR2.Util", "CheckRoll")
				}))
				{
					LogILError($"{((MemberReference)il.Method).Name} PART {num}", il, c);
					return;
				}
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				index = c.Index;
				c.Index = index + 1;
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				index = c.Index;
				c.Index = index + 1;
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				index = c.Index;
				c.Index = index + 1;
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
			}
		}

		private static class RemoteCaffeinator
		{
			[CompilerGenerated]
			private static class <>O
			{
				public static Manipulator <0>__EquipmentSlot_FireVendingMachine;
			}

			internal static void SetupHook()
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Expected O, but got Unknown
				object obj = <>O.<0>__EquipmentSlot_FireVendingMachine;
				if (obj == null)
				{
					Manipulator val = EquipmentSlot_FireVendingMachine;
					<>O.<0>__EquipmentSlot_FireVendingMachine = val;
					obj = (object)val;
				}
				EquipmentSlot.FireVendingMachine += (Manipulator)obj;
			}

			private static void EquipmentSlot_FireVendingMachine(ILContext il)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Expected O, but got Unknown
				ILCursor c = new ILCursor(il);
				il.DefineLabel();
				VariableDefinition[] requiredMethodParameters = CreateArrayForParametersAsLocalILVariables(il);
				AssignValuesToLocalILParametersArray(il, c, requiredMethodParameters);
				ReplaceBadFireProjectileLine(il, c, requiredMethodParameters);
			}

			private static void AssignValuesToLocalILParametersArray(ILContext il, ILCursor c, VariableDefinition[] requiredMethodParameters)
			{
				//IL_0057: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_0129: Unknown result type (might be due to invalid IL or missing references)
				//IL_0192: 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_0220: 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_02ae: Unknown result type (might be due to invalid IL or missing references)
				//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
				int num = 1;
				if (!c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 4)
				}))
				{
					LogILError($"{((MemberReference)il.Method).Name} PART {num}", il, c);
					return;
				}
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				if (!c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchCall<RaycastHit>(x, "get_point")
				}))
				{
					LogILError($"{((MemberReference)il.Method).Name} PART {num}", il, c);
					return;
				}
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				if (!c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchCall<Quaternion>(x, "get_identity")
				}))
				{
					LogILError($"{((MemberReference)il.Method).Name} PART {num}", il, c);
					return;
				}
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				if (!c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchCall<Component>(x, "get_gameObject")
				}))
				{
					LogILError($"{((MemberReference)il.Method).Name} PART {num}", il, c);
					return;
				}
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				if (!c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchCallvirt<CharacterBody>(x, "get_damage")
				}))
				{
					LogILError($"{((MemberReference)il.Method).Name} PART {num}", il, c);
					return;
				}
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				int index = c.Index;
				c.Index = index + 1;
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				if (!c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchCall(x, "RoR2.Util", "CheckRoll")
				}))
				{
					LogILError($"{((MemberReference)il.Method).Name} PART {num}", il, c);
					return;
				}
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				index = c.Index;
				c.Index = index + 1;
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				index = c.Index;
				c.Index = index + 1;
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				index = c.Index;
				c.Index = index + 1;
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
			}
		}

		private static class RoyalCapacitor
		{
			[CompilerGenerated]
			private static class <>O
			{
				public static Manipulator <0>__LightningStrikeOrb_OnArrival;
			}

			internal static void SetupHook()
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Expected O, but got Unknown
				object obj = <>O.<0>__LightningStrikeOrb_OnArrival;
				if (obj == null)
				{
					Manipulator val = LightningStrikeOrb_OnArrival;
					<>O.<0>__LightningStrikeOrb_OnArrival = val;
					obj = (object)val;
				}
				LightningStrikeOrb.OnArrival += (Manipulator)obj;
			}

			private static void LightningStrikeOrb_OnArrival(ILContext il)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Expected O, but got Unknown
				//IL_004c: 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.MatchStfld<BlastAttack>(x, "damageType")
				}))
				{
					LogILError(((MemberReference)il.Method).Name, il, val);
					return;
				}
				val.Emit(OpCodes.Dup);
				val.EmitDelegate<Action<BlastAttack>>((Action<BlastAttack>)delegate(BlastAttack blastAttack)
				{
					//IL_0008: Unknown result type (might be due to invalid IL or missing references)
					blastAttack.damageType.damageSource = (DamageSource)64;
				});
			}
		}

		private static class Crowdfunder
		{
			[CompilerGenerated]
			private static class <>O
			{
				public static Manipulator <0>__GoldGatFire_FireBullet;
			}

			internal static void SetupHook()
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Expected O, but got Unknown
				object obj = <>O.<0>__GoldGatFire_FireBullet;
				if (obj == null)
				{
					Manipulator val = GoldGatFire_FireBullet;
					<>O.<0>__GoldGatFire_FireBullet = val;
					obj = (object)val;
				}
				GoldGatFire.FireBullet += (Manipulator)obj;
			}

			private static void GoldGatFire_FireBullet(ILContext il)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Expected O, but got Unknown
				//IL_004c: Unknown result type (might be due to invalid IL or missing references)
				ILCursor val = new ILCursor(il);
				if (!val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchCallvirt<BulletAttack>(x, "Fire")
				}))
				{
					LogILError(((MemberReference)il.Method).Name, il, val);
					return;
				}
				val.Emit(OpCodes.Dup);
				val.EmitDelegate<Action<BulletAttack>>((Action<BulletAttack>)delegate(BulletAttack bulletAttack)
				{
					//IL_0008: Unknown result type (might be due to invalid IL or missing references)
					bulletAttack.damageType.damageSource = (DamageSource)64;
				});
			}
		}

		private static class VolcanicEgg
		{
			[CompilerGenerated]
			private static class <>O
			{
				public static Manipulator <0>__FireballVehicle_OnPassengerEnter;

				public static Manipulator <1>__FireballVehicle_DetonateServer;
			}

			internal static void SetupHooks()
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Expected O, but got Unknown
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Expected O, but got Unknown
				object obj = <>O.<0>__FireballVehicle_OnPassengerEnter;
				if (obj == null)
				{
					Manipulator val = FireballVehicle_OnPassengerEnter;
					<>O.<0>__FireballVehicle_OnPassengerEnter = val;
					obj = (object)val;
				}
				FireballVehicle.OnPassengerEnter += (Manipulator)obj;
				object obj2 = <>O.<1>__FireballVehicle_DetonateServer;
				if (obj2 == null)
				{
					Manipulator val2 = FireballVehicle_DetonateServer;
					<>O.<1>__FireballVehicle_DetonateServer = val2;
					obj2 = (object)val2;
				}
				FireballVehicle.DetonateServer += (Manipulator)obj2;
			}

			private static void FireballVehicle_OnPassengerEnter(ILContext il)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Expected O, but got Unknown
				//IL_004c: Unknown result type (might be due to invalid IL or missing references)
				ILCursor val = new ILCursor(il);
				if (!val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchStfld<FireballVehicle>(x, "overlapAttack")
				}))
				{
					LogILError(((MemberReference)il.Method).Name, il, val);
					return;
				}
				val.Emit(OpCodes.Dup);
				val.EmitDelegate<Action<OverlapAttack>>((Action<OverlapAttack>)delegate(OverlapAttack overlapAttack)
				{
					//IL_0008: Unknown result type (might be due to invalid IL or missing references)
					overlapAttack.damageType.damageSource = (DamageSource)64;
				});
			}

			private static void FireballVehicle_DetonateServer(ILContext il)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Expected O, but got Unknown
				//IL_004c: Unknown result type (might be due to invalid IL or missing references)
				ILCursor val = new ILCursor(il);
				if (!val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchCallvirt<BlastAttack>(x, "Fire")
				}))
				{
					LogILError(((MemberReference)il.Method).Name, il, val);
					return;
				}
				val.Emit(OpCodes.Dup);
				val.EmitDelegate<Action<BlastAttack>>((Action<BlastAttack>)delegate(BlastAttack blastAttack)
				{
					//IL_0008: Unknown result type (might be due to invalid IL or missing references)
					blastAttack.damageType.damageSource = (DamageSource)64;
				});
			}
		}

		internal static void SetupHooks()
		{
			DisposableMissileLauncher.SetupHooks();
			FuelArray.SetupHook();
			Molotov.SetupHook();
			PreonAccumulator.SetupHook();
			RemoteCaffeinator.SetupHook();
			RoyalCapacitor.SetupHook();
			Crowdfunder.SetupHook();
			VolcanicEgg.SetupHooks();
			GildedAspect.SetupHook();
		}

		internal static VariableDefinition[] CreateArrayForParametersAsLocalILVariables(ILContext il)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Expected O, but got Unknown
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Expected O, but got Unknown
			VariableDefinition val = new VariableDefinition(il.Import(typeof(GameObject)));
			VariableDefinition val2 = new VariableDefinition(il.Import(typeof(Vector3)));
			VariableDefinition val3 = new VariableDefinition(il.Import(typeof(Quaternion)));
			VariableDefinition val4 = new VariableDefinition(il.Import(typeof(GameObject)));
			VariableDefinition val5 = new VariableDefinition(il.Import(typeof(float)));
			VariableDefinition val6 = new VariableDefinition(il.Import(typeof(float)));
			VariableDefinition val7 = new VariableDefinition(il.Import(typeof(bool)));
			VariableDefinition val8 = new VariableDefinition(il.Import(typeof(DamageColorIndex)));
			VariableDefinition val9 = new VariableDefinition(il.Import(typeof(GameObject)));
			VariableDefinition val10 = new VariableDefinition(il.Import(typeof(float)));
			VariableDefinition[] array = (VariableDefinition[])(object)new VariableDefinition[10] { val, val2, val3, val4, val5, val6, val7, val8, val9, val10 };
			VariableDefinition[] array2 = array;
			foreach (VariableDefinition val11 in array2)
			{
				il.Method.Body.Variables.Add(val11);
			}
			return array;
		}

		internal static void ReplaceBadFireProjectileLine(ILContext il, ILCursor c, VariableDefinition[] requiredMethodParameters)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			ILLabel val = il.DefineLabel();
			VariableDefinition[] array = requiredMethodParameters;
			foreach (VariableDefinition val2 in array)
			{
				c.Emit(OpCodes.Ldloc, val2);
			}
			c.EmitDelegate<Func<DamageTypeCombo?>>((Func<DamageTypeCombo?>)(() => Main.GenericEquipment));
			c.Emit<ProjectileManager>(OpCodes.Callvirt, "FireProjectile");
			c.Emit(OpCodes.Br, (object)val);
			c.Emit<ProjectileManager>(OpCodes.Call, "get_instance");
			array = requiredMethodParameters;
			foreach (VariableDefinition val3 in array)
			{
				c.Emit(OpCodes.Ldloc, val3);
			}
			int i = c.Index;
			c.Index = i + 1;
			c.MarkLabel(val);
		}

		internal static void LogILError(string methodName, ILContext il, ILCursor c)
		{
			Log.Error("COULD NOT IL HOOK " + methodName);
			Log.Warning($"cursor is {c}");
			Log.Warning($"il is {il}");
		}
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;

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

		internal static void Debug(object data)
		{
		}

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

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

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

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

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	public static class Main
	{
		public static ModdedProcType AddEquipmentDamageSource;

		public static readonly DamageTypeCombo GenericEquipment = new DamageTypeCombo
		{
			damageType = (DamageType)0,
			damageTypeExtended = (DamageTypeExtended)0,
			damageSource = (DamageSource)64
		};

		internal static readonly Type[] GoodFireProjectileTypes = new Type[11]
		{
			typeof(GameObject),
			typeof(Vector3),
			typeof(Quaternion),
			typeof(GameObject),
			typeof(float),
			typeof(float),
			typeof(bool),
			typeof(DamageColorIndex),
			typeof(GameObject),
			typeof(float),
			typeof(DamageTypeCombo?)
		};
	}
	internal static class ModSupport
	{
		internal static class ItemStatisticsMod
		{
			internal const string GUID = "dolso.ItemStatistics";

			private static bool? _modexists;

			internal static bool ModIsRunning
			{
				get
				{
					bool valueOrDefault = _modexists.GetValueOrDefault();
					if (!_modexists.HasValue)
					{
						valueOrDefault = Chainloader.PluginInfos.ContainsKey("dolso.ItemStatistics");
						_modexists = valueOrDefault;
					}
					return _modexists.Value;
				}
			}
		}
	}
	public class PassiveAspectEffects
	{
		public class BlazingDamageTrail
		{
			public class DamageTrailDamageSource
			{
				public DamageSource DamageSource;
			}

			[CompilerGenerated]
			private static class <>O
			{
				public static hook_Awake <0>__DamageTrail_Awake;

				public static hook_OnDisable <1>__DamageTrail_OnDisable;

				public static Manipulator <2>__CharacterBody_UpdateFireTrail;

				public static Manipulator <3>__DamageTrail_DoDamage;
			}

			public static readonly FixedConditionalWeakTable<DamageTrail, DamageTrailDamageSource> DamageTrailDamageSourceTable = new FixedConditionalWeakTable<DamageTrail, DamageTrailDamageSource>();

			internal static void SetupHooks()
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Expected O, but got Unknown
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Expected O, but got Unknown
				//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_005b: Expected O, but got Unknown
				//IL_0070: Unknown result type (might be due to invalid IL or missing references)
				//IL_0075: Unknown result type (might be due to invalid IL or missing references)
				//IL_007b: Expected O, but got Unknown
				object obj = <>O.<0>__DamageTrail_Awake;
				if (obj == null)
				{
					hook_Awake val = DamageTrail_Awake;
					<>O.<0>__DamageTrail_Awake = val;
					obj = (object)val;
				}
				DamageTrail.Awake += (hook_Awake)obj;
				object obj2 = <>O.<1>__DamageTrail_OnDisable;
				if (obj2 == null)
				{
					hook_OnDisable val2 = DamageTrail_OnDisable;
					<>O.<1>__DamageTrail_OnDisable = val2;
					obj2 = (object)val2;
				}
				DamageTrail.OnDisable += (hook_OnDisable)obj2;
				object obj3 = <>O.<2>__CharacterBody_UpdateFireTrail;
				if (obj3 == null)
				{
					Manipulator val3 = CharacterBody_UpdateFireTrail;
					<>O.<2>__CharacterBody_UpdateFireTrail = val3;
					obj3 = (object)val3;
				}
				CharacterBody.UpdateFireTrail += (Manipulator)obj3;
				object obj4 = <>O.<3>__DamageTrail_DoDamage;
				if (obj4 == null)
				{
					Manipulator val4 = DamageTrail_DoDamage;
					<>O.<3>__DamageTrail_DoDamage = val4;
					obj4 = (object)val4;
				}
				DamageTrail.DoDamage += (Manipulator)obj4;
			}

			private static void DamageTrail_Awake(orig_Awake orig, DamageTrail self)
			{
				orig.Invoke(self);
				DamageTrailDamageSourceTable.GetOrCreateValue(self);
			}

			private static void DamageTrail_OnDisable(orig_OnDisable orig, DamageTrail self)
			{
				orig.Invoke(self);
				DamageTrailDamageSource damageTrailDamageSource = default(DamageTrailDamageSource);
				if (DamageTrailDamageSourceTable.TryGetValue(self, ref damageTrailDamageSource))
				{
					DamageTrailDamageSourceTable.Remove(self);
				}
			}

			private static void DamageTrail_DoDamage(ILContext il)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Expected O, but got Unknown
				//IL_004c: 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)
				ILCursor val = new ILCursor(il);
				if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchStfld<DamageInfo>(x, "damageType")
				}))
				{
					ILHooks.LogILError(((MemberReference)il.Method).Name, il, val);
					return;
				}
				val.Emit(OpCodes.Ldarg_0);
				val.Emit(OpCodes.Ldloc_3);
				val.EmitDelegate<Action<DamageTrail, DamageInfo>>((Action<DamageTrail, DamageInfo>)delegate(DamageTrail damageTrail, DamageInfo damageInfo)
				{
					//IL_0016: 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)
					DamageTrailDamageSource damageTrailDamageSource = default(DamageTrailDamageSource);
					if (DamageTrailDamageSourceTable.TryGetValue(damageTrail, ref damageTrailDamageSource))
					{
						damageInfo.damageType.damageSource = damageTrailDamageSource.DamageSource;
					}
				});
			}

			private static void CharacterBody_UpdateFireTrail(ILContext il)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Expected O, but got Unknown
				//IL_004c: 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.MatchStfld<CharacterBody>(x, "fireTrail")
				}))
				{
					ILHooks.LogILError(((MemberReference)il.Method).Name, il, val);
					return;
				}
				val.Emit(OpCodes.Ldarg_0);
				val.EmitDelegate<Action<CharacterBody>>((Action<CharacterBody>)delegate(CharacterBody characterBody)
				{
					//IL_0017: Unknown result type (might be due to invalid IL or missing references)
					DamageTrailDamageSource damageTrailDamageSource = default(DamageTrailDamageSource);
					if (DamageTrailDamageSourceTable.TryGetValue(characterBody.fireTrail, ref damageTrailDamageSource))
					{
						damageTrailDamageSource.DamageSource = (DamageSource)64;
					}
				});
			}
		}

		internal static class MalachiteSpikes
		{
			[CompilerGenerated]
			private static class <>O
			{
				public static Manipulator <0>__CharacterBody_UpdateAffixPoison;
			}

			internal static void SetupHooks()
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Expected O, but got Unknown
				object obj = <>O.<0>__CharacterBody_UpdateAffixPoison;
				if (obj == null)
				{
					Manipulator val = CharacterBody_UpdateAffixPoison;
					<>O.<0>__CharacterBody_UpdateAffixPoison = val;
					obj = (object)val;
				}
				CharacterBody.UpdateAffixPoison += (Manipulator)obj;
			}

			private static void CharacterBody_UpdateAffixPoison(ILContext il)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Expected O, but got Unknown
				ILCursor c = new ILCursor(il);
				il.DefineLabel();
				VariableDefinition[] requiredMethodParameters = ILHooks.CreateArrayForParametersAsLocalILVariables(il);
				AssignValuesToLocalILParametersArray(il, c, requiredMethodParameters);
				ILHooks.ReplaceBadFireProjectileLine(il, c, requiredMethodParameters);
			}

			private static void AssignValuesToLocalILParametersArray(ILContext il, ILCursor c, VariableDefinition[] requiredMethodParameters)
			{
				//IL_0057: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_0129: Unknown result type (might be due to invalid IL or missing references)
				//IL_0192: 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_0220: 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_02ae: Unknown result type (might be due to invalid IL or missing references)
				//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
				int num = 1;
				if (!c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchCall(x, "RoR2.LegacyResourcesAPI", "Load")
				}))
				{
					ILHooks.LogILError($"{((MemberReference)il.Method).Name} PART {num}", il, c);
					return;
				}
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				if (!c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchCall<CharacterBody>(x, "get_corePosition")
				}))
				{
					ILHooks.LogILError($"{((MemberReference)il.Method).Name} PART {num}", il, c);
					return;
				}
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				if (!c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchCall(x, "RoR2.Util", "QuaternionSafeLookRotation")
				}))
				{
					ILHooks.LogILError($"{((MemberReference)il.Method).Name} PART {num}", il, c);
					return;
				}
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				if (!c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchCall<Component>(x, "get_gameObject")
				}))
				{
					ILHooks.LogILError($"{((MemberReference)il.Method).Name} PART {num}", il, c);
					return;
				}
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				if (!c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchMul(x)
				}))
				{
					ILHooks.LogILError($"{((MemberReference)il.Method).Name} PART {num}", il, c);
					return;
				}
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				int index = c.Index;
				c.Index = index + 1;
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				if (!c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchCall(x, "RoR2.Util", "CheckRoll")
				}))
				{
					ILHooks.LogILError($"{((MemberReference)il.Method).Name} PART {num}", il, c);
					return;
				}
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				index = c.Index;
				c.Index = index + 1;
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				index = c.Index;
				c.Index = index + 1;
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
				index = c.Index;
				c.Index = index + 1;
				c.Emit(OpCodes.Stloc, requiredMethodParameters[num - 1]);
				num++;
			}
		}

		internal static class GlacialDeathBubble
		{
			[CompilerGenerated]
			private static class <>O
			{
				public static Manipulator <0>__GlobalEventManager_OnCharacterDeath;
			}

			internal static void SetupHooks()
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Expected O, but got Unknown
				object obj = <>O.<0>__GlobalEventManager_OnCharacterDeath;
				if (obj == null)
				{
					Manipulator val = GlobalEventManager_OnCharacterDeath;
					<>O.<0>__GlobalEventManager_OnCharacterDeath = val;
					obj = (object)val;
				}
				GlobalEventManager.OnCharacterDeath += (Manipulator)obj;
			}

			private static void GlobalEventManager_OnCharacterDeath(ILContext il)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Expected O, but got Unknown
				//IL_004c: 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.MatchStfld<DelayBlast>(x, "damageType")
				}))
				{
					ILHooks.LogILError(((MemberReference)il.Method).Name, il, val);
					return;
				}
				val.Emit(OpCodes.Ldloc, 24);
				val.EmitDelegate<Action<DelayBlast>>((Action<DelayBlast>)delegate(DelayBlast delayBlast)
				{
					//IL_0008: Unknown result type (might be due to invalid IL or missing references)
					delayBlast.damageType.damageSource = (DamageSource)64;
				});
			}
		}

		internal static void SetupHooks()
		{
			BlazingDamageTrail.SetupHooks();
			MalachiteSpikes.SetupHooks();
			GlacialDeathBubble.SetupHooks();
		}
	}
	[BepInPlugin("LordVGames.DamageSourceForEquipment", "DamageSourceForEquipment", "1.0.2")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGUID = "LordVGames.DamageSourceForEquipment";

		public const string PluginAuthor = "LordVGames";

		public const string PluginName = "DamageSourceForEquipment";

		public const string PluginVersion = "1.0.2";

		public void Awake()
		{
			//IL_0016: 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_002f: Unknown result type (might be due to invalid IL or missing references)
			Log.Init(((BaseUnityPlugin)this).Logger);
			ConfigOptions.BindConfigOptions(((BaseUnityPlugin)this).Config);
			Main.AddEquipmentDamageSource = ProcTypeAPI.ReserveProcType();
			AssetEdits.LoadAndEditAssets();
			ILHooks.SetupHooks();
			new Harmony("LordVGames.DamageSourceForEquipment").CreateClassProcessor(typeof(HarmonyPatches)).Patch();
			if (ConfigOptions.AspectPassiveDamageIsEquipment.Value)
			{
				PassiveAspectEffects.SetupHooks();
			}
		}
	}
}