Decompiled source of Catch Players v1.1.3

tony4twentys-Catch Players.dll

Decompiled a month ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
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: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[BepInPlugin("tony4twentys.Catch_Players", "Catch Players", "1.1.3")]
public class Catch_Players : BaseUnityPlugin
{
	[HarmonyPatch(typeof(CharacterGrabbing), "Reach")]
	private static class Patch_Reach
	{
		private static void Postfix(CharacterGrabbing __instance)
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			Character character = __instance.character;
			if ((Object)(object)character == (Object)null || character.data.isScoutmaster)
			{
				return;
			}
			foreach (Character allCharacter in Character.AllCharacters)
			{
				if ((Object)(object)allCharacter == (Object)(object)character || allCharacter.data.isScoutmaster)
				{
					continue;
				}
				float num = Vector3.Distance(character.Center, allCharacter.Center);
				float num2 = Vector3.Angle(character.data.lookDirection, allCharacter.Center - character.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 < character.Center.y + 1f);
				if (flag && (flag2 || flag3))
				{
					if (num < character.data.grabFriendDistance)
					{
						character.data.grabFriendDistance = num;
						character.data.sinceGrabFriend = 0f;
					}
					if (allCharacter.refs.view.IsMine)
					{
						allCharacter.DragTowards(character.Center, PullStrength.Value);
						allCharacter.LimitFalling();
						GUIManager.instance.Grasp();
					}
				}
			}
		}
	}

	[HarmonyPatch(typeof(Character), "Update")]
	private static class Patch_AutoRelease
	{
		private static void Postfix(Character __instance)
		{
			try
			{
				if (!__instance.data.isScoutmaster && __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 void Awake()
	{
		//IL_002a: 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.");
		new Harmony("tony4twentys.Catch_Players").PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"[Catch_Players] Plugin loaded and patches applied.");
	}
}