private static bool Prefix(DoorVariant __instance, ReferenceHub ply, byte colliderId) { try { InteractingDoorEventArgs ev = new(Player.Get(ply), __instance, false); bool bypassDenied = false; bool allowInteracting = false; if (__instance.ActiveLocks != 0) { DoorLockMode mode = DoorLockUtils.GetMode((DoorLockReason)__instance.ActiveLocks); if ((!mode.HasFlagFast(DoorLockMode.CanClose) || !mode.HasFlagFast(DoorLockMode.CanOpen)) && (!mode.HasFlagFast(DoorLockMode.ScpOverride) || ply.characterClassManager.CurRole.team != 0) && (mode == DoorLockMode.FullLock || (__instance.TargetState && !mode.HasFlagFast(DoorLockMode.CanClose)) || (!__instance.TargetState && !mode.HasFlagFast(DoorLockMode.CanOpen)))) { /* * __instance.LockBypassDenied(ply, colliderId); * return false; */ //>EXILED ev.IsAllowed = false; bypassDenied = true; //<EXILED } } if (!bypassDenied && (allowInteracting = __instance.AllowInteracting(ply, colliderId))) { if (ply.characterClassManager.CurClass == RoleType.Scp079 || __instance.RequiredPermissions.CheckPermissions(ply.inventory.CurInstance, ply)) { /* * __instance.NetworkTargetState = !__instance.TargetState; * __instance._triggerPlayer = ply; */ //>EXILED ev.IsAllowed = true; //<EXILED } else { /* * __instance.PermissionsDenied(ply, colliderId); * DoorEvents.TriggerAction(__instance, DoorAction.AccessDenied, ply); */ //>EXILED ev.IsAllowed = false; //<EXILED } } //>EXILED Handlers.Player.OnInteractingDoor(ev); if (ev.IsAllowed && allowInteracting) { __instance.NetworkTargetState = !__instance.TargetState; __instance._triggerPlayer = ply; } else if (bypassDenied) { __instance.LockBypassDenied(ply, colliderId); } // Don't call the RPC if the door is still moving else if (allowInteracting) { // To avoid breaking their API, call the access denied event // when our event prevents the door from opening __instance.PermissionsDenied(ply, colliderId); DoorEvents.TriggerAction(__instance, DoorAction.AccessDenied, ply); } //<EXILED return(false); } catch (Exception ex) { Log.Error($"{typeof(InteractingDoor).FullName}.{nameof(Prefix)}:\n{ex}"); return(true); } }
private static bool Prefix(DoorVariant __instance, ReferenceHub ply, byte colliderId) { try { if (!NetworkServer.active) { Debug.LogWarning("[Server] function 'System.Void Interactables.Interobjects.DoorUtils.DoorVariant::ServerInteract(ReferenceHub,System.Byte)' called on client"); return(false); } if (__instance.ActiveLocks > 0) { DoorLockMode mode = DoorLockUtils.GetMode((DoorLockReason)__instance.ActiveLocks); if ((!mode.HasFlagFast(DoorLockMode.CanClose) || !mode.HasFlagFast(DoorLockMode.CanOpen)) && (!mode.HasFlagFast(DoorLockMode.ScpOverride) || ply.characterClassManager.CurRole.team != Team.SCP) && (mode == DoorLockMode.FullLock || (__instance.TargetState && !mode.HasFlagFast(DoorLockMode.CanClose)) || (!__instance.TargetState && !mode.HasFlagFast(DoorLockMode.CanOpen)))) { __instance.LockBypassDenied(ply, colliderId); return(false); } } if (__instance.AllowInteracting(ply, colliderId)) { var player = ply.GetPlayer(); var flag = __instance.RequiredPermissions.CheckPermissions(player.VanillaInventory.curItem, ply); var cardaccess = false; var item = player.ItemInHand; if (item != null && item.ItemCategory == ItemCategory.Keycard) { EventHandler.Get.Player.InvokePlayerItemUseEvent(player, item, Api.Events.SynapseEventArguments.ItemInteractState.Finalizing, ref flag); } if (flag) { cardaccess = true; } else if (Server.Get.Configs.SynapseConfiguration.RemoteKeyCard) { foreach (var item2 in player.Inventory.Items.Where(x => x != item && x.ItemCategory == ItemCategory.Keycard)) { var allowcard = __instance.RequiredPermissions.CheckPermissions(item2.ItemType, ply); EventHandler.Get.Player.InvokePlayerItemUseEvent(player, item2, Api.Events.SynapseEventArguments.ItemInteractState.Finalizing, ref allowcard); if (allowcard) { cardaccess = true; break; } } } EventHandler.Get.Map.InvokeDoorInteractEvent(player, __instance.GetDoor(), ref cardaccess); if (ply.characterClassManager.CurClass == RoleType.Scp079 || cardaccess) { __instance.NetworkTargetState = !__instance.TargetState; __instance._triggerPlayer = ply; return(false); } __instance.PermissionsDenied(ply, colliderId); DoorEvents.TriggerAction(__instance, DoorAction.AccessDenied, ply); } return(false); } catch (Exception e) { Logger.Get.Error($"Synapse-Event: DoorInteract failed!!\n{e}"); return(true); } }