Decompiled source of NREater v0.0.1

plugins/NRE/NRE.dll

Decompiled 5 days 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 HarmonyLib;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using RoR2;
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("NRE")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: AssemblyInformationalVersion("0.0.1+699d44c84c452f77e1ce6fc6b6b278ff65859051")]
[assembly: AssemblyProduct("NRE")]
[assembly: AssemblyTitle("NRE")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.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 itsschwer.RoR2.NRE
{
	[BepInPlugin("itsschwer.NREater", "NREater", "0.0.1")]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string GUID = "itsschwer.NREater";

		public const string Author = "itsschwer";

		public const string Name = "NREater";

		public const string Version = "0.0.1";

		internal static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			Logger.Sources.Remove((ILogSource)(object)((BaseUnityPlugin)this).Logger);
			Logger = Logger.CreateLogSource("itsschwer.NREater");
			new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID).PatchAll();
			Logger.LogMessage((object)"Patched.");
		}
	}
}
namespace itsschwer.RoR2.NRE.IL
{
	[HarmonyPatch]
	internal static class ElusiveAntlersPickup
	{
		[HarmonyILManipulator]
		[HarmonyPatch(typeof(ElusiveAntlersPickup), "FixedUpdate")]
		private static void ElusiveAntlersPickup_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_00f0: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			Func<Instruction, bool>[] array = new Func<Instruction, bool>[6]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<ElusiveAntlersPickup>(x, "ownerBody"),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Component>(x, "get_gameObject"),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<GameObject>(x, "get_transform"),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Transform>(x, "get_position"),
				(Instruction x) => ILPatternMatchingExt.MatchStloc(x, 0)
			};
			if (val.TryGotoNext(array))
			{
				val.RemoveRange(array.Length - 1);
				val.Emit(OpCodes.Ldarg_0);
				val.EmitDelegate<Func<ElusiveAntlersPickup, Vector3>>((Func<ElusiveAntlersPickup, Vector3>)delegate(ElusiveAntlersPickup @this)
				{
					//IL_002e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0033: Unknown result type (might be due to invalid IL or missing references)
					//IL_004b: Unknown result type (might be due to invalid IL or missing references)
					//IL_001d: Unknown result type (might be due to invalid IL or missing references)
					if (Object.op_Implicit((Object)(object)@this.ownerBody))
					{
						return ((Component)@this.ownerBody).gameObject.transform.position;
					}
					Vector3 position = ((Component)@this).gameObject.transform.position;
					position.z += @this.maxDistanceFromOwner + 1f;
					return position;
				});
			}
			else
			{
				Plugin.Logger.LogError((object)"ElusiveAntlersPickup_FixedUpdate> Cannot hook: failed to match IL instructions.");
			}
		}
	}
}