Decompiled source of FlyMode v1.0.0

FlyMod.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;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("FlyMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("DESKTOP-")]
[assembly: AssemblyProduct("FlyMod")]
[assembly: AssemblyCopyright("Copyright © DESKTOP- 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("11fc7f41-185a-4476-822d-665d4c5c4065")]
[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 FlyMod;

[BepInPlugin("com.mathis.flymod", "Fly Mod", "1.0.0")]
public class FlyModPlugin : BaseUnityPlugin
{
	private void Awake()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		Harmony val = new Harmony("com.mathis.flymod");
		val.PatchAll(Assembly.GetExecutingAssembly());
		((BaseUnityPlugin)this).Logger.LogInfo((object)"[FlyMod] Patch Harmony appliqué.");
	}
}
[HarmonyPatch(typeof(Character), "Update")]
public class FlyPatch
{
	private static bool isFlying = false;

	private static Vector3 flyVelocity = Vector3.zero;

	private static float flySpeed = 100f;

	private static float acceleration = 300f;

	private static void Postfix(Character __instance)
	{
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0141: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: 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_0158: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: 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_0162: Unknown result type (might be due to invalid IL or missing references)
		//IL_0167: 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_0169: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: 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)
		//IL_017b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0180: Unknown result type (might be due to invalid IL or missing references)
		//IL_0185: Unknown result type (might be due to invalid IL or missing references)
		//IL_0197: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: Unknown result type (might be due to invalid IL or missing references)
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c7: 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_01e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e6: 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)
		//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bf: 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)
		if (!__instance.IsLocal || (Object)(object)__instance.refs?.ragdoll == (Object)null)
		{
			return;
		}
		if (Input.GetKeyDown((KeyCode)287))
		{
			isFlying = !isFlying;
			flyVelocity = Vector3.zero;
			foreach (Bodypart part in __instance.refs.ragdoll.partList)
			{
				if ((Object)(object)((part != null) ? part.Rig : null) != (Object)null)
				{
					part.Rig.useGravity = !isFlying;
				}
			}
			string text = (isFlying ? "activé" : "désactivé");
			Debug.Log((object)("[FlyMod] Mode vol " + text));
		}
		if (!isFlying)
		{
			return;
		}
		__instance.data.isGrounded = true;
		__instance.data.sinceGrounded = 0f;
		__instance.data.sinceJump = 0f;
		Vector3 val = Vector2.op_Implicit(__instance.input.movementInput);
		Vector3 normalized = ((Vector3)(ref __instance.data.lookDirection_Flat)).normalized;
		Vector3 val2 = Vector3.Cross(Vector3.up, normalized);
		Vector3 normalized2 = ((Vector3)(ref val2)).normalized;
		Vector3 val3 = normalized * val.y + normalized2 * val.x;
		if (__instance.input.jumpIsPressed)
		{
			val3 += Vector3.up;
		}
		if (__instance.input.crouchIsPressed)
		{
			val3 += Vector3.down;
		}
		flyVelocity = Vector3.Lerp(flyVelocity, ((Vector3)(ref val3)).normalized * flySpeed, Time.deltaTime * acceleration);
		foreach (Bodypart part2 in __instance.refs.ragdoll.partList)
		{
			if ((Object)(object)((part2 != null) ? part2.Rig : null) != (Object)null)
			{
				part2.Rig.linearVelocity = flyVelocity;
			}
		}
	}
}