Decompiled source of EviscerateFix v1.0.2

EviscerateFix.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
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 EntityStates;
using EntityStates.Merc;
using IL.EntityStates.Merc;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using RiskyMod.Survivors;
using RiskyMod.Survivors.Merc;
using RoR2;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("EviscerateFix")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("EviscerateFix")]
[assembly: AssemblyTitle("EviscerateFix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace EviscerateFix
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.Moffein.EviscerateFix", "EviscerateFix", "1.0.0")]
	public class EviscerateFix : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Func<Instruction, bool> <>9__0_2;

			public static Func<Collider[], EvisDash, Collider[]> <>9__0_1;

			public static Manipulator <>9__0_0;

			internal void <Awake>b__0_0(ILContext il)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Expected O, but got Unknown
				//IL_003d: 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<Physics>(x, "OverlapSphere")
				}))
				{
					val.Emit(OpCodes.Ldarg_0);
					val.EmitDelegate<Func<Collider[], EvisDash, Collider[]>>((Func<Collider[], EvisDash, Collider[]>)delegate(Collider[] colliders, EvisDash self)
					{
						//IL_0001: Unknown result type (might be due to invalid IL or missing references)
						//IL_0007: Invalid comparison between Unknown and I4
						//IL_0056: 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)
						if ((int)FriendlyFireManager.friendlyFireMode > 0)
						{
							return colliders;
						}
						List<Collider> list = new List<Collider>();
						foreach (Collider val2 in colliders)
						{
							HurtBox component = ((Component)val2).GetComponent<HurtBox>();
							if (Object.op_Implicit((Object)(object)component) && (Object)(object)component.healthComponent != (Object)(object)((EntityState)self).healthComponent && component.teamIndex != ((BaseState)self).GetTeam())
							{
								list.Add(val2);
							}
						}
						return list.ToArray();
					});
				}
				else
				{
					Debug.LogError((object)"RiskyMod: Merc EvisDash IL Hook failed");
				}
			}

			internal bool <Awake>b__0_2(Instruction x)
			{
				return ILPatternMatchingExt.MatchCall<Physics>(x, "OverlapSphere");
			}

			internal Collider[] <Awake>b__0_1(Collider[] colliders, EvisDash self)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Invalid comparison between Unknown and I4
				//IL_0056: 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)
				if ((int)FriendlyFireManager.friendlyFireMode > 0)
				{
					return colliders;
				}
				List<Collider> list = new List<Collider>();
				foreach (Collider val in colliders)
				{
					HurtBox component = ((Component)val).GetComponent<HurtBox>();
					if (Object.op_Implicit((Object)(object)component) && (Object)(object)component.healthComponent != (Object)(object)((EntityState)self).healthComponent && component.teamIndex != ((BaseState)self).GetTeam())
					{
						list.Add(val);
					}
				}
				return list.ToArray();
			}
		}

		public void Awake()
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			bool flag = true;
			if (Chainloader.PluginInfos.ContainsKey("com.RiskyLives.RiskyMod"))
			{
				flag = !RiskyModAppliedFix();
			}
			if (!flag)
			{
				Debug.LogError((object)"EviscerateFix: RiskyMod already applied fix. Code will not be run.");
				return;
			}
			object obj = <>c.<>9__0_0;
			if (obj == null)
			{
				Manipulator val = delegate(ILContext il)
				{
					//IL_0002: Unknown result type (might be due to invalid IL or missing references)
					//IL_0008: Expected O, but got Unknown
					//IL_003d: Unknown result type (might be due to invalid IL or missing references)
					ILCursor val2 = new ILCursor(il);
					if (val2.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
					{
						(Instruction x) => ILPatternMatchingExt.MatchCall<Physics>(x, "OverlapSphere")
					}))
					{
						val2.Emit(OpCodes.Ldarg_0);
						val2.EmitDelegate<Func<Collider[], EvisDash, Collider[]>>((Func<Collider[], EvisDash, Collider[]>)delegate(Collider[] colliders, EvisDash self)
						{
							//IL_0001: Unknown result type (might be due to invalid IL or missing references)
							//IL_0007: Invalid comparison between Unknown and I4
							//IL_0056: 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)
							if ((int)FriendlyFireManager.friendlyFireMode > 0)
							{
								return colliders;
							}
							List<Collider> list = new List<Collider>();
							foreach (Collider val3 in colliders)
							{
								HurtBox component = ((Component)val3).GetComponent<HurtBox>();
								if (Object.op_Implicit((Object)(object)component) && (Object)(object)component.healthComponent != (Object)(object)((EntityState)self).healthComponent && component.teamIndex != ((BaseState)self).GetTeam())
								{
									list.Add(val3);
								}
							}
							return list.ToArray();
						});
					}
					else
					{
						Debug.LogError((object)"RiskyMod: Merc EvisDash IL Hook failed");
					}
				};
				<>c.<>9__0_0 = val;
				obj = (object)val;
			}
			EvisDash.FixedUpdate += (Manipulator)obj;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private bool RiskyModAppliedFix()
		{
			return SurvivorsCore.enabled && MercCore.enabled && MercCore.evisTargetingFix;
		}
	}
}
namespace R2API.Utils
{
	[AttributeUsage(AttributeTargets.Assembly)]
	public class ManualNetworkRegistrationAttribute : Attribute
	{
	}
}