Decompiled source of NoDronePush v1.0.0

plugins/NoDronePush.dll

Decompiled 6 hours 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.Logging;
using EntityStates;
using EntityStates.Merc;
using HG.Reflection;
using IL.EntityStates.Merc;
using Logger;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
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: OptIn]
[assembly: IgnoresAccessChecksTo("ItemQualities")]
[assembly: IgnoresAccessChecksTo("ItemQualities.Patcher")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("NoDronePush")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+f19949d7890f5e785b7a200e7b7bdff6fbecf3a5")]
[assembly: AssemblyProduct("NoDronePush")]
[assembly: AssemblyTitle("NoDronePush")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MonoDetour.HookGen
{
	internal static class DefaultMonoDetourManager
	{
		internal static MonoDetourManager Instance { get; } = New();

		internal static MonoDetourManager New()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			return new MonoDetourManager(typeof(DefaultMonoDetourManager).Assembly.GetName().Name);
		}
	}
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
	internal class MonoDetourTargetsAttribute(Type? targetType = null) : Attribute(), IMonoDetourTargets
	{
		public Type? TargetType { get; } = targetType;

		public bool IncludeNestedTypes { get; set; } = true;

		public string[]? Members { get; set; }

		public string[]? MemberNamePrefixes { get; set; }

		public string[]? MemberNameSuffixes { get; set; }

		public bool GenerateControlFlowVariants { get; set; }
	}
}
namespace NoDronePush
{
	[BepInPlugin("com.Onyx.NoDronePush", "NoDronePush", "1.0.0")]
	public sealed class NoDronePush : BaseUnityPlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Manipulator <0>__EvisDash_FixedUpdate;

			public static Func<EvisDash, HurtBox, bool> <1>__ignoreTeamMates;
		}

		public const string PluginGUID = "com.Onyx.NoDronePush";

		public const string PluginAuthor = "Onyx";

		public const string PluginName = "NoDronePush";

		public const string PluginVersion = "1.0.0";

		public void Awake()
		{
			Log.Init(((BaseUnityPlugin)this).Logger);
		}

		[SystemInitializer(new Type[] { typeof(DroneCatalog) })]
		private static void Init()
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected O, but got Unknown
			CharacterBody val = default(CharacterBody);
			foreach (DroneDef allDroneDef in DroneCatalog.allDroneDefs)
			{
				if (Object.op_Implicit((Object)(object)allDroneDef.bodyPrefab) && allDroneDef.bodyPrefab.TryGetComponent<CharacterBody>(ref val))
				{
					val.doNotReassignToTeamBasedCollisionLayer = true;
					allDroneDef.bodyPrefab.layer = LayerIndex.playerFakeActor.intVal;
				}
			}
			object obj = <>O.<0>__EvisDash_FixedUpdate;
			if (obj == null)
			{
				Manipulator val2 = EvisDash_FixedUpdate;
				<>O.<0>__EvisDash_FixedUpdate = val2;
				obj = (object)val2;
			}
			EvisDash.FixedUpdate += (Manipulator)obj;
		}

		private static void EvisDash_FixedUpdate(ILContext il)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			ILLabel label = null;
			int hurtboxLoc = 0;
			if (!val.TryGotoNext(new Func<Instruction, bool>[2]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, typeof(Component), "GetComponent"),
				(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref hurtboxLoc)
			}))
			{
				Log.Error(((MemberReference)il.Method).Name + " IL Hook failed!");
			}
			val.Index = 0;
			if (val.TryGotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchNewobj(x, typeof(Evis))
			}) && val.TryGotoPrev((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref label)
			}))
			{
				val.Emit(OpCodes.Ldarg_0);
				val.Emit(OpCodes.Ldloc, hurtboxLoc);
				val.EmitDelegate<Func<EvisDash, HurtBox, bool>>((Func<EvisDash, HurtBox, bool>)ignoreTeamMates);
				val.Emit(OpCodes.Brfalse, (object)label);
			}
			else
			{
				Log.Error(((MemberReference)il.Method).Name + " IL Hook failed!");
			}
			static bool ignoreTeamMates(EvisDash self, HurtBox hurtBox)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				TeamMask unprotectedTeams = TeamMask.GetUnprotectedTeams(((BaseState)self).GetTeam());
				if (((TeamMask)(ref unprotectedTeams)).HasTeam(hurtBox.teamIndex))
				{
					return true;
				}
				return false;
			}
		}
	}
}
namespace Logger
{
	internal static class Log
	{
		private static ManualLogSource _logSource;

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

		internal static void message(object data)
		{
			_logSource.LogInfo(data);
			if (data != null)
			{
				Chat.AddMessage(data.ToString());
			}
			else
			{
				Chat.AddMessage("Null");
			}
		}

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

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

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

		internal static void Info(object data)
		{
			StackFrame stackFrame = new StackFrame(1);
			MethodBase method = stackFrame.GetMethod();
			_logSource.LogInfo((object)("[" + method.Name + "]: " + data));
		}

		internal static void Message(object data)
		{
			message(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}