using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
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("PeakNoclipMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PeakNoclipMod")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("bd05c152-3d6c-45d2-84b9-183115bc48f4")]
[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")]
[BepInPlugin("com.noclip.peak.xaxis", "PEAK X-Axis NoClip", "1.0.1")]
public class XAxisNoClip : BaseUnityPlugin
{
private bool enabledXNoClip = false;
private CharacterController controller;
private float originalRadius;
private bool controllerCached = false;
private void Update()
{
if (Input.GetKeyDown((KeyCode)110))
{
enabledXNoClip = !enabledXNoClip;
((BaseUnityPlugin)this).Logger.LogInfo((object)("X-Axis NoClip " + (enabledXNoClip ? "ENABLED" : "DISABLED")));
ApplyState();
}
CacheController();
}
private void CacheController()
{
if (controllerCached || (Object)(object)Player.localPlayer == (Object)null)
{
return;
}
GameObject gameObject = ((Component)Player.localPlayer).gameObject;
if (!((Object)(object)gameObject == (Object)null))
{
controller = gameObject.GetComponentInChildren<CharacterController>(true);
if (!((Object)(object)controller == (Object)null))
{
originalRadius = controller.radius;
controllerCached = true;
((BaseUnityPlugin)this).Logger.LogInfo((object)"CharacterController found and cached");
}
}
}
private void ApplyState()
{
if (controllerCached && !((Object)(object)controller == (Object)null))
{
controller.radius = (enabledXNoClip ? 0.01f : originalRadius);
}
}
private void OnDestroy()
{
if (controllerCached && (Object)(object)controller != (Object)null)
{
controller.radius = originalRadius;
}
}
}