Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of NoMoreDoors v1.0.1
NoMoreDoors.dll
Decompiled a day agousing System; using System.Collections; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("Autodesk.Fbx")] [assembly: IgnoresAccessChecksTo("Discord.Sdk")] [assembly: IgnoresAccessChecksTo("Domain_Reload")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")] [assembly: IgnoresAccessChecksTo("Klattersynth")] [assembly: IgnoresAccessChecksTo("Photon3Unity3D")] [assembly: IgnoresAccessChecksTo("PhotonChat")] [assembly: IgnoresAccessChecksTo("PhotonRealtime")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")] [assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")] [assembly: IgnoresAccessChecksTo("PhotonVoice.API")] [assembly: IgnoresAccessChecksTo("PhotonVoice")] [assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")] [assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")] [assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")] [assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Modules.Unity.Addressables")] [assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Modules.UnityLocalization")] [assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")] [assembly: IgnoresAccessChecksTo("Sirenix.Serialization")] [assembly: IgnoresAccessChecksTo("Sirenix.Utilities")] [assembly: IgnoresAccessChecksTo("Unity.Addressables")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.InternalAPIEngineBridge.013")] [assembly: IgnoresAccessChecksTo("Unity.Localization")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.MemoryProfiler")] [assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.ResourceManager")] [assembly: IgnoresAccessChecksTo("Unity.ScriptableBuildPipeline")] [assembly: IgnoresAccessChecksTo("Unity.Splines")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")] [assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: IgnoresAccessChecksTo("websocket-sharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("NoMoreDoors")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("NoMoreDoors")] [assembly: AssemblyTitle("NoMoreDoors")] [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 NoMoreDoors { [BepInPlugin("Milaan.NoMoreDoors", "NoMoreDoors", "1.0.0")] public class NoMoreDoorsPlugin : BaseUnityPlugin { public const string PluginGuid = "Milaan.NoMoreDoors"; public const string PluginName = "NoMoreDoors"; public const string PluginVersion = "1.0.0"; internal static ManualLogSource Log; internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<float> RemoveDelay; internal static ConfigEntry<KeyboardShortcut> ListDoorsKey; internal static ConfigEntry<bool> InspectHeldObjectEnabled; internal static ConfigEntry<KeyboardShortcut> InspectHeldObjectKey; private Harmony _harmony; private void Awake() { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Remove broken real doors only. Intact doors are left alone until their hinge breaks. (Host controls this in multiplayer.)"); RemoveDelay = ((BaseUnityPlugin)this).Config.Bind<float>("General", "RemoveDelay", 0.1f, new ConfigDescription("Seconds to wait after a broken door is detected before removing it. Small delay lets the object finish network setup.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>())); ListDoorsKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Debug", "ListDoorsKey", new KeyboardShortcut((KeyCode)287, Array.Empty<KeyCode>()), "Press to log every door still present in the current scene."); InspectHeldObjectEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "InspectHeldObjectEnabled", false, "Enable the held-object inspector key (off by default)."); InspectHeldObjectKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Debug", "InspectHeldObjectKey", new KeyboardShortcut((KeyCode)288, Array.Empty<KeyCode>()), "Press to log full details of the object the local player is currently holding."); Log.LogInfo((object)"NoMoreDoors v1.0.0 loading..."); _harmony = new Harmony("Milaan.NoMoreDoors"); _harmony.PatchAll(); Log.LogInfo((object)"NoMoreDoors v1.0.0 loaded. Doors are on notice."); } private void Update() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut value = ListDoorsKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { ListRemainingDoors(); } if (InspectHeldObjectEnabled.Value) { value = InspectHeldObjectKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { InspectHeldObject(); } } } private static void InspectHeldObject() { //IL_009f: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar instance = PlayerAvatar.instance; if ((Object)(object)instance == (Object)null) { Log.LogInfo((object)"[Inspect] No local PlayerAvatar found."); return; } PhysGrabber physGrabber = instance.physGrabber; if ((Object)(object)physGrabber == (Object)null) { Log.LogInfo((object)"[Inspect] Local player has no PhysGrabber."); return; } PhysGrabObject grabbedPhysGrabObject = physGrabber.grabbedPhysGrabObject; if ((Object)(object)grabbedPhysGrabObject == (Object)null) { Log.LogInfo((object)"[Inspect] Not currently holding anything (grabbedPhysGrabObject is null)."); return; } GameObject gameObject = ((Component)grabbedPhysGrabObject).gameObject; StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine("=== Held object inspection ==="); stringBuilder.AppendLine("Name: " + ((Object)gameObject).name); stringBuilder.AppendLine($"Position: {gameObject.transform.position}"); stringBuilder.AppendLine($"Tag: {gameObject.tag} Layer: {LayerMask.LayerToName(gameObject.layer)} ({gameObject.layer})"); stringBuilder.AppendLine("Parent: " + (((Object)(object)gameObject.transform.parent != (Object)null) ? ((Object)gameObject.transform.parent).name : "<none>")); stringBuilder.AppendLine("--- PhysGrabObject ---"); stringBuilder.AppendLine($"isMaster: {grabbedPhysGrabObject.isMaster}"); stringBuilder.AppendLine($"spawned: {grabbedPhysGrabObject.spawned}"); stringBuilder.AppendLine($"dead: {grabbedPhysGrabObject.dead}"); stringBuilder.AppendLine($"hasHinge: {grabbedPhysGrabObject.hasHinge}"); stringBuilder.AppendLine($"isValuable: {grabbedPhysGrabObject.isValuable} isEnemy: {grabbedPhysGrabObject.isEnemy} isNonValuable: {grabbedPhysGrabObject.isNonValuable}"); PhysGrabHinge val = grabbedPhysGrabObject.hinge; if ((Object)(object)val == (Object)null && !grabbedPhysGrabObject.hasHinge) { val = gameObject.GetComponentInChildren<PhysGrabHinge>(); } if ((Object)(object)val != (Object)null) { stringBuilder.AppendLine("--- PhysGrabHinge ---"); stringBuilder.AppendLine("GameObject: " + ((Object)((Component)val).gameObject).name + " (this may differ from the held object's root)"); stringBuilder.AppendLine($"closed: {val.closed} closing: {val.closing}"); stringBuilder.AppendLine($"dead: {val.dead} broken: {val.broken}"); stringBuilder.AppendLine($"joint present: {(Object)(object)val.joint != (Object)null}"); stringBuilder.AppendLine("physGrabObject (hinge->owner): " + (((Object)(object)val.physGrabObject != (Object)null) ? ((Object)((Component)val.physGrabObject).gameObject).name : "<null>")); bool flag = PhysGrabHinge_Awake_Patch.IsDoor(val); stringBuilder.AppendLine($"IsDoor() name filter result: {flag}"); } else { stringBuilder.AppendLine("--- PhysGrabHinge ---"); stringBuilder.AppendLine("No PhysGrabHinge found on this object (hasHinge=false and no component in children)."); stringBuilder.AppendLine("This object would NOT be touched by the door-removal patch at all."); } stringBuilder.AppendLine("--- Components on held GameObject ---"); Component[] components = gameObject.GetComponents<Component>(); foreach (Component val2 in components) { if ((Object)(object)val2 != (Object)null) { stringBuilder.AppendLine(" " + ((object)val2).GetType().Name); } } Transform root = gameObject.transform.root; if ((Object)(object)root != (Object)null && (Object)(object)((Component)root).gameObject != (Object)(object)gameObject) { stringBuilder.AppendLine("--- Root object: " + ((Object)root).name + " ---"); components = ((Component)root).GetComponents<Component>(); foreach (Component val3 in components) { if ((Object)(object)val3 != (Object)null) { stringBuilder.AppendLine(" " + ((object)val3).GetType().Name); } } } Log.LogInfo((object)stringBuilder.ToString()); } private static void ListRemainingDoors() { //IL_008e: Unknown result type (might be due to invalid IL or missing references) PhysGrabHinge[] array = Object.FindObjectsOfType<PhysGrabHinge>(); int num = 0; Log.LogInfo((object)"=== Doors still present ==="); PhysGrabHinge[] array2 = array; foreach (PhysGrabHinge val in array2) { if (!((Object)(object)val == (Object)null) && PhysGrabHinge_Awake_Patch.IsDoor(val)) { num++; PhysGrabObject val2 = (((Object)(object)val.physGrabObject != (Object)null) ? val.physGrabObject : ((Component)val).GetComponentInParent<PhysGrabObject>()); GameObject val3 = (((Object)(object)val2 != (Object)null) ? ((Component)val2).gameObject : ((Component)val).gameObject); Log.LogInfo((object)$"[{num}] {((Object)val3).name} at {val3.transform.position}"); } } Log.LogInfo((object)((num == 0) ? "=== No doors remaining ===" : $"=== {num} door(s) remaining ===")); } } [HarmonyPatch(typeof(PhysGrabHinge), "HingeBreakRPC")] internal static class PhysGrabHinge_Awake_Patch { private static void Postfix(PhysGrabHinge __instance) { if (NoMoreDoorsPlugin.Enabled.Value && IsDoor(__instance) && __instance.broken) { ((MonoBehaviour)__instance).StartCoroutine(RemoveDoor(__instance)); } } internal static bool IsDoor(PhysGrabHinge hinge) { if (!((Object)(object)((Component)hinge).GetComponent<DirtFinderMapDoor>() != (Object)null)) { return (Object)(object)((Component)hinge).GetComponentInParent<DirtFinderMapDoor>() != (Object)null; } return true; } private static IEnumerator RemoveDoor(PhysGrabHinge hinge) { yield return (object)new WaitForSeconds(NoMoreDoorsPlugin.RemoveDelay.Value); if (!((Object)(object)hinge == (Object)null) && SemiFunc.IsMasterClientOrSingleplayer()) { PhysGrabObject val = (((Object)(object)hinge.physGrabObject != (Object)null) ? hinge.physGrabObject : ((Component)hinge).GetComponentInParent<PhysGrabObject>()); if ((Object)(object)val != (Object)null) { NoMoreDoorsPlugin.Log.LogInfo((object)("Removing door: " + ((Object)((Component)val).gameObject).name)); val.DestroyPhysGrabObject(); } else { NoMoreDoorsPlugin.Log.LogInfo((object)("Removing hinge (no PhysGrabObject found): " + ((Object)((Component)hinge).gameObject).name)); hinge.DestroyHinge(); } } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }