using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BoneLib; using BoneLib.BoneMenu; using DevToolsHider; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSLZ.Bonelab; using Il2CppSLZ.Marrow; using Il2CppSLZ.Marrow.Interaction; using MelonLoader; using MelonLoader.Preferences; using MenuHelper; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: MelonInfo(typeof(DevToolsHiderMod), "DevToolsHider", "1.0.0", "triangle", "https://thunderstore.io/c/bonelab/p/triangle/DevToolsHider/")] [assembly: MelonGame("Stress Level Zero", "BONELAB")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("DevToolsHider")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+87b683b6255eac427b6a41c281851521d58ed894")] [assembly: AssemblyProduct("DevToolsHider")] [assembly: AssemblyTitle("DevToolsHider")] [assembly: NeutralResourcesLanguage("en-US")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace MenuHelper { public static class MenuHelper { internal static IntElement CreateIntPref(this Page page, string name, Color color, ref MelonPreferences_Entry value, int increment, int minValue, int maxValue, Action callback = null, string prefName = null, int prefDefaultValue = 0, string tooltip = null) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) return page.CreateIntPref(name, color, ref value, DevToolsHiderMod.DevToolsHider_Category, increment, minValue, maxValue, callback, prefName, prefDefaultValue, tooltip); } internal static FloatElement CreateFloatPref(this Page page, string name, Color color, ref MelonPreferences_Entry value, float increment, float minValue, float maxValue, Action callback = null, string prefName = null, float prefDefaultValue = 0f, string tooltip = null) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) return page.CreateFloatPref(name, color, ref value, DevToolsHiderMod.DevToolsHider_Category, increment, minValue, maxValue, callback, prefName, prefDefaultValue, tooltip); } internal static BoolElement CreateBoolPref(this Page page, string name, Color color, ref MelonPreferences_Entry value, Action callback = null, string prefName = null, bool prefDefaultValue = false, string tooltip = null) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) return page.CreateBoolPref(name, color, ref value, DevToolsHiderMod.DevToolsHider_Category, callback, prefName, prefDefaultValue, tooltip); } internal static EnumElement CreateEnumPref(this Page page, string name, Color color, ref MelonPreferences_Entry value, Action callback = null, string prefName = null, Enum prefDefaultValue = null, string tooltip = null) where T : Enum { //IL_0003: Unknown result type (might be due to invalid IL or missing references) return page.CreateEnumPref(name, color, ref value, DevToolsHiderMod.DevToolsHider_Category, callback, prefName, prefDefaultValue, tooltip); } internal static StringElement CreateStringPref(this Page page, string name, Color color, ref MelonPreferences_Entry value, Action callback = null, string prefName = null, string prefDefaultValue = null, string tooltip = null) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) return page.CreateStringPref(name, color, ref value, DevToolsHiderMod.DevToolsHider_Category, callback, prefName, prefDefaultValue, tooltip); } public static IntElement CreateIntPref(this Page page, string name, Color color, ref MelonPreferences_Entry value, MelonPreferences_Category prefCategory, int increment, int minValue, int maxValue, Action callback = null, string prefName = null, int prefDefaultValue = 0, string tooltip = null) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) if (prefName == null) { prefName = name; } if (!prefCategory.HasEntry(prefName)) { value = prefCategory.CreateEntry(prefName, prefDefaultValue, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); } MelonPreferences_Entry val = value; IntElement val2 = page.CreateInt(name, color, val.Value, increment, minValue, maxValue, (Action)delegate(int x) { val.Value = x; prefCategory.SaveToFile(false); Action action = callback; if (action != null) { Extensions.InvokeActionSafe(action, x); } }); ((Element)val2).ElementTooltip = tooltip; return val2; } public static FloatElement CreateFloatPref(this Page page, string name, Color color, ref MelonPreferences_Entry value, MelonPreferences_Category prefCategory, float increment, float minValue, float maxValue, Action callback = null, string prefName = null, float prefDefaultValue = 0f, string tooltip = null) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) if (prefName == null) { prefName = name; } if (!prefCategory.HasEntry(prefName)) { value = prefCategory.CreateEntry(prefName, prefDefaultValue, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); } MelonPreferences_Entry val = value; FloatElement val2 = page.CreateFloat(name, color, val.Value, increment, minValue, maxValue, (Action)delegate(float x) { val.Value = x; prefCategory.SaveToFile(false); Action action = callback; if (action != null) { Extensions.InvokeActionSafe(action, x); } }); ((Element)val2).ElementTooltip = tooltip; return val2; } public static BoolElement CreateBoolPref(this Page page, string name, Color color, ref MelonPreferences_Entry value, MelonPreferences_Category prefCategory, Action callback = null, string prefName = null, bool prefDefaultValue = false, string tooltip = null) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) if (prefName == null) { prefName = name; } if (!prefCategory.HasEntry(prefName)) { value = prefCategory.CreateEntry(prefName, prefDefaultValue, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); } MelonPreferences_Entry val = value; BoolElement val2 = page.CreateBool(name, color, val.Value, (Action)delegate(bool x) { val.Value = x; prefCategory.SaveToFile(false); Action action = callback; if (action != null) { Extensions.InvokeActionSafe(action, x); } }); ((Element)val2).ElementTooltip = tooltip; return val2; } public static EnumElement CreateEnumPref(this Page page, string name, Color color, ref MelonPreferences_Entry value, MelonPreferences_Category prefCategory, Action callback = null, string prefName = null, Enum prefDefaultValue = null, string tooltip = null) where T : Enum { //IL_0058: Unknown result type (might be due to invalid IL or missing references) if (prefName == null) { prefName = name; } if (!prefCategory.HasEntry(prefName)) { value = prefCategory.CreateEntry(prefName, (T)prefDefaultValue, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); } MelonPreferences_Entry val = value; EnumElement val2 = page.CreateEnum(name, color, (Enum)val.Value, (Action)delegate(Enum x) { val.Value = (T)x; prefCategory.SaveToFile(false); Action action = callback; if (action != null) { Extensions.InvokeActionSafe(action, x); } }); ((Element)val2).ElementTooltip = tooltip; return val2; } public static StringElement CreateStringPref(this Page page, string name, Color color, ref MelonPreferences_Entry value, MelonPreferences_Category prefCategory, Action callback = null, string prefName = null, string prefDefaultValue = null, string tooltip = null) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) if (prefName == null) { prefName = name; } if (!prefCategory.HasEntry(prefName)) { value = prefCategory.CreateEntry(prefName, prefDefaultValue, (string)null, (string)null, false, false, (ValueValidator)null, (string)null); } MelonPreferences_Entry val = value; StringElement val2 = page.CreateString(name, color, val.Value, (Action)delegate(string x) { val.Value = x; prefCategory.SaveToFile(false); Action action = callback; if (action != null) { Extensions.InvokeActionSafe(action, x); } }); ((Element)val2).ElementTooltip = tooltip; return val2; } } } namespace DevToolsHider { public class DevToolsHiderMod : MelonMod { public static MelonPreferences_Category DevToolsHider_Category; public static MelonPreferences_Entry DevToolsHidden; public static MelonPreferences_Entry EnableInFlatPlayer; public const int FixtureLayer = 6; public const int DynamicLayer = 10; public const int HideableLayer = 11; public static bool IsFlatPlayer; public static Color SpawnGunBlue = new Color(0.06432372f, 0.7570404f, 0.856f, 1f); public override void OnInitializeMelon() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) DevToolsHider_Category = MelonPreferences.CreateCategory("Dev Tools Hider"); Page val = Page.Root.CreatePage("Dev Tools Hider", SpawnGunBlue, 0, true); global::MenuHelper.MenuHelper.CreateBoolPref(val, "Hide in Spectator", SpawnGunBlue, ref DevToolsHidden, UpdateSpectatorCameraSettings, null, prefDefaultValue: true); if (!HelperMethods.IsAndroid()) { val.CreateBoolPref("Hide in FlatPlayer Spectator", SpawnGunBlue, ref EnableInFlatPlayer, UpdateSpectatorCameraSettings, null, prefDefaultValue: false, "Hide in Spectator must be enabled for this to have any effect."); } val.CreateFunction("Toggle Held Items Visibility", SpawnGunBlue, (Action)ToggleHeldItemVisibility); val.CreateFunction("Toggle Held Camera Mask", SpawnGunBlue, (Action)ToggleHeldCameraMask); Physics.IgnoreLayerCollision(11, 6, false); Physics.IgnoreLayerCollision(11, 11, false); ((MelonBase)this).LoggerInstance.Msg("Initialized."); } public override void OnLateInitializeMelon() { if (MelonBase.FindMelon("FlatPlayer", "LlamasHere") != null) { IsFlatPlayer = true; } else { IsFlatPlayer = false; } } public static void ToggleHeldItemVisibility() { GameObject[] array = (GameObject[])(object)new GameObject[2] { Player.GetObjectInHand(Player.LeftHand), Player.GetObjectInHand(Player.RightHand) }; GameObject[] array2 = array; foreach (GameObject val in array2) { if (!((Object)(object)val != (Object)null) || !((Object)(object)val.GetComponentInParent() != (Object)null)) { continue; } Il2CppArrayBase componentsInChildren = ((Component)val.GetComponentInParent(true)).GetComponentsInChildren(true); int layer = ((componentsInChildren.Length == 0 || ((Component)((IEnumerable)componentsInChildren).First()).gameObject.layer == 11) ? 10 : 11); foreach (Renderer item in componentsInChildren) { ((Component)item).gameObject.layer = layer; } } } public static void ToggleHeldCameraMask() { GameObject[] array = (GameObject[])(object)new GameObject[2] { Player.GetObjectInHand(Player.LeftHand), Player.GetObjectInHand(Player.RightHand) }; GameObject[] array2 = array; foreach (GameObject val in array2) { if (!((Object)(object)val != (Object)null) || !((Object)(object)val.GetComponentInParent() != (Object)null)) { continue; } foreach (Camera componentsInChild in ((Component)val.GetComponentInParent(true)).GetComponentsInChildren()) { int cullingMask = componentsInChild.cullingMask; if (RemoveLayer(componentsInChild.cullingMask, 11) == componentsInChild.cullingMask) { componentsInChild.cullingMask = ShowLayer(componentsInChild.cullingMask, 11); } else { componentsInChild.cullingMask = RemoveLayer(componentsInChild.cullingMask, 11); } } } } public static void UpdateSpectatorCameraSettings(bool value) { Camera component = GameObject.Find("/GameplaySystems [0]/DisabledContainer/Spectator Camera/Spectator Camera").GetComponent(); if (DevToolsHidden.Value && (!IsFlatPlayer || EnableInFlatPlayer.Value)) { component.cullingMask = RemoveLayer(component.cullingMask, 11); } else { component.cullingMask = ShowLayer(component.cullingMask, 11); } } public static int ShowLayer(int mask, int layer) { return mask |= 1 << layer; } public static int RemoveLayer(int mask, int layer) { return mask &= ~(1 << layer); } } [HarmonyPatch] public class Patches { [HarmonyPatch(typeof(SpawnGun), "Start")] [HarmonyPostfix] public static void SetSpawnGunLayers(SpawnGun __instance) { SwitchRendererLayers((Component)(object)__instance); } [HarmonyPatch(typeof(FlyingGun), "Awake")] [HarmonyPostfix] public static void SetSpawnGunLayers(FlyingGun __instance) { SwitchRendererLayers((Component)(object)__instance); } public static void SwitchRendererLayers(Component __instance) { Il2CppArrayBase componentsInChildren = __instance.gameObject.GetComponentsInChildren(true); foreach (Renderer item in componentsInChildren) { ((Component)item).gameObject.layer = 11; } } [HarmonyPatch(typeof(RigScreenOptions), "Start")] [HarmonyPostfix] public static void OnLoadedGameplaySystems(RigScreenOptions __instance) { if (!DevToolsHiderMod.IsFlatPlayer || DevToolsHiderMod.EnableInFlatPlayer.Value) { DevToolsHiderMod.UpdateSpectatorCameraSettings(DevToolsHiderMod.DevToolsHidden.Value); } } } }