Decompiled source of SO Noclip v1.0.0

SONoclip.dll

Decompiled 6 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using SONoclip;
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("SONoclip")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SONoclip")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("6ab95881-759d-4957-8b53-4f41ce938ba2")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
public class NoclipPatch : MonoBehaviour
{
	private CharacterController characterController;

	private Rigidbody rb;

	private bool isNoClip;

	public float flySpeed = 10f;

	private void Start()
	{
		characterController = ((Component)this).GetComponent<CharacterController>();
		rb = ((Component)this).GetComponent<Rigidbody>();
	}

	private void Update()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		if (Input.GetKeyDown(NoClip.noclipToggleKey.Value))
		{
			ToggleNoClip();
		}
		if (isNoClip)
		{
			FlyMovement();
		}
	}

	private void ToggleNoClip()
	{
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		isNoClip = !isNoClip;
		if (isNoClip)
		{
			if (Object.op_Implicit((Object)(object)characterController))
			{
				((Collider)characterController).enabled = false;
			}
			if (Object.op_Implicit((Object)(object)rb))
			{
				rb.useGravity = false;
				rb.velocity = Vector3.zero;
				rb.isKinematic = true;
			}
		}
		else
		{
			if (Object.op_Implicit((Object)(object)characterController))
			{
				((Collider)characterController).enabled = true;
			}
			if (Object.op_Implicit((Object)(object)rb))
			{
				rb.useGravity = true;
				rb.isKinematic = false;
			}
		}
	}

	private void FlyMovement()
	{
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: 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: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		float axis = Input.GetAxis("Horizontal");
		float axis2 = Input.GetAxis("Vertical");
		float num = 0f;
		if (Input.GetKey(NoClip.noclipUpKey.Value))
		{
			num = 1f;
		}
		if (Input.GetKey(NoClip.noclipDownKey.Value))
		{
			num = -1f;
		}
		Vector3 val = ((Component)this).transform.right * axis + ((Component)this).transform.forward * axis2 + ((Component)this).transform.up * num;
		Transform transform = ((Component)this).transform;
		transform.position += val * flySpeed * Time.deltaTime;
	}
}
namespace SONoclip;

[BepInPlugin("SoloOne.NoClipPlugin", "SO Noclip", "1.0.0")]
public class NoClip : BaseUnityPlugin
{
	private const string modguid = "SoloOne.NoClipPlugin";

	private const string modname = "SO Noclip";

	private const string modversion = "1.0.0";

	private readonly Harmony harmony = new Harmony("SoloOne.NoClipPlugin");

	public static ConfigEntry<KeyCode> noclipToggleKey;

	public static ConfigEntry<KeyCode> noclipUpKey;

	public static ConfigEntry<KeyCode> noclipDownKey;

	private void Awake()
	{
		noclipToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "ToggleNoclip", (KeyCode)105, "Key to toggle noclip");
		noclipUpKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "MoveUpKey", (KeyCode)121, "Key to move up in noclip mode");
		noclipDownKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "MoveDownKey", (KeyCode)104, "Key to move down in noclip mode");
		harmony.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"SO Noclip v1.0.0 loaded!");
	}
}
[HarmonyPatch(typeof(PlayerController), "Start")]
public class NoClipPatch
{
	private static void Postfix(PlayerController __instance)
	{
		((Component)__instance).gameObject.AddComponent<NoclipPatch>();
		Debug.Log((object)"NoClip component added to PlayerController.");
	}
}