using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BBModMenu;
using MelonLoader;
using NoClip;
using UnityEngine;
using UnityEngine.UIElements;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(NoClipMod), "NoClip", "1.0.0", "Bowilla", null)]
[assembly: MelonGame("", "Beton Brutal")]
[assembly: AssemblyTitle("NoClip")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NoClip")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("2d27f64d-e62f-4b77-a074-e7dc03a1dd67")]
[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 NoClip;
public class NoClipMod : MelonMod
{
private CapsuleCollider collider;
private string noclipKey;
private bool toggle;
public override void OnLateInitializeMelon()
{
MelonLogger.Msg("NoClip starting to load.");
GameObject val = GameObject.Find("GameUI");
GameUI component = val.GetComponent<GameUI>();
UIScreen? obj = ((typeof(GameUI)?.GetField("screens", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(component) is List<UIScreen> source) ? ((IEnumerable<UIScreen>)source).FirstOrDefault((Func<UIScreen, bool>)((UIScreen screen) => screen is ModMenu)) : null);
ModMenu val2 = (ModMenu)(object)((obj is ModMenu) ? obj : null);
if (val2 == null)
{
MelonLogger.Msg("ModMenu not found");
return;
}
string text = "NoClip";
VisualElement val3 = val2.AddSetting(text);
Toggle val4 = val2.CreateToggle(text, "EnabledOnStart", true);
HotKeyEntry val5 = val2.CreateHotKey(text, "NoClipKey", (KeyCode)110);
noclipKey = val5.Value;
val5.OnChanged = (Action<string>)Delegate.Combine(val5.OnChanged, (Action<string>)delegate(string newKey)
{
MelonLogger.Msg("NoClip Key : " + newKey);
noclipKey = newKey;
});
VisualElement val6 = val2.CreateGroup("Toggles");
VisualElement val7 = val2.CreateWrapper();
val7.Add((VisualElement)(object)val2.CreateLabel("Enabled on Start"));
val7.Add((VisualElement)(object)val4);
VisualElement val8 = val2.CreateWrapper();
val8.Add((VisualElement)(object)val2.CreateLabel("NoClip Toggle Key"));
val8.Add(val5.Root);
val6.Add(val7);
val6.Add(val8);
val3.Add(val6);
collider = ((Component)Object.FindObjectOfType<PlayerController>()).GetComponent<CapsuleCollider>();
toggle = !((BaseField<bool>)(object)val4).value;
}
public override void OnUpdate()
{
if (Utils.IsHotkeyPressed(noclipKey))
{
toggle = !toggle;
}
if (GameModeManager.Instance.IsGameModeActive<MapEditorGameMode>() && GameModeManager.Instance.player.IsFlying)
{
((Collider)collider).enabled = toggle;
}
else
{
((Collider)collider).enabled = true;
}
}
}