Decompiled source of RescueHookInfiniteRange v1.1.1

plugins/RescueHookInfiniteRange.dll

Decompiled 3 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.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("RescueHookInfiniteRange")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RescueHookInfiniteRange")]
[assembly: AssemblyTitle("RescueHookInfiniteRange")]
[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.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]
	[Microsoft.CodeAnalysis.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]
	[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 RescueHookInfiniteRange
{
	[BepInPlugin("RescueHookInfiniteRange", "RescueHookInfiniteRange", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		private void Awake()
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)"RescueHookInfiniteRange v1.0.0 loaded!");
			Type type = null;
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			foreach (Assembly assembly in assemblies)
			{
				if (!(assembly.GetName().Name != "Assembly-CSharp"))
				{
					type = assembly.GetType("RescueHook");
					break;
				}
			}
			if (type == null)
			{
				Log.LogError((object)"Could not find RescueHook class!");
				return;
			}
			Harmony val = new Harmony("RescueHookInfiniteRange");
			MethodInfo methodInfo = AccessTools.Method(type, "GetHit", (Type[])null, (Type[])null);
			if (methodInfo != null)
			{
				val.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(GetHitPatch), "Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				Log.LogInfo((object)"Patched RescueHook.GetHit — infinite range active.");
			}
			else
			{
				Log.LogError((object)"Could not find GetHit method!");
			}
		}
	}
	public static class GetHitPatch
	{
		private static FieldInfo? _curRange;

		private static FieldInfo? _range;

		private static FieldInfo? _rangeDownward;

		private static FieldInfo? _maxWallHookTime;

		private static FieldInfo? _maxScoutHookTime;

		public static void Postfix(object __instance)
		{
			if (__instance != null)
			{
				Type type = __instance.GetType();
				if ((object)_curRange == null)
				{
					_curRange = type.GetField("curRange", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				}
				if ((object)_range == null)
				{
					_range = type.GetField("range", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				}
				if ((object)_rangeDownward == null)
				{
					_rangeDownward = type.GetField("rangeDownward", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				}
				if ((object)_maxWallHookTime == null)
				{
					_maxWallHookTime = type.GetField("maxWallHookTime", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				}
				if ((object)_maxScoutHookTime == null)
				{
					_maxScoutHookTime = type.GetField("maxScoutHookTime", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				}
				_curRange?.SetValue(__instance, 10000f);
				_range?.SetValue(__instance, 10000f);
				_rangeDownward?.SetValue(__instance, 10000f);
				_maxWallHookTime?.SetValue(__instance, 30f);
				_maxScoutHookTime?.SetValue(__instance, 30f);
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "RescueHookInfiniteRange";

		public const string PLUGIN_NAME = "RescueHookInfiniteRange";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}