using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using GameNetcodeStuff; using HarmonyLib; using Unity.Netcode; 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("HoldDoorMod")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("HoldDoorMod")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("245e188f-64b9-4527-aec7-ded7e966a329")] [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 DoorHoldMod; [BepInPlugin("com.yourname.doorholdmod", "DoorHoldMod", "1.0.0")] public class DoorHoldPlugin : BaseUnityPlugin { private readonly Harmony harmony = new Harmony("com.yourname.doorholdmod"); private void Awake() { harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"DoorHoldMod 1.0.0 successfully loaded. UI errors fixed, enemy stun active!"); } } [HarmonyPatch(typeof(PlayerControllerB), "Update")] public class PlayerControllerB_Patch { private static DoorLock currentDoor; private static InteractTrigger currentTrigger; private static float doorLockBufferTimer; private const float LOCK_BUFFER_DURATION = 0.5f; private static bool wasMessageShown; private static void Postfix(PlayerControllerB __instance) { if (!((NetworkBehaviour)__instance).IsOwner || !__instance.isPlayerControlled) { return; } bool flag = false; if ((Object)(object)__instance.hoveringOverTrigger != (Object)null) { InteractTrigger hoveringOverTrigger = __instance.hoveringOverTrigger; DoorLock componentInParent = ((Component)hoveringOverTrigger).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && (!componentInParent.isLocked || (Object)(object)currentDoor == (Object)(object)componentInParent) && UnityInput.Current.GetKey((KeyCode)116)) { flag = true; if (!wasMessageShown) { HUDManager.Instance.DisplayTip("SYSTEM:", "DOOR HELD", false, false, "LC_TipNotification"); wasMessageShown = true; } if ((Object)(object)currentDoor != (Object)(object)componentInParent) { ForceUnlockPrevious(); currentDoor = componentInParent; currentTrigger = hoveringOverTrigger; } currentDoor.isLocked = true; if ((Object)(object)currentTrigger != (Object)null) { currentTrigger.interactable = false; currentTrigger.disabledHoverTip = "[DOOR IS HELD]"; } doorLockBufferTimer = 0.5f; } } if (!flag && (Object)(object)currentDoor != (Object)null) { doorLockBufferTimer -= Time.deltaTime; if (doorLockBufferTimer <= 0f) { TryStunEnemiesAtDoor(); ForceUnlockPrevious(); wasMessageShown = false; } } } private static void TryStunEnemiesAtDoor() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)currentDoor == (Object)null) { return; } Collider[] array = Physics.OverlapSphere(((Component)currentDoor).transform.position, 3.5f); Collider[] array2 = array; foreach (Collider val in array2) { EnemyAI componentInParent = ((Component)val).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null) { componentInParent.SetEnemyStunned(true, 3f, (PlayerControllerB)null); } } } private static void ForceUnlockPrevious() { if ((Object)(object)currentDoor != (Object)null) { currentDoor.isLocked = false; if ((Object)(object)currentTrigger != (Object)null) { currentTrigger.interactable = true; } currentDoor = null; currentTrigger = null; } } }