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 int FallCooldown = 0;
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_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: 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_0190: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: 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_01df: Unknown result type (might be due to invalid IL or missing references)
//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
//IL_020a: Unknown result type (might be due to invalid IL or missing references)
//IL_021d: Unknown result type (might be due to invalid IL or missing references)
//IL_0222: 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_0233: Unknown result type (might be due to invalid IL or missing references)
//IL_0259: Unknown result type (might be due to invalid IL or missing references)
//IL_026c: 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_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_02a3: 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_02af: Unknown result type (might be due to invalid IL or missing references)
//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
//IL_02df: 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_02eb: Unknown result type (might be due to invalid IL or missing references)
//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
//IL_0385: 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 = 0f;
__instance.movementSpeed = 0.5f;
Noclip.FallCooldown = 1500;
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);
}
}
if (Noclip.FallCooldown > 1)
{
__instance.takingFallDamage = false;
Noclip.FallCooldown--;
}
else if (Noclip.FallCooldown == 1)
{
Noclip.FallCooldown--;
Noclip.Logs.LogMessage((object)"Fall Damage Cooldown Over!");
}
}
}