Decompiled source of EnemyAttackSpeedFixes v1.2.0

plugins/EnemyAttackSpeedFixes.dll

Decompiled 3 weeks ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using EntityStates;
using EntityStates.BrotherMonster;
using EntityStates.GolemMonster;
using EntityStates.TitanMonster;
using IL.EntityStates.BrotherMonster;
using IL.EntityStates.GolemMonster;
using IL.EntityStates.TitanMonster;
using IL.RoR2;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using RoR2;
using RoR2.Projectile;
using UnityEngine;

[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("EnemyAttackSpeedFixes")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+2501e503d956fdc3ecc6132bb705c7e714b84455")]
[assembly: AssemblyProduct("EnemyAttackSpeedFixes")]
[assembly: AssemblyTitle("EnemyAttackSpeedFixes")]
[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 EnemyAttackSpeedFixes
{
	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);
		}
	}
	internal static class Main
	{
		internal static class StoneGolem
		{
			[CompilerGenerated]
			private static class <>O
			{
				public static Manipulator <0>__ClapState_OnEnter;

				public static Manipulator <1>__ClapState_FixedUpdate;

				public static Manipulator <2>__ClapState_OnExit;
			}

			internal static void SetupILHooks()
			{
				//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
				object obj = <>O.<0>__ClapState_OnEnter;
				if (obj == null)
				{
					Manipulator val = ClapState_OnEnter;
					<>O.<0>__ClapState_OnEnter = val;
					obj = (object)val;
				}
				ClapState.OnEnter += (Manipulator)obj;
				object obj2 = <>O.<1>__ClapState_FixedUpdate;
				if (obj2 == null)
				{
					Manipulator val2 = ClapState_FixedUpdate;
					<>O.<1>__ClapState_FixedUpdate = val2;
					obj2 = (object)val2;
				}
				ClapState.FixedUpdate += (Manipulator)obj2;
				object obj3 = <>O.<2>__ClapState_OnExit;
				if (obj3 == null)
				{
					Manipulator val3 = ClapState_OnExit;
					<>O.<2>__ClapState_OnExit = val3;
					obj3 = (object)val3;
				}
				ClapState.OnExit += (Manipulator)obj3;
			}

			private static void ClapState_OnEnter(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.MatchLdstr(x, "Clap"),
					(Instruction x) => ILPatternMatchingExt.MatchLdstr(x, "Clap.playbackRate"),
					(Instruction x) => ILPatternMatchingExt.MatchLdsfld<ClapState>(x, "duration")
				}))
				{
					Log.Error("COULD NOT IL HOOK " + ((MemberReference)il.Method).Name);
					LogILStuff(il, val);
				}
				else
				{
					MakeDurationUseAttackSpeed(val);
				}
			}

			private static void ClapState_FixedUpdate(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);
				MethodReference val2 = default(MethodReference);
				if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[3]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
					(Instruction x) => ILPatternMatchingExt.MatchCall(x, ref val2),
					(Instruction x) => ILPatternMatchingExt.MatchLdsfld<ClapState>(x, "duration")
				}))
				{
					Log.Error("COULD NOT IL HOOK " + ((MemberReference)il.Method).Name);
					LogILStuff(il, val);
				}
				else
				{
					MakeDurationUseAttackSpeed(val);
				}
			}

			private static void ClapState_OnExit(ILContext il)
			{
				//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)
				ILCursor val = new ILCursor(il);
				val.Emit(OpCodes.Ldarg_0);
				val.EmitDelegate<Action<ClapState>>((Action<ClapState>)delegate(ClapState clapState)
				{
					clapState.modelAnimator.speed = 1f;
				});
			}

			private static void MakeDurationUseAttackSpeed(ILCursor c)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				c.Emit(OpCodes.Ldarg_0);
				c.EmitDelegate<Func<float, ClapState, float>>((Func<float, ClapState, float>)delegate(float clapStateDuration, ClapState currentClapState)
				{
					currentClapState.modelAnimator.speed = 1f * ((BaseState)currentClapState).attackSpeedStat;
					return clapStateDuration / ((BaseState)currentClapState).attackSpeedStat;
				});
			}
		}

		internal static class Mithrix
		{
			[CompilerGenerated]
			private static class <>O
			{
				public static Manipulator <0>__WeaponSlam_OnEnter;

				public static Manipulator <1>__WeaponSlam_FixedUpdate;

				public static Manipulator <2>__WeaponSlam_OnExit;
			}

			internal static void SetupILHooks()
			{
				//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
				object obj = <>O.<0>__WeaponSlam_OnEnter;
				if (obj == null)
				{
					Manipulator val = WeaponSlam_OnEnter;
					<>O.<0>__WeaponSlam_OnEnter = val;
					obj = (object)val;
				}
				WeaponSlam.OnEnter += (Manipulator)obj;
				object obj2 = <>O.<1>__WeaponSlam_FixedUpdate;
				if (obj2 == null)
				{
					Manipulator val2 = WeaponSlam_FixedUpdate;
					<>O.<1>__WeaponSlam_FixedUpdate = val2;
					obj2 = (object)val2;
				}
				WeaponSlam.FixedUpdate += (Manipulator)obj2;
				object obj3 = <>O.<2>__WeaponSlam_OnExit;
				if (obj3 == null)
				{
					Manipulator val3 = WeaponSlam_OnExit;
					<>O.<2>__WeaponSlam_OnExit = val3;
					obj3 = (object)val3;
				}
				WeaponSlam.OnExit += (Manipulator)obj3;
			}

			private static void WeaponSlam_OnEnter(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.MatchLdstr(x, "WeaponSlam"),
					(Instruction x) => ILPatternMatchingExt.MatchLdstr(x, "WeaponSlam.playbackRate"),
					(Instruction x) => ILPatternMatchingExt.MatchLdsfld<WeaponSlam>(x, "duration")
				}))
				{
					Log.Error("COULD NOT IL HOOK " + ((MemberReference)il.Method).Name);
					LogILStuff(il, val);
				}
				else
				{
					MakeDurationUseAttackSpeed(val);
					val.Next.Operand = 0.05f;
				}
			}

			private static void WeaponSlam_FixedUpdate(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);
				MethodReference val3 = default(MethodReference);
				if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[3]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
					(Instruction x) => ILPatternMatchingExt.MatchCall(x, ref val3),
					(Instruction x) => ILPatternMatchingExt.MatchLdsfld<WeaponSlam>(x, "duration")
				}))
				{
					Log.Error("COULD NOT IL HOOK " + ((MemberReference)il.Method).Name + " PART 1");
					LogILStuff(il, val);
				}
				else
				{
					MakeDurationUseAttackSpeed(val);
				}
				MethodReference val2 = default(MethodReference);
				if (!val.TryGotoNext((MoveType)1, new Func<Instruction, bool>[3]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
					(Instruction x) => ILPatternMatchingExt.MatchLdfld<EntityState>(x, "outer"),
					(Instruction x) => ILPatternMatchingExt.MatchCallvirt(x, ref val2)
				}))
				{
					Log.Error("COULD NOT IL HOOK " + ((MemberReference)il.Method).Name + " PART 2");
					LogILStuff(il, val);
				}
				else
				{
					ResetEntityStateAnimatorSpeed(val);
				}
			}

			private static void WeaponSlam_OnExit(ILContext il)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Expected O, but got Unknown
				ResetEntityStateAnimatorSpeed(new ILCursor(il)
				{
					Index = 0
				});
			}

			private static void MakeDurationUseAttackSpeed(ILCursor c)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				c.Emit(OpCodes.Ldarg_0);
				c.EmitDelegate<Func<float, WeaponSlam, float>>((Func<float, WeaponSlam, float>)((float slamStateDuration, WeaponSlam currentSlamState) => slamStateDuration / ((BaseState)currentSlamState).attackSpeedStat));
			}

			private static void ResetEntityStateAnimatorSpeed(ILCursor c)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				c.Emit(OpCodes.Ldarg_0);
				c.EmitDelegate<Action<WeaponSlam>>((Action<WeaponSlam>)delegate(WeaponSlam slamState)
				{
					slamState.modelAnimator.speed = 1f;
				});
			}
		}

		internal static class StoneTitan
		{
			[CompilerGenerated]
			private static class <>O
			{
				public static Manipulator <0>__FireFist_OnEnter;

				public static Manipulator <1>__FireFist_FixedUpdate;

				public static Manipulator <2>__FireFist_PlaceSingleDelayBlast;

				public static Manipulator <3>__FireFist_OnExit;

				public static Manipulator <4>__TitanRockController_Start;

				public static Manipulator <5>__TitanRockController_FixedUpdate;

				public static Manipulator <6>__TitanRockController_FixedUpdateServer;

				public static Manipulator <7>__FireMegaLaser_FixedUpdate;

				public static Manipulator <8>__FireMegaLaser_FireBullet;
			}

			internal static void SetupILHooks()
			{
				//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
				//IL_0090: Unknown result type (might be due to invalid IL or missing references)
				//IL_0095: Unknown result type (might be due to invalid IL or missing references)
				//IL_009b: Expected O, but got Unknown
				//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: Expected O, but got Unknown
				//IL_00d0: 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
				//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fb: Expected O, but got Unknown
				//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_011b: Expected O, but got Unknown
				object obj = <>O.<0>__FireFist_OnEnter;
				if (obj == null)
				{
					Manipulator val = FireFist_OnEnter;
					<>O.<0>__FireFist_OnEnter = val;
					obj = (object)val;
				}
				FireFist.OnEnter += (Manipulator)obj;
				object obj2 = <>O.<1>__FireFist_FixedUpdate;
				if (obj2 == null)
				{
					Manipulator val2 = FireFist_FixedUpdate;
					<>O.<1>__FireFist_FixedUpdate = val2;
					obj2 = (object)val2;
				}
				FireFist.FixedUpdate += (Manipulator)obj2;
				object obj3 = <>O.<2>__FireFist_PlaceSingleDelayBlast;
				if (obj3 == null)
				{
					Manipulator val3 = FireFist_PlaceSingleDelayBlast;
					<>O.<2>__FireFist_PlaceSingleDelayBlast = val3;
					obj3 = (object)val3;
				}
				FireFist.PlaceSingleDelayBlast += (Manipulator)obj3;
				object obj4 = <>O.<3>__FireFist_OnExit;
				if (obj4 == null)
				{
					Manipulator val4 = FireFist_OnExit;
					<>O.<3>__FireFist_OnExit = val4;
					obj4 = (object)val4;
				}
				FireFist.OnExit += (Manipulator)obj4;
				object obj5 = <>O.<4>__TitanRockController_Start;
				if (obj5 == null)
				{
					Manipulator val5 = TitanRockController_Start;
					<>O.<4>__TitanRockController_Start = val5;
					obj5 = (object)val5;
				}
				TitanRockController.Start += (Manipulator)obj5;
				object obj6 = <>O.<5>__TitanRockController_FixedUpdate;
				if (obj6 == null)
				{
					Manipulator val6 = TitanRockController_FixedUpdate;
					<>O.<5>__TitanRockController_FixedUpdate = val6;
					obj6 = (object)val6;
				}
				TitanRockController.FixedUpdate += (Manipulator)obj6;
				object obj7 = <>O.<6>__TitanRockController_FixedUpdateServer;
				if (obj7 == null)
				{
					Manipulator val7 = TitanRockController_FixedUpdateServer;
					<>O.<6>__TitanRockController_FixedUpdateServer = val7;
					obj7 = (object)val7;
				}
				TitanRockController.FixedUpdateServer += (Manipulator)obj7;
				object obj8 = <>O.<7>__FireMegaLaser_FixedUpdate;
				if (obj8 == null)
				{
					Manipulator val8 = FireMegaLaser_FixedUpdate;
					<>O.<7>__FireMegaLaser_FixedUpdate = val8;
					obj8 = (object)val8;
				}
				FireMegaLaser.FixedUpdate += (Manipulator)obj8;
				object obj9 = <>O.<8>__FireMegaLaser_FireBullet;
				if (obj9 == null)
				{
					Manipulator val9 = FireMegaLaser_FireBullet;
					<>O.<8>__FireMegaLaser_FireBullet = val9;
					obj9 = (object)val9;
				}
				FireMegaLaser.FireBullet += (Manipulator)obj9;
			}

			private static void FireFist_OnEnter(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.MatchLdstr(x, "PrepFist"),
					(Instruction x) => ILPatternMatchingExt.MatchLdstr(x, "PrepFist.playbackRate"),
					(Instruction x) => ILPatternMatchingExt.MatchLdsfld<FireFist>(x, "entryDuration")
				}))
				{
					Log.Error("COULD NOT IL HOOK " + ((MemberReference)il.Method).Name);
					LogILStuff(il, val);
				}
				else
				{
					MakeFireFistDurationUseAttackSpeed(val);
				}
			}

			private static void FireFist_FixedUpdate(ILContext il)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Expected O, but got Unknown
				//IL_0230: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
				ILCursor val = new ILCursor(il);
				int num = 1;
				if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdfld<FireFist>(x, "stopwatch"),
					(Instruction x) => ILPatternMatchingExt.MatchLdsfld<FireFist>(x, "trackingDuration")
				}))
				{
					Log.Error("COULD NOT IL HOOK " + ((MemberReference)il.Method).Name);
					LogILStuff(il, val);
					return;
				}
				MakeFireFistDurationUseAttackSpeed(val);
				num++;
				if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdfld<FireFist>(x, "stopwatch"),
					(Instruction x) => ILPatternMatchingExt.MatchLdsfld<FireFist>(x, "entryDuration")
				}))
				{
					Log.Error($"COULD NOT IL HOOK {((MemberReference)il.Method).Name} PART {num}");
					LogILStuff(il, val);
					return;
				}
				MakeFireFistDurationUseAttackSpeed(val);
				num++;
				if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdfld<FireFist>(x, "stopwatch"),
					(Instruction x) => ILPatternMatchingExt.MatchLdsfld<FireFist>(x, "fireDuration")
				}))
				{
					Log.Error($"COULD NOT IL HOOK {((MemberReference)il.Method).Name} PART {num}");
					LogILStuff(il, val);
					return;
				}
				MakeFireFistDurationUseAttackSpeed(val);
				num++;
				if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[3]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdstr(x, "ExitFist"),
					(Instruction x) => ILPatternMatchingExt.MatchLdstr(x, "ExitFist.playbackRate"),
					(Instruction x) => ILPatternMatchingExt.MatchLdsfld<FireFist>(x, "exitDuration")
				}))
				{
					Log.Error($"COULD NOT IL HOOK {((MemberReference)il.Method).Name} PART {num}");
					LogILStuff(il, val);
					return;
				}
				val.Emit(OpCodes.Ldarg_0);
				val.EmitDelegate<Func<float, FireFist, float>>((Func<float, FireFist, float>)delegate(float fireFirstDuration, FireFist currentFireFistState)
				{
					((EntityState)currentFireFistState).GetModelAnimator().speed = 1f;
					return fireFirstDuration / (((BaseState)currentFireFistState).attackSpeedStat * 1.4f);
				});
				num++;
				if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdfld<FireFist>(x, "stopwatch"),
					(Instruction x) => ILPatternMatchingExt.MatchLdsfld<FireFist>(x, "exitDuration")
				}))
				{
					Log.Error($"COULD NOT IL HOOK {((MemberReference)il.Method).Name} PART {num}");
					LogILStuff(il, val);
					return;
				}
				val.Emit(OpCodes.Ldarg_0);
				val.EmitDelegate<Func<float, FireFist, float>>((Func<float, FireFist, float>)delegate(float fireFirstDuration, FireFist currentFireFistState)
				{
					((EntityState)currentFireFistState).GetModelAnimator().speed = 1f;
					return fireFirstDuration / (((BaseState)currentFireFistState).attackSpeedStat * 1.4f);
				});
				num++;
				if (!val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[2]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
					(Instruction x) => ILPatternMatchingExt.MatchLdfld<EntityState>(x, "outer")
				}))
				{
					Log.Error($"COULD NOT IL HOOK {((MemberReference)il.Method).Name} PART {num}");
					LogILStuff(il, val);
				}
				else
				{
					ResetAnimatorSpeed(val);
				}
			}

			private static void FireFist_PlaceSingleDelayBlast(ILContext il)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Expected O, but got Unknown
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_0092: Unknown result type (might be due to invalid IL or missing references)
				ILCursor val = new ILCursor(il);
				if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchCall<ProjectileManager>(x, "get_instance")
				}))
				{
					Log.Error("COULD NOT IL HOOK " + ((MemberReference)il.Method).Name + " PART 1");
					LogILStuff(il, val);
					return;
				}
				val.Emit(OpCodes.Ldloc_0);
				val.EmitDelegate<Func<FireProjectileInfo, FireProjectileInfo>>((Func<FireProjectileInfo, FireProjectileInfo>)delegate(FireProjectileInfo fireProjectileInfo)
				{
					//IL_0008: Unknown result type (might be due to invalid IL or missing references)
					fireProjectileInfo.useFuseOverride = true;
					return fireProjectileInfo;
				});
				val.Emit(OpCodes.Stloc_0);
				val.Index = 0;
				if (!val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchCall<FireProjectileInfo>(x, "set_fuseOverride")
				}))
				{
					Log.Error("COULD NOT IL HOOK " + ((MemberReference)il.Method).Name + " PART 2");
					LogILStuff(il, val);
				}
				else
				{
					MakeFireFistDurationUseAttackSpeed(val);
				}
			}

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

			private static void TitanRockController_Start(ILContext il)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Expected O, but got Unknown
				//IL_005b: 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.MatchLdfld<TitanRockController>(x, "startDelay")
				}))
				{
					Log.Error("COULD NOT IL HOOK " + ((MemberReference)il.Method).Name);
					LogILStuff(il, val);
					return;
				}
				val.Emit(OpCodes.Ldarg_0);
				val.EmitDelegate<Func<float, TitanRockController, float>>((Func<float, TitanRockController, float>)((float startDelay, TitanRockController titanRockController) => Object.op_Implicit((Object)(object)titanRockController.ownerCharacterBody) ? (startDelay / titanRockController.ownerCharacterBody.attackSpeed) : startDelay));
			}

			private static void TitanRockController_FixedUpdate(ILContext il)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Expected O, but got Unknown
				//IL_007d: 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>[2]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdflda<TitanRockController>(x, "velocity"),
					(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 1f)
				}))
				{
					Log.Error("COULD NOT IL HOOK " + ((MemberReference)il.Method).Name);
					LogILStuff(il, val);
					return;
				}
				val.Emit(OpCodes.Ldarg_0);
				val.EmitDelegate<Func<float, TitanRockController, float>>((Func<float, TitanRockController, float>)((float moveTime, TitanRockController titanRockController) => Object.op_Implicit((Object)(object)titanRockController.ownerCharacterBody) ? (moveTime / (1f + (titanRockController.ownerCharacterBody.attackSpeed - 1f) / 2f)) : moveTime));
			}

			private static void TitanRockController_FixedUpdateServer(ILContext il)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Expected O, but got Unknown
				//IL_005b: 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.MatchLdfld<TitanRockController>(x, "fireInterval")
				}))
				{
					Log.Error("COULD NOT IL HOOK " + ((MemberReference)il.Method).Name);
					LogILStuff(il, val);
					return;
				}
				val.Emit(OpCodes.Ldarg_0);
				val.EmitDelegate<Func<float, TitanRockController, float>>((Func<float, TitanRockController, float>)((float fireInterval, TitanRockController titanRockController) => Object.op_Implicit((Object)(object)titanRockController.ownerCharacterBody) ? (fireInterval / titanRockController.ownerCharacterBody.attackSpeed) : fireInterval));
			}

			private static void FireMegaLaser_FixedUpdate(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);
				MakeMegaLaserFireFrequencyUseAttackSpeed(il, c, 1);
				MakeMegaLaserFireFrequencyUseAttackSpeed(il, c, 2);
			}

			private static void FireMegaLaser_FireBullet(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);
				MakeMegaLaserFireFrequencyUseAttackSpeed(il, c, 1);
			}

			private static void MakeFireFistDurationUseAttackSpeed(ILCursor c)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				c.Emit(OpCodes.Ldarg_0);
				c.EmitDelegate<Func<float, FireFist, float>>((Func<float, FireFist, float>)delegate(float fireFirstDuration, FireFist currentFireFistState)
				{
					((EntityState)currentFireFistState).GetModelAnimator().speed = 1f * ((BaseState)currentFireFistState).attackSpeedStat;
					return fireFirstDuration / ((BaseState)currentFireFistState).attackSpeedStat;
				});
			}

			private static void ResetAnimatorSpeed(ILCursor c)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				c.Emit(OpCodes.Ldarg_0);
				c.EmitDelegate<Action<FireFist>>((Action<FireFist>)delegate(FireFist fireFistState)
				{
					((EntityState)fireFistState).GetModelAnimator().speed = 1f;
				});
			}

			private static void MakeMegaLaserFireFrequencyUseAttackSpeed(ILContext il, ILCursor c, int partNumber)
			{
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				if (!c.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdsfld<FireMegaLaser>(x, "fireFrequency")
				}))
				{
					Log.Error($"COULD NOT IL HOOK {((MemberReference)il.Method).Name} PART {partNumber}");
					LogILStuff(il, c);
					return;
				}
				c.Emit(OpCodes.Ldarg_0);
				c.EmitDelegate<Func<float, FireMegaLaser, float>>((Func<float, FireMegaLaser, float>)((float fireFrequency, FireMegaLaser megaLaserState) => fireFrequency * ((BaseState)megaLaserState).attackSpeedStat));
			}
		}

		private static void LogILStuff(ILContext il, ILCursor c)
		{
			Log.Warning($"cursor is {c}");
			Log.Warning($"il is {il}");
		}
	}
	public static class ModAssets
	{
		public static AssetBundle AssetBundle;

		public const string BundleName = "animgolemdiff";

		public static string AssetBundlePath => Path.Combine(Path.GetDirectoryName(Plugin.PluginInfo.Location), "animgolemdiff");

		public static void Init()
		{
			AssetBundle = AssetBundle.LoadFromFile(AssetBundlePath);
		}
	}
	[BepInPlugin("LordVGames.EnemyAttackSpeedFixes", "EnemyAttackSpeedFixes", "1.2.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGUID = "LordVGames.EnemyAttackSpeedFixes";

		public const string PluginAuthor = "LordVGames";

		public const string PluginName = "EnemyAttackSpeedFixes";

		public const string PluginVersion = "1.2.0";

		public static PluginInfo PluginInfo { get; private set; }

		public void Awake()
		{
			PluginInfo = ((BaseUnityPlugin)this).Info;
			Log.Init(((BaseUnityPlugin)this).Logger);
			Main.StoneGolem.SetupILHooks();
			Main.Mithrix.SetupILHooks();
			Main.StoneTitan.SetupILHooks();
		}
	}
}