Decompiled source of BetterMovement v1.0.0

MiSide.Plugin.BetterMovement.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using PhotoModeActive.Patches;
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("MiSide.Plugin.BetterMovement")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MiSide.Plugin.BetterMovement")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("15c5350c-7ca4-4acc-bcab-723959c43aad")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace PhotoModeActive
{
	[BepInPlugin("juzlus.miside.bettermovement", "Better Movement", "1.0.0")]
	[BepInProcess("MiSideFull.exe")]
	public class Plugin : BasePlugin
	{
		private const string gameName = "MiSideFull.exe";

		private const string pluginGuild = "juzlus.miside.bettermovement";

		private const string pluginName = "Better Movement";

		private const string pluginVersion = "1.0.0";

		private ConfigEntry<bool> infinityJumpsConfig;

		public static bool infinityJumps = false;

		private ConfigEntry<string> infinityJumpsKeyConfig;

		public static KeyCode infinityJumpsKey = (KeyCode)289;

		private ConfigEntry<float> jumpForceConfig;

		public static float jumpForce = 50f;

		public static ManualLogSource logSource;

		public override void Load()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			logSource = ((BasePlugin)this).Log;
			logSource.LogInfo((object)"Plugin juzlus.miside.bettermovement is loaded!");
			Harmony val = new Harmony("juzlus.miside.bettermovement");
			val.PatchAll(typeof(PlayerMovePath));
			infinityJumpsConfig = ((BasePlugin)this).Config.Bind<bool>("General", "InfinityJumps", false, "Infinite jumps enabled at startup.");
			infinityJumps = infinityJumpsConfig.Value;
			infinityJumpsKeyConfig = ((BasePlugin)this).Config.Bind<string>("General", "InfinityJumpsKey", "F8", "Key bind to toggle the infinite jumps feature.");
			infinityJumpsKey = (KeyCode)Enum.Parse(typeof(KeyCode), infinityJumpsKeyConfig.Value);
			jumpForceConfig = ((BasePlugin)this).Config.Bind<float>("General", "JumpForce", 50f, "Sets the force applied when jumping.");
			jumpForce = jumpForceConfig.Value;
			logSource.LogMessage((object)("Infinity Jumps : " + infinityJumps + ", Jump Force : " + jumpForce));
			logSource.LogMessage((object)("Infinity Jumps Key -> " + ((object)(KeyCode)(ref infinityJumpsKey)).ToString()));
		}
	}
}
namespace PhotoModeActive.Patches
{
	[HarmonyPatch(typeof(PlayerMove))]
	internal class PlayerMovePath
	{
		private static GameObject plane;

		private static bool isReset = true;

		private static float cooldownJump = 3f;

		private static float cooldownTimer;

		private static string planeName = "JumpGround";

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		private static void AwakePostfix(PlayerMove __instance)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			plane = GameObject.CreatePrimitive((PrimitiveType)4);
			plane.transform.parent = ((Component)__instance).transform;
			((Object)plane).name = planeName;
			plane.transform.localPosition = new Vector3(0f, 0f, -0.05f);
			plane.transform.localScale = new Vector3(0.04f, 5f, 0.04f);
			plane.AddComponent<ObjectMaterial>();
			BoxCollider val = plane.AddComponent<BoxCollider>();
			((Collider)val).isTrigger = true;
			Rigidbody val2 = plane.AddComponent<Rigidbody>();
			val2.isKinematic = true;
			MeshRenderer component = plane.GetComponent<MeshRenderer>();
			((Renderer)component).castShadows = false;
			Object.Destroy((Object)(object)plane.GetComponent<MeshFilter>());
			Object.Destroy((Object)(object)plane.GetComponent<MeshRenderer>());
			Object.Destroy((Object)(object)plane.GetComponent<MeshCollider>());
		}

		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void UpdatePostfix(PlayerMove __instance)
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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_015d: Unknown result type (might be due to invalid IL or missing references)
			__instance.canRun = true;
			__instance.canSit = true;
			Collider val = null;
			if (Object.op_Implicit((Object)(object)plane))
			{
				Collider[] source = Il2CppArrayBase<Collider>.op_Implicit((Il2CppArrayBase<Collider>)(object)Physics.OverlapBox(plane.transform.position, new Vector3(0.1f, 0.1f, 0.1f)));
				val = ((IEnumerable<Collider>)source).FirstOrDefault((Func<Collider, bool>)((Collider c) => ((Object)((Component)c).gameObject).name != planeName && ((Object)((Component)c).gameObject).name != "Player" && ((Component)c).gameObject.layer == 0));
			}
			if (Input.GetKeyDown(Plugin.infinityJumpsKey))
			{
				Plugin.logSource.LogInfo((object)("Infinity jumps changed : " + Plugin.infinityJumps + " -> " + !Plugin.infinityJumps));
				Plugin.infinityJumps = !Plugin.infinityJumps;
			}
			if (isReset)
			{
				if (Object.op_Implicit((Object)(object)plane))
				{
					plane.SetActive(false);
				}
				if (Object.op_Implicit((Object)(object)val) && cooldownTimer <= 0f)
				{
					isReset = false;
				}
				cooldownTimer -= Time.deltaTime;
				return;
			}
			if (Input.GetKeyDown((KeyCode)32) && (Object.op_Implicit((Object)(object)val) || Plugin.infinityJumps))
			{
				__instance.rb.AddForce(Vector3.up * Plugin.jumpForce, (ForceMode)1);
			}
			if (Object.op_Implicit((Object)(object)plane))
			{
				if (!Object.op_Implicit((Object)(object)val))
				{
					plane.SetActive(true);
				}
				else
				{
					plane.SetActive(false);
				}
			}
		}

		[HarmonyPatch("TeleportPlayer")]
		[HarmonyPostfix]
		[HarmonyPatch(new Type[]
		{
			typeof(Vector3),
			typeof(float),
			typeof(float)
		})]
		private static void TeleportPlayerPostfix(Vector3 _position, float _rotation, float _rotationHead)
		{
			isReset = true;
			cooldownTimer = cooldownJump;
		}
	}
}