Decompiled source of BunnyHop v1.0.0

BunnyHop.dll

Decompiled 3 days ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityStandardAssets.Characters.FirstPerson;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("BunnyHop")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BunnyHop")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b60e1856-2a5a-4a94-bbe9-ff3d1effc8a3")]
[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 BunnyHop;

[BepInPlugin("ru.mxyfell.kek", "BunnyHop", "1.0.0")]
public class BunnyHop : BaseUnityPlugin
{
	private FirstPersonController FPS;

	private Cheats cheats;

	private string CurScene;

	private static FieldInfo pressingJumpField;

	private static FieldInfo RunSpeedField;

	private static FieldInfo charControllerField;

	private bool pressingJump;

	private Vector3 previousPosition;

	private float currentVelocity;

	private Vector3 previousCameraForward;

	private float turnSpeed;

	private float newSpeed;

	private float smoothedVelocity;

	private float speedBonus;

	private void OnEnable()
	{
		SceneManager.sceneLoaded += OnSceneLoaded;
	}

	private void OnDisable()
	{
		SceneManager.sceneLoaded -= OnSceneLoaded;
	}

	private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
	{
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		if (((Scene)(ref scene)).name != "menus")
		{
			CurScene = ((Scene)(ref scene)).name;
			GameObject obj = GameObject.FindWithTag("Player");
			FPS = ((obj != null) ? obj.GetComponent<FirstPersonController>() : null);
			GameObject obj2 = GameObject.FindWithTag("Player");
			cheats = ((obj2 != null) ? obj2.GetComponent<Cheats>() : null);
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
			pressingJumpField = typeof(FirstPersonController).GetField("pressingJump", BindingFlags.Instance | BindingFlags.NonPublic);
			RunSpeedField = typeof(FirstPersonController).GetField("m_RunSpeed", BindingFlags.Instance | BindingFlags.NonPublic);
			charControllerField = typeof(FirstPersonController).GetField("m_CharacterController", BindingFlags.Instance | BindingFlags.NonPublic);
			if ((Object)(object)FPS != (Object)null)
			{
				previousPosition = ((Component)FPS).transform.position;
			}
			cheats.CheatsActivated = true;
		}
	}

	private void OnGUI()
	{
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Expected O, but got Unknown
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Expected O, but got Unknown
		//IL_0094: 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)
		if (CurScene != "menus" && (Object)(object)FPS != (Object)null)
		{
			_ = FPS.m_MoveDir;
			if (true)
			{
				Texture2D val = new Texture2D(1, 1);
				val.SetPixel(0, 0, new Color(0f, 0f, 0f, 0.5f));
				val.Apply();
				GUIStyle val2 = new GUIStyle();
				val2.fontSize = 30;
				val2.fontStyle = (FontStyle)1;
				val2.normal.background = val;
				val2.normal.textColor = Color.yellow;
				val2.alignment = (TextAnchor)4;
				GUI.Box(new Rect((float)(Screen.width / 2 - 175), (float)(Screen.height - 100), 350f, 50f), $"velocity: {currentVelocity:F2}", val2);
			}
		}
	}

	private void Update()
	{
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: 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_0087: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		if (CurScene != "menus" && (Object)(object)FPS != (Object)null && RunSpeedField != null)
		{
			Vector3 position = ((Component)FPS).transform.position;
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(position.x - previousPosition.x, 0f, position.z - previousPosition.z);
			float num = ((Vector3)(ref val)).magnitude / Time.deltaTime;
			previousPosition = position;
			smoothedVelocity = Mathf.Lerp(smoothedVelocity, num, Time.deltaTime / 0.1f);
			currentVelocity = smoothedVelocity;
			smoothedVelocity = Mathf.Lerp(smoothedVelocity, num, Time.deltaTime / 0.1f);
			currentVelocity = smoothedVelocity;
			Vector3 forward = ((Component)FPS.GetMainCamera()).transform.forward;
			forward.y = 0f;
			((Vector3)(ref forward)).Normalize();
			if (previousCameraForward != Vector3.zero)
			{
				float num2 = Vector3.Angle(previousCameraForward, forward);
				turnSpeed = num2 / Time.deltaTime;
			}
			previousCameraForward = forward;
			float runSpeed = FPS.GetRunSpeed();
			if (turnSpeed < 2500f)
			{
				speedBonus = turnSpeed * 0.00025f;
			}
			newSpeed = runSpeed + speedBonus;
			float num3 = FPS.m_MoveDir.x + FPS.m_MoveDir.z;
			if (!FPS.IsGrounded() && num3 != 0f && runSpeed < 80f)
			{
				FPS.SetRunSpeed(newSpeed);
			}
			pressingJump = (bool)pressingJumpField.GetValue(FPS);
			if (FPS.IsGrounded() && pressingJump && !FPS.m_Jump)
			{
				FPS.m_Jump = true;
			}
			else if (FPS.IsGrounded() && !pressingJump && !FPS.m_Jump)
			{
				FPS.SetRunSpeed(10f);
			}
		}
	}
}