Decompiled source of Catch Players v1.1.2

tony4twentys-Catch Players.dll

Decompiled a week ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Photon.Pun;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Catch Players")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Catch Players")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("253db8f0-aa96-4337-9ba2-7ed5ca33642c")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("tony4twentys.Catch_Players", "Catch Players", "1.1.2")]
public class Catch_Players : BaseUnityPlugin
{
	[HarmonyPatch(typeof(CharacterGrabbing), "Reach")]
	private static class Patch_Reach
	{
		private static void Postfix(CharacterGrabbing __instance)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			Character value = Traverse.Create((object)__instance).Field("character").GetValue<Character>();
			if ((Object)(object)value == (Object)null)
			{
				return;
			}
			foreach (Character allCharacter in Character.AllCharacters)
			{
				if ((Object)(object)allCharacter == (Object)(object)value)
				{
					continue;
				}
				float num = Vector3.Distance(value.Center, allCharacter.Center);
				float num2 = Vector3.Angle(value.data.lookDirection, allCharacter.Center - value.Center);
				bool flag = num <= 4f && num2 <= 60f;
				bool flag2 = !allCharacter.data.isGrounded && !allCharacter.data.isRopeClimbing && !allCharacter.data.isVineClimbing;
				bool flag3 = allCharacter.IsStuck() || allCharacter.data.sinceUnstuck < 1f || (allCharacter.data.isClimbing && allCharacter.Center.y < value.Center.y + 1f);
				if (flag && (flag2 || flag3))
				{
					if (num < value.data.grabFriendDistance)
					{
						value.data.grabFriendDistance = num;
						value.data.sinceGrabFriend = 0f;
					}
					if (allCharacter.refs.view.IsMine)
					{
						dragTowardsMethod?.Invoke(allCharacter, new object[2] { value.Center, PullStrength.Value });
						limitFallingMethod?.Invoke(allCharacter, null);
						GUIManager.instance.Grasp();
					}
				}
			}
		}
	}

	[HarmonyPatch(typeof(Character), "Update")]
	private static class Patch_AutoRelease
	{
		private static void Postfix(Character __instance)
		{
			try
			{
				if (__instance.data.isReaching && (Object)(object)__instance.data.grabJoint != (Object)null && (__instance.data.isGrounded || __instance.data.isClimbing || __instance.data.isRopeClimbing || __instance.data.isVineClimbing))
				{
					__instance.refs.view.RPC("RPCA_StopReaching", (RpcTarget)0, Array.Empty<object>());
				}
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("[Catch_Players] AutoRelease error: " + ex.Message));
			}
		}
	}

	[HarmonyPatch(typeof(CharacterGrabbing), "CanGrab")]
	private static class Patch_CanGrab
	{
		private static bool Prefix(ref bool __result)
		{
			return true;
		}
	}

	public static ConfigEntry<float> PullStrength;

	private static MethodInfo dragTowardsMethod;

	private static MethodInfo limitFallingMethod;

	private void Awake()
	{
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		PullStrength = ((BaseUnityPlugin)this).Config.Bind<float>("General", "PullStrength", 100f, "How strong the pull should be when grabbing a player.");
		dragTowardsMethod = AccessTools.Method(typeof(Character), "DragTowards", (Type[])null, (Type[])null);
		limitFallingMethod = AccessTools.Method(typeof(Character), "LimitFalling", (Type[])null, (Type[])null);
		new Harmony("tony4twentys.Catch_Players").PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"[Catch_Players] Plugin loaded and patches applied.");
	}
}