Decompiled source of Noclip Flight v1.0.0

Noclip.dll

Decompiled 5 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
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("Noclip")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Noclip")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("ad7fe647-6fb2-4394-8d7f-e2de362f285f")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Noclip;

[BepInPlugin("Rissoe.NoclipFlight", "Noclip Flight", "1.0.0")]
public class Noclip : BaseUnityPlugin
{
	public const string modGUID = "Rissoe.NoclipFlight";

	public const string modName = "Noclip Flight";

	public const string modVersion = "1.0.0";

	public static bool isNoclip = false;

	public static bool NoclipKeyPressed = false;

	public static ManualLogSource Logs = Logger.CreateLogSource("Rissoe.NoclipFlight");

	public static ConfigEntry<string> NoclipKey;

	private readonly Harmony harmony = new Harmony("Rissoe.NoclipFlight");

	private void Awake()
	{
		NoclipKey = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Noclip toggle key", "Z", "Key to use for noclip");
		if (!Enum.TryParse<KeyCode>(NoclipKey.Value, out KeyCode _))
		{
			NoclipKey.Value = "Z";
		}
		harmony.PatchAll(typeof(Clip));
		Logs.LogMessage((object)"Rissoe.NoclipFlight has clipped into the code.");
	}
}
[HarmonyPatch(typeof(PlayerControllerB))]
[HarmonyPatch("Update")]
internal class Clip
{
	[HarmonyPostfix]
	private static void Postfix(ref PlayerControllerB __instance)
	{
		//IL_013d: 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_0167: 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_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_0186: 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_01b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d0: 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_01da: Unknown result type (might be due to invalid IL or missing references)
		//IL_0200: 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_0218: Unknown result type (might be due to invalid IL or missing references)
		//IL_021f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0224: 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_024f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0262: Unknown result type (might be due to invalid IL or missing references)
		//IL_0269: Unknown result type (might be due to invalid IL or missing references)
		//IL_026e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0273: Unknown result type (might be due to invalid IL or missing references)
		//IL_0299: Unknown result type (might be due to invalid IL or missing references)
		//IL_029b: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_02af: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_037b: Unknown result type (might be due to invalid IL or missing references)
		if (UnityInput.Current.GetKeyDown(Noclip.NoclipKey.Value) && !Noclip.isNoclip && !Noclip.NoclipKeyPressed)
		{
			Noclip.isNoclip = true;
			__instance.movementSpeed = 0f;
			Noclip.Logs.LogMessage((object)"Noclip Enabled!");
		}
		else if (UnityInput.Current.GetKeyDown(Noclip.NoclipKey.Value) && Noclip.isNoclip && !Noclip.NoclipKeyPressed)
		{
			Noclip.isNoclip = false;
			__instance.fallValue = 5f;
			__instance.movementSpeed = 0.5f;
			Noclip.Logs.LogMessage((object)"Noclip Disabled!");
		}
		if (UnityInput.Current.GetKeyDown(Noclip.NoclipKey.Value))
		{
			Noclip.NoclipKeyPressed = true;
		}
		else
		{
			Noclip.NoclipKeyPressed = false;
		}
		if (Noclip.isNoclip)
		{
			__instance.fallValue = 0f;
			__instance.takingFallDamage = false;
			float num = 12f;
			if (UnityInput.Current.GetKey("LeftShift") && !Noclip.NoclipKeyPressed)
			{
				num = 4f;
			}
			Vector3 val = ((Component)__instance.playersManager.localPlayerController).transform.position;
			if (UnityInput.Current.GetKey("W") && !Noclip.NoclipKeyPressed)
			{
				val += ((Component)__instance.playersManager.localPlayerController).transform.forward / num;
			}
			if (UnityInput.Current.GetKey("A") && !Noclip.NoclipKeyPressed)
			{
				val += -((Component)__instance.playersManager.localPlayerController).transform.right / num;
			}
			if (UnityInput.Current.GetKey("S") && !Noclip.NoclipKeyPressed)
			{
				val += -((Component)__instance.playersManager.localPlayerController).transform.forward / num;
			}
			if (UnityInput.Current.GetKey("D") && !Noclip.NoclipKeyPressed)
			{
				val += ((Component)__instance.playersManager.localPlayerController).transform.right / num;
			}
			if (UnityInput.Current.GetKey("Space") && !Noclip.NoclipKeyPressed)
			{
				val += Vector3.up / 4f;
			}
			if (UnityInput.Current.GetKey("LeftControl") && !Noclip.NoclipKeyPressed)
			{
				val += Vector3.down / 4f;
			}
			if (UnityInput.Current.GetKey("W") || UnityInput.Current.GetKey("A") || UnityInput.Current.GetKey("S") || UnityInput.Current.GetKey("D") || UnityInput.Current.GetKey("Space") || UnityInput.Current.GetKey("LeftControl"))
			{
				Noclip.NoclipKeyPressed = true;
			}
			if (Noclip.NoclipKeyPressed)
			{
				__instance.playersManager.localPlayerController.TeleportPlayer(val, false, 0f, false, true);
			}
		}
	}
}