Decompiled source of BHopAgain v1.1.0

BhopAgain.dll

Decompiled 4 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BHop.Component;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("BhopAgain")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BhopAgain")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("610c8b35-b806-433b-a51d-eafec257ded9")]
[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")]
namespace BHop
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "MCFixed";

		public const string PLUGIN_NAME = "MCFixed";

		public const string PLUGIN_VERSION = "2.0.0";
	}
	[BepInPlugin("MCFixed", "MCFixed", "2.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private Harmony _harmony = new Harmony("MCFixed");

		public static ManualLogSource Log;

		public void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Hi :)");
			_harmony.PatchAll();
		}

		public void Update()
		{
			PlayerControllerB[] array = Object.FindObjectsOfType<PlayerControllerB>();
			foreach (PlayerControllerB val in array)
			{
				if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).gameObject.GetComponentInChildren<MovementScript>() == (Object)null && ((NetworkBehaviour)val).IsOwner && val.isPlayerControlled)
				{
					((Component)val).gameObject.AddComponent<MovementScript>().myPlayer = val;
					Log.LogMessage((object)"Gave player the movement script");
				}
			}
		}

		public void OnDestroy()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			GameObject val = new GameObject("MovementAdder");
			Object.DontDestroyOnLoad((Object)val);
			val.AddComponent<MovementAdder>();
		}
	}
}
namespace BHop.Component
{
	internal class MovementAdder : MonoBehaviour
	{
		private void Update()
		{
			PlayerControllerB[] array = Object.FindObjectsOfType<PlayerControllerB>();
			foreach (PlayerControllerB val in array)
			{
				if ((Object)(object)val != (Object)null && (Object)(object)((Component)val).gameObject.GetComponentInChildren<MovementScript>() == (Object)null && ((NetworkBehaviour)val).IsOwner && val.isPlayerControlled)
				{
					((Component)val).gameObject.AddComponent<MovementScript>().myPlayer = val;
					Plugin.Log.LogMessage((object)"Gave player the movement script");
				}
			}
		}
	}
	internal class MovementScript : MonoBehaviour
	{
		public PlayerControllerB myPlayer;

		private bool inAir;

		public static Vector3 wantedVelToAdd;

		public float jumpTime;

		private Vector3 previousForward;

		public void Update()
		{
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: 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_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: 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_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			myPlayer.sprintMeter = 100f;
			if (myPlayer.playerBodyAnimator.GetBool("Jumping") && jumpTime < 0.1f)
			{
				myPlayer.fallValue = myPlayer.jumpForce;
				jumpTime += Time.deltaTime * 10f;
			}
			if (!myPlayer.thisController.isGrounded && !myPlayer.isClimbingLadder)
			{
				if (!inAir)
				{
					inAir = true;
					Vector3 velocity = myPlayer.thisController.velocity;
					velocity.y = 0f;
					wantedVelToAdd += 0.0033f * velocity;
				}
				wantedVelToAdd.y = 0f;
				((Component)this).transform.InverseTransformDirection(myPlayer.thisController.velocity);
				Vector3 val2;
				if (myPlayer.moveInputVector.y > 0f)
				{
					CharacterController thisController = myPlayer.thisController;
					Vector3 val = new Vector3(((Component)myPlayer).gameObject.transform.forward.x, ((Component)myPlayer).gameObject.transform.forward.y, ((Component)myPlayer).gameObject.transform.forward.z);
					val2 = wantedVelToAdd;
					thisController.Move(val * ((Vector3)(ref val2)).magnitude);
				}
				else if (myPlayer.moveInputVector.y < 0f)
				{
					CharacterController thisController2 = myPlayer.thisController;
					Vector3 val3 = new Vector3(0f - ((Component)myPlayer).gameObject.transform.forward.x, ((Component)myPlayer).gameObject.transform.forward.y, 0f - ((Component)myPlayer).gameObject.transform.forward.z);
					val2 = wantedVelToAdd;
					thisController2.Move(val3 * ((Vector3)(ref val2)).magnitude);
				}
				Vector3 forward = ((Component)myPlayer).gameObject.transform.forward;
				Vector3 val4 = forward - previousForward;
				float num = 0.01f;
				val2 = val4;
				if (((Vector3)(ref val2)).magnitude > num)
				{
					wantedVelToAdd += new Vector3(0.0006f, 0.0006f, 0.0006f);
				}
				previousForward = forward;
			}
			else
			{
				wantedVelToAdd = Vector3.Lerp(wantedVelToAdd, Vector3.zero, Time.deltaTime * 4.2f);
				inAir = false;
				jumpTime = 0f;
			}
			_ = myPlayer.thisController.isGrounded;
		}
	}
}