Decompiled source of Swing System v1.0.1

plugins/SwingSystem.dll

Decompiled 2 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.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("BellaModsGames")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SwingSystem")]
[assembly: AssemblyTitle("SwingSystem")]
[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 SwingSystemMod
{
	[BepInPlugin("com.BellaModsGames.reposwingsystem", "Swing System", "1.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(PlayerController))]
		private class PlayerControllerPatches
		{
			[HarmonyPatch("Start")]
			[HarmonyPostfix]
			private static void Start_Postfix(PlayerController __instance)
			{
				if ((Object)(object)((Component)__instance).gameObject.GetComponent<SwingSystemController>() == (Object)null)
				{
					swingController = ((Component)__instance).gameObject.AddComponent<SwingSystemController>();
					ManualLogSource? loggerInstance = LoggerInstance;
					if (loggerInstance != null)
					{
						loggerInstance.LogInfo((object)"SwingSystemController added to Player.");
					}
					swingController.Configure(MaxSwingDistance?.Value ?? 30f, SwingForceMultiplier?.Value ?? 50f, UpwardsForceMultiplier?.Value ?? 10f, JointSpring?.Value ?? 8f, JointDamper?.Value ?? 5f, JointMassScale?.Value ?? 5f);
				}
			}

			[HarmonyPatch("FixedUpdate")]
			[HarmonyPrefix]
			private static bool FixedUpdate_Prefix(PlayerController __instance)
			{
				//IL_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_004c: Unknown result type (might be due to invalid IL or missing references)
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)swingController != (Object)null && swingController.IsSwinging())
				{
					if ((Object)(object)__instance.cameraGameObject != (Object)null)
					{
						Transform transform = ((Component)__instance).transform;
						Quaternion localRotation = __instance.cameraGameObject.transform.localRotation;
						transform.rotation = Quaternion.Euler(0f, ((Quaternion)(ref localRotation)).eulerAngles.y, 0f);
					}
					swingController.ApplySwingPhysics();
					return false;
				}
				return true;
			}

			[HarmonyPatch("Update")]
			[HarmonyPrefix]
			private static bool Update_Prefix(PlayerController __instance)
			{
				//IL_004c: Unknown result type (might be due to invalid IL or missing references)
				//IL_005c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0099: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
				//IL_0153: Unknown result type (might be due to invalid IL or missing references)
				//IL_0164: Unknown result type (might be due to invalid IL or missing references)
				//IL_0175: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)swingController == (Object)null || (Object)(object)__instance.playerAvatarScript?.physGrabber == (Object)null || SwingKey == null)
				{
					return true;
				}
				bool flag = SemiFunc.InputHold((InputKey)10);
				bool keyDown = Input.GetKeyDown(SwingKey.Value);
				bool keyUp = Input.GetKeyUp(SwingKey.Value);
				if (keyDown && !flag && !swingController.IsSwinging())
				{
					ManualLogSource? loggerInstance = LoggerInstance;
					if (loggerInstance != null)
					{
						loggerInstance.LogDebug((object)$"Swing key ({SwingKey.Value}) pressed DOWN while LMB not held. Attempting swing start.");
					}
					swingController.TryStartSwing(__instance.playerAvatarScript.physGrabber);
				}
				if (keyUp && swingController.IsSwinging())
				{
					ManualLogSource? loggerInstance2 = LoggerInstance;
					if (loggerInstance2 != null)
					{
						loggerInstance2.LogDebug((object)$"Swing key ({SwingKey.Value}) released UP while swinging. Initiating jump-off.");
					}
					swingController.JumpOffLine();
				}
				if (swingController.IsSwinging())
				{
					if (SemiFunc.InputDown((InputKey)1))
					{
						ManualLogSource? loggerInstance3 = LoggerInstance;
						if (loggerInstance3 != null)
						{
							loggerInstance3.LogDebug((object)"Blocked normal jump while swinging.");
						}
						return false;
					}
					if (!Input.GetKey(SwingKey.Value) && !Input.GetKeyDown(SwingKey.Value) && !Input.GetKeyUp(SwingKey.Value))
					{
					}
				}
				if (SemiFunc.InputDown((InputKey)10) && swingController.IsTryingToSwing())
				{
					ManualLogSource? loggerInstance4 = LoggerInstance;
					if (loggerInstance4 != null)
					{
						loggerInstance4.LogDebug((object)"LMB pressed while trying to swing with RMB, cancelling swing attempt.");
					}
					swingController.CancelSwingAttempt();
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(PhysGrabber))]
		private class PhysGrabberPatches
		{
			[HarmonyPatch(typeof(PhysGrabber), "PhysGrabBeamActivate")]
			[HarmonyPrefix]
			private static bool PhysGrabBeamActivate_Prefix(PhysGrabber __instance)
			{
				if ((Object)(object)swingController != (Object)null && swingController.IsSwinging())
				{
					ManualLogSource? loggerInstance = LoggerInstance;
					if (loggerInstance != null)
					{
						loggerInstance.LogDebug((object)"PhysGrabBeamActivate blocked because Swing System is active.");
					}
					return false;
				}
				return true;
			}

			[HarmonyPatch(typeof(PhysGrabber), "PhysGrabBeamDeactivate")]
			[HarmonyPrefix]
			private static bool PhysGrabBeamDeactivate_Prefix(PhysGrabber __instance)
			{
				if ((Object)(object)swingController != (Object)null && swingController.IsSwinging())
				{
					ManualLogSource? loggerInstance = LoggerInstance;
					if (loggerInstance != null)
					{
						loggerInstance.LogDebug((object)"PhysGrabBeamDeactivate blocked because Swing System is active.");
					}
					return false;
				}
				return true;
			}
		}

		public static ConfigEntry<float>? MaxSwingDistance;

		public static ConfigEntry<float>? SwingForceMultiplier;

		public static ConfigEntry<float>? UpwardsForceMultiplier;

		public static ConfigEntry<float>? JointSpring;

		public static ConfigEntry<float>? JointDamper;

		public static ConfigEntry<float>? JointMassScale;

		public static ConfigEntry<KeyCode>? SwingKey;

		private static ManualLogSource? modLogger;

		public static SwingSystemController? swingController;

		private readonly Harmony harmony = new Harmony("com.BellaModsGames.reposwingsystem");

		public static ManualLogSource? LoggerInstance => modLogger;

		public static Plugin? Instance { get; private set; }

		private void Awake()
		{
			Instance = this;
			modLogger = Logger.CreateLogSource("SwingSystem");
			MaxSwingDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Physics", "MaxSwingDistance", 30f, "How far the swing can reach.");
			SwingForceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Physics", "SwingForceMultiplier", 50f, "How much directional input affects swing speed.");
			UpwardsForceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Physics", "UpwardsForceMultiplier", 10f, "Extra boost when pressing forward while looking up.");
			JointSpring = ((BaseUnityPlugin)this).Config.Bind<float>("Physics", "JointSpring", 8f, "Springiness of the swing joint.");
			JointDamper = ((BaseUnityPlugin)this).Config.Bind<float>("Physics", "JointDamper", 5f, "Damping resistance of the swing joint.");
			JointMassScale = ((BaseUnityPlugin)this).Config.Bind<float>("Physics", "JointMassScale", 5f, "How much the joint ignores player mass (higher = feels stronger).");
			SwingKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "SwingKey", (KeyCode)324, "Key to hold for swinging (only works if Grab key is not held).");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Applying Swing System Mod patches...");
			harmony.PatchAll(typeof(Plugin).Assembly);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Swing System Mod Patches Applied!");
		}
	}
	public class SwingSystemController : MonoBehaviour
	{
		private float maxSwingDistance = 30f;

		private float swingForceMultiplier = 50f;

		private float upwardsForceMultiplier = 10f;

		private float jointSpring = 8f;

		private float jointDamper = 5f;

		private float jointMassScale = 5f;

		private const float MIN_LINE_LENGTH = 2f;

		private PlayerController? playerController;

		private PhysGrabber? physGrabber;

		private Rigidbody? playerRb;

		private Camera? playerCamera;

		private SpringJoint? swingJoint;

		private bool isSwinging = false;

		private bool isAttemptingSwing = false;

		private Vector3 swingAnchorPoint;

		private LayerMask swingableLayers;

		private void Awake()
		{
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).TryGetComponent<PlayerController>(ref playerController);
			((Component)this).TryGetComponent<Rigidbody>(ref playerRb);
			playerCamera = Camera.main;
			if ((Object)(object)playerController == (Object)null)
			{
				ManualLogSource? loggerInstance = Plugin.LoggerInstance;
				if (loggerInstance != null)
				{
					loggerInstance.LogError((object)"PlayerController not found!");
				}
			}
			if ((Object)(object)playerRb == (Object)null)
			{
				ManualLogSource? loggerInstance2 = Plugin.LoggerInstance;
				if (loggerInstance2 != null)
				{
					loggerInstance2.LogError((object)"Player Rigidbody not found!");
				}
			}
			if ((Object)(object)playerCamera == (Object)null)
			{
				ManualLogSource? loggerInstance3 = Plugin.LoggerInstance;
				if (loggerInstance3 != null)
				{
					loggerInstance3.LogWarning((object)"Player Camera (Camera.main) not found initially!");
				}
			}
			swingableLayers = LayerMask.op_Implicit(LayerMask.GetMask(new string[3] { "Default", "Environment", "NavmeshOnly" }));
		}

		public void Configure(float maxDist, float swingForce, float upForce, float spring, float damper, float massScale)
		{
			maxSwingDistance = maxDist;
			swingForceMultiplier = swingForce;
			upwardsForceMultiplier = upForce;
			jointSpring = spring;
			jointDamper = damper;
			jointMassScale = massScale;
			ManualLogSource? loggerInstance = Plugin.LoggerInstance;
			if (loggerInstance != null)
			{
				loggerInstance.LogInfo((object)$"Swing Controller Configured: MaxDist={maxDist}, SwingForce={swingForce}");
			}
		}

		private void Update()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			if (isSwinging && (Object)(object)physGrabber != (Object)null)
			{
				if ((Object)(object)physGrabber.physGrabPoint != (Object)null)
				{
					physGrabber.physGrabPoint.position = swingAnchorPoint;
				}
				if ((Object)(object)physGrabber.physGrabPointPuller != (Object)null)
				{
					physGrabber.physGrabPointPuller.position = swingAnchorPoint;
				}
			}
		}

		public void ApplySwingPhysics()
		{
			if (isSwinging)
			{
				ApplySwingForce();
			}
		}

		public void TryStartSwing(PhysGrabber grabberInstance)
		{
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)playerController == (Object)null || (Object)(object)playerController.playerAvatarScript == (Object)null || isSwinging || isAttemptingSwing || playerController.playerAvatarScript.isTumbling || (Object)(object)grabberInstance == (Object)null)
			{
				return;
			}
			if ((Object)(object)physGrabber == (Object)null)
			{
				physGrabber = grabberInstance;
			}
			if ((Object)(object)playerCamera == (Object)null)
			{
				playerCamera = Camera.main;
			}
			if ((Object)(object)playerCamera == (Object)null)
			{
				ManualLogSource? loggerInstance = Plugin.LoggerInstance;
				if (loggerInstance != null)
				{
					loggerInstance.LogError((object)"Cannot find player camera for swinging!");
				}
				return;
			}
			isAttemptingSwing = true;
			ManualLogSource? loggerInstance2 = Plugin.LoggerInstance;
			if (loggerInstance2 != null)
			{
				loggerInstance2.LogDebug((object)"TryStartSwing: Performing Raycast...");
			}
			RaycastHit val = default(RaycastHit);
			if (Physics.Raycast(((Component)playerCamera).transform.position, ((Component)playerCamera).transform.forward, ref val, maxSwingDistance, LayerMask.op_Implicit(swingableLayers)))
			{
				if (((1 << ((Component)((RaycastHit)(ref val)).collider).gameObject.layer) & ((LayerMask)(ref swingableLayers)).value) != 0 && !((Component)((RaycastHit)(ref val)).collider).CompareTag("Player") && !((Component)((RaycastHit)(ref val)).collider).CompareTag("Enemy") && !((Component)((RaycastHit)(ref val)).collider).CompareTag("Phys Grab Object"))
				{
					if (!SemiFunc.InputHold((InputKey)10))
					{
						ManualLogSource? loggerInstance3 = Plugin.LoggerInstance;
						if (loggerInstance3 != null)
						{
							loggerInstance3.LogInfo((object)$"Swing target found: {((Object)((RaycastHit)(ref val)).collider).name} at {((RaycastHit)(ref val)).point}. Initiating swing.");
						}
						StartSwing(((RaycastHit)(ref val)).point, grabberInstance);
					}
					else
					{
						ManualLogSource? loggerInstance4 = Plugin.LoggerInstance;
						if (loggerInstance4 != null)
						{
							loggerInstance4.LogDebug((object)"Swing target found, but LMB was pressed before swing could start. Aborting.");
						}
					}
				}
				else
				{
					ManualLogSource? loggerInstance5 = Plugin.LoggerInstance;
					if (loggerInstance5 != null)
					{
						loggerInstance5.LogDebug((object)("Swing raycast hit invalid target: " + ((Object)((RaycastHit)(ref val)).collider).name + " (Layer: " + LayerMask.LayerToName(((Component)((RaycastHit)(ref val)).collider).gameObject.layer) + ") or Tag: " + ((Component)((RaycastHit)(ref val)).collider).tag));
					}
				}
			}
			else
			{
				ManualLogSource? loggerInstance6 = Plugin.LoggerInstance;
				if (loggerInstance6 != null)
				{
					loggerInstance6.LogDebug((object)"Swing raycast hit nothing valid.");
				}
			}
			isAttemptingSwing = false;
		}

		public void CancelSwingAttempt()
		{
			if (isAttemptingSwing)
			{
				isAttemptingSwing = false;
				ManualLogSource? loggerInstance = Plugin.LoggerInstance;
				if (loggerInstance != null)
				{
					loggerInstance.LogDebug((object)"Swing attempt explicitly cancelled.");
				}
			}
		}

		public bool IsTryingToSwing()
		{
			return isAttemptingSwing;
		}

		private void StartSwing(Vector3 anchorPosition, PhysGrabber grabberInstance)
		{
			//IL_0032: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			if (isSwinging || (Object)(object)playerController == (Object)null || (Object)(object)grabberInstance == (Object)null)
			{
				return;
			}
			physGrabber = grabberInstance;
			swingAnchorPoint = anchorPosition;
			float num = Vector3.Distance(((Component)playerController).transform.position, swingAnchorPoint);
			if (num < 2f)
			{
				ManualLogSource? loggerInstance = Plugin.LoggerInstance;
				if (loggerInstance != null)
				{
					loggerInstance.LogInfo((object)"Swing target too close.");
				}
				return;
			}
			isSwinging = true;
			isAttemptingSwing = false;
			ManualLogSource? loggerInstance2 = Plugin.LoggerInstance;
			if (loggerInstance2 != null)
			{
				loggerInstance2.LogInfo((object)$"Starting swing at {anchorPosition}");
			}
			ManualLogSource? loggerInstance3 = Plugin.LoggerInstance;
			if (loggerInstance3 != null)
			{
				loggerInstance3.LogDebug((object)"Activating PhysGrabber visuals for swing...");
			}
			if ((Object)(object)physGrabber.physGrabPoint != (Object)null)
			{
				physGrabber.physGrabPoint.position = swingAnchorPoint;
				((Component)physGrabber.physGrabPoint).gameObject.SetActive(true);
			}
			if ((Object)(object)physGrabber.physGrabPointPuller != (Object)null)
			{
				physGrabber.physGrabPointPuller.position = swingAnchorPoint;
			}
			if ((Object)(object)physGrabber.physGrabBeam != (Object)null)
			{
				physGrabber.physGrabBeam.SetActive(true);
			}
			if ((Object)(object)swingJoint != (Object)null)
			{
				Object.Destroy((Object)(object)swingJoint);
			}
			swingJoint = ((Component)this).gameObject.AddComponent<SpringJoint>();
			((Joint)swingJoint).autoConfigureConnectedAnchor = false;
			((Joint)swingJoint).connectedAnchor = swingAnchorPoint;
			swingJoint.maxDistance = num;
			swingJoint.minDistance = 1f;
			swingJoint.spring = jointSpring;
			swingJoint.damper = jointDamper;
			((Joint)swingJoint).massScale = jointMassScale;
			((Joint)swingJoint).enableCollision = false;
			if ((Object)(object)playerController.CollisionController != (Object)null)
			{
				playerController.CollisionController.Grounded = false;
			}
			if ((Object)(object)playerController.CollisionGrounded != (Object)null)
			{
				playerController.CollisionGrounded.Grounded = false;
			}
			playerController.CanLand = false;
			Sound startSound = physGrabber.startSound;
			if (startSound != null)
			{
				startSound.Play(physGrabber.grabberAudioTransform.position, 1f, 1f, 1f, 1f);
			}
		}

		public void StopSwing(bool performJump = false)
		{
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			if (!isSwinging)
			{
				return;
			}
			ManualLogSource? loggerInstance = Plugin.LoggerInstance;
			if (loggerInstance != null)
			{
				loggerInstance.LogInfo((object)$"Stopping swing. Perform Jump: {performJump}");
			}
			isSwinging = false;
			isAttemptingSwing = false;
			ManualLogSource? loggerInstance2 = Plugin.LoggerInstance;
			if (loggerInstance2 != null)
			{
				loggerInstance2.LogDebug((object)"Deactivating PhysGrabber visuals used for swing...");
			}
			if ((Object)(object)physGrabber?.physGrabBeam != (Object)null)
			{
				physGrabber.physGrabBeam.SetActive(false);
			}
			if ((Object)(object)physGrabber?.physGrabPoint != (Object)null)
			{
				((Component)physGrabber.physGrabPoint).gameObject.SetActive(false);
			}
			PhysGrabber? obj = physGrabber;
			if (obj != null)
			{
				Sound stopSound = obj.stopSound;
				if (stopSound != null)
				{
					stopSound.Play(physGrabber.grabberAudioTransform.position, 1f, 1f, 1f, 1f);
				}
			}
			if ((Object)(object)swingJoint != (Object)null)
			{
				Object.Destroy((Object)(object)swingJoint);
				swingJoint = null;
			}
			if ((Object)(object)playerController != (Object)null)
			{
				playerController.CanLand = true;
			}
			if (performJump && !((Object)(object)playerRb == (Object)null) && !((Object)(object)playerController?.playerAvatarScript == (Object)null))
			{
				Vector3 val = playerRb.velocity;
				Vector3 val2 = ((Vector3)(ref val)).normalized;
				if (val2 == Vector3.zero)
				{
					val2 = ((Component)playerController).transform.forward;
				}
				Vector3 val3 = Vector3.up * (playerController.JumpForce * 0.5f);
				val = val2 + val3;
				Vector3 val4 = ((Vector3)(ref val)).normalized * playerController.JumpForce;
				playerRb.AddForce(val4, (ForceMode)1);
				PlayerAvatar playerAvatarScript = playerController.playerAvatarScript;
				if (playerAvatarScript != null)
				{
					playerAvatarScript.Jump(false);
				}
				CameraJump instance = CameraJump.instance;
				if (instance != null)
				{
					instance.Jump();
				}
			}
		}

		private void ApplySwingForce()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: 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_0071: 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_0082: 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_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: 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)
			if (!isSwinging || (Object)(object)playerRb == (Object)null || (Object)(object)playerController == (Object)null)
			{
				return;
			}
			Vector3 inputDirection = playerController.InputDirection;
			if (((Vector3)(ref inputDirection)).magnitude < 0.1f)
			{
				return;
			}
			Vector3 val = ((Component)playerController).transform.forward * inputDirection.z;
			Vector3 val2 = ((Component)playerController).transform.right * inputDirection.x;
			Vector3 val3 = val + val2;
			Vector3 normalized = ((Vector3)(ref val3)).normalized;
			playerRb.AddForce(normalized * swingForceMultiplier, (ForceMode)0);
			if (inputDirection.z > 0.1f && (Object)(object)playerCamera != (Object)null)
			{
				float num = Vector3.Dot(((Component)playerCamera).transform.forward, Vector3.up);
				if (num > 0.3f)
				{
					playerRb.AddForce(Vector3.up * upwardsForceMultiplier * num, (ForceMode)0);
				}
			}
		}

		public void JumpOffLine()
		{
			StopSwing(performJump: true);
		}

		public bool IsSwinging()
		{
			return isSwinging;
		}
	}
}