Example #1
0
        public static bool Prefix(PlayerInteract __instance)
        {
            if (EventPlugin.Scp914ActivationEventPatchDisabled)
            {
                return(true);
            }

            try
            {
                if (!__instance._playerInteractRateLimit.CanExecute(true) ||
                    __instance._hc.CufferId > 0 && !__instance.CanDisarmedInteract ||
                    (Scp914Machine.singleton.working || !__instance.ChckDis(Scp914Machine.singleton.button.position)))
                {
                    return(false);
                }

                bool   allow = true;
                double time  = 0;

                Events.InvokeScp914Activation(__instance.gameObject, ref allow, ref time);

                if (allow)
                {
                    Scp914Machine.singleton.RpcActivate(NetworkTime.time + time);
                    __instance.OnInteract();
                }

                return(false);
            }
            catch (Exception exception)
            {
                Log.Error($"Scp914ActivationEvent error: {exception}");
                return(true);
            }
        }
Example #2
0
        private static bool Prefix(PlayerInteract __instance, GameObject elevator)
        {
            if (!__instance._playerInteractRateLimit.CanExecute(true) ||
                (__instance._hc.CufferId > 0 && !PlayerInteract.CanDisarmedInteract) || elevator == null)
            {
                return(false);
            }

            Lift component = elevator.GetComponent <Lift>();

            if (component == null)
            {
                return(false);
            }

            foreach (Lift.Elevator elevator2 in component.elevators)
            {
                if (__instance.ChckDis(elevator2.door.transform.position))
                {
                    var ev = new InteractingElevatorEventArgs(API.Features.Player.Get(__instance.gameObject), elevator2);

                    Player.OnInteractingElevator(ev);

                    if (!ev.IsAllowed)
                    {
                        return(false);
                    }

                    elevator.GetComponent <Lift>().UseLift();
                    __instance.OnInteract();
                }
            }

            return(false);
        }
        public static bool Prefix(PlayerInteract __instance)
        {
            if (!PluginConfig.Cfg.Enabled)
            {
                return(true);
            }

            if (!__instance._playerInteractRateLimit.CanExecute(true) ||
                (__instance._hc.CufferId > 0 &&
                 !(PluginConfig.Cfg.OverrideHandcuffConfig ? PluginConfig.Cfg.CanDisarmedInteract : __instance.CanDisarmedInteract))
                )
            {
                return(false);
            }

            if (!PluginConfig.Cfg.CanChangeKnobWhileWorking && Scp914Machine.singleton.working || !__instance.ChckDis(Scp914Machine.singleton.knob.position))
            {
                return(false);
            }

            //if (Plugin.KnobBlockade) return false;

            Scp914Machine.singleton.ChangeKnobStatus();
            Plugin.LastPlayerHub = ReferenceHub.GetHub(__instance.gameObject);
            __instance.OnInteract();
            return(false);
        }
Example #4
0
        private static bool Prefix(PlayerInteract __instance)
        {
            if (!__instance._playerInteractRateLimit.CanExecute(true) || (__instance._hc.CufferId > 0 && !PlayerInteract.CanDisarmedInteract))
            {
                return(false);
            }

            GameObject gameObject = GameObject.Find("OutsitePanelScript");

            if (!__instance.ChckDis(gameObject.transform.position))
            {
                return(false);
            }

            var ev = new ActivatingWarheadPanelEventArgs(API.Features.Player.Get(__instance.gameObject), new List <string>()
            {
                "CONT_LVL_3"
            });

            Player.OnActivatingWarheadPanel(ev);

            if (ev.IsAllowed && __instance._inv.GetItemByID(__instance._inv.curItem).permissions.Intersect(ev.Permissions).Any())
            {
                gameObject.GetComponentInParent <AlphaWarheadOutsitePanel>().NetworkkeycardEntered = true;
                __instance.OnInteract();
            }

            return(false);
        }
Example #5
0
        public static bool Prefix(PlayerInteract __instance)
        {
            if (EventPlugin.WarheadStartEventPatchDisable)
            {
                return(true);
            }

            try
            {
                if (!__instance._playerInteractRateLimit.CanExecute(true) || (__instance._hc.CufferId > 0 && !__instance.CanDisarmedInteract))
                {
                    return(false);
                }

                GameObject gameObject = GameObject.Find("OutsitePanelScript");

                if (!__instance.ChckDis(gameObject.transform.position) || !AlphaWarheadOutsitePanel.nukeside.enabled)
                {
                    return(false);
                }

                if (!gameObject.GetComponent <AlphaWarheadOutsitePanel>().keycardEntered || Recontainer079.isLocked)
                {
                    return(false);
                }

                AlphaWarheadController.Host.doorsOpen = false;

                ServerLogs.AddLog(ServerLogs.Modules.Warhead, "Countdown started.", ServerLogs.ServerLogType.GameEvent);
                if ((AlphaWarheadController._resumeScenario == -1 && AlphaWarheadController.Host.scenarios_start[AlphaWarheadController._startScenario].SumTime() == AlphaWarheadController.Host.timeToDetonation) ||
                    (AlphaWarheadController._resumeScenario != -1 && AlphaWarheadController.Host.scenarios_resume[AlphaWarheadController._resumeScenario].SumTime() == AlphaWarheadController.Host.timeToDetonation))
                {
                    bool allow = true;

                    Events.InvokeWarheadStart(__instance.gameObject, ref allow);

                    if (!allow)
                    {
                        return(false);
                    }

                    AlphaWarheadController.Host.NetworkinProgress = true;
                }

                ServerLogs.AddLog(ServerLogs.Modules.Warhead, __instance.GetComponent <NicknameSync>().MyNick + " (" + __instance.GetComponent <CharacterClassManager>().UserId + ") started the Alpha Warhead detonation.", ServerLogs.ServerLogType.GameEvent);

                __instance.OnInteract();

                return(false);
            }
            catch (Exception exception)
            {
                Log.Error($"WarheadStartEvent error: {exception}");
                return(true);
            }
        }
        private static bool Prefix(PlayerInteract __instance)
        {
            try
            {
                if (!__instance._playerInteractRateLimit.CanExecute() ||
                    (__instance._hc.CufferId > 0 && !PlayerInteract.CanDisarmedInteract))
                {
                    return(false);
                }

                GameObject gameObject = GameObject.Find("OutsitePanelScript");
                if (!__instance.ChckDis(gameObject.transform.position))
                {
                    return(false);
                }

                var itemById = __instance._inv.GetItemByID(__instance._inv.curItem);
                if (!__instance._sr.BypassMode && itemById == null)
                {
                    return(false);
                }

                const string PANEL_PERM = "CONT_LVL_3";

                // Deprecated
                var list = ListPool <string> .Shared.Rent();

                list.Add(PANEL_PERM);

                var ev = new ActivatingWarheadPanelEventArgs(
                    API.Features.Player.Get(__instance.gameObject),
                    list,
                    __instance._sr.BypassMode || itemById.permissions.Contains(PANEL_PERM));

                Player.OnActivatingWarheadPanel(ev);
                ListPool <string> .Shared.Return(list);

                if (ev.IsAllowed)
                {
                    gameObject.GetComponentInParent <AlphaWarheadOutsitePanel>().NetworkkeycardEntered = true;
                    __instance.OnInteract();
                }

                return(false);
            }
            catch (Exception exception)
            {
                API.Features.Log.Error($"{typeof(ActivatingWarheadPanel).FullName}.{nameof(Prefix)}:\n{exception}");

                return(true);
            }
        }
Example #7
0
        private static bool Prefix(PlayerInteract __instance)
        {
            try
            {
                if (!__instance._playerInteractRateLimit.CanExecute() ||
                    (__instance._hc.CufferId > 0 && !PlayerInteract.CanDisarmedInteract))
                {
                    return(false);
                }

                GameObject gameObject = GameObject.Find("OutsitePanelScript");

                if (!__instance.ChckDis(gameObject.transform.position))
                {
                    return(false);
                }

                Item itemById = __instance._inv.GetItemByID(__instance._inv.curItem);

                if (!__instance._sr.BypassMode && itemById == null)
                {
                    return(false);
                }

                var list = ListPool <string> .Shared.Rent();

                list.Add("CONT_LVL_3");
                var ev = new ActivatingWarheadPanelEventArgs(API.Features.Player.Get(__instance.gameObject), list);

                Player.OnActivatingWarheadPanel(ev);

                if (ev.IsAllowed && itemById.permissions.Intersect(ev.Permissions).Any())
                {
                    gameObject.GetComponentInParent <AlphaWarheadOutsitePanel>().NetworkkeycardEntered = true;
                    __instance.OnInteract();
                }

                ListPool <string> .Shared.Return(list);

                return(false);
            }
            catch (Exception exception)
            {
                API.Features.Log.Error($"Exiled.Events.Patches.Events.Player.ActivatingWarheadPanel: {exception}\n{exception.StackTrace}");

                return(true);
            }
        }
Example #8
0
        public static bool Prefix(PlayerInteract __instance, GameObject elevator)
        {
            if (EventPlugin.ElevatorInteractionEventDisable)
            {
                return(true);
            }

            try
            {
                bool allow = true;
                if (!__instance._playerInteractRateLimit.CanExecute(true) ||
                    (__instance._hc.CufferId > 0 && !__instance.CanDisarmedInteract) || elevator == null)
                {
                    return(false);
                }

                Lift component = elevator.GetComponent <Lift>();
                if (component == null)
                {
                    return(false);
                }

                foreach (Lift.Elevator elevator2 in component.elevators)
                {
                    if (__instance.ChckDis(elevator2.door.transform.position))
                    {
                        Events.InvokeElevatorInteract(__instance.gameObject, elevator2, ref allow);

                        if (!allow)
                        {
                            return(false);
                        }

                        elevator.GetComponent <Lift>().UseLift();
                        __instance.OnInteract();
                    }
                }

                return(false);
            }
            catch (Exception exception)
            {
                Log.Error($"ElevatorUseEvent error: {exception}");
                return(true);
            }
        }
Example #9
0
        public static bool Prefix(PlayerInteract __instance)
        {
            if (EventPlugin.Scp914KnobChangeEventPatchDisable)
            {
                return(true);
            }

            try
            {
                if (!__instance._playerInteractRateLimit.CanExecute(true) ||
                    __instance._hc.CufferId > 0 && !__instance.CanDisarmedInteract ||
                    (Scp914Machine.singleton.working || !__instance.ChckDis(Scp914Machine.singleton.knob.position)))
                {
                    return(false);
                }

                Scp914Knob knobSetting = Scp914Machine.singleton.knobState;

                if (knobSetting + 1 > Scp914Machine.knobStateMax)
                {
                    knobSetting = Scp914Machine.knobStateMin;
                }
                else
                {
                    knobSetting += 1;
                }

                bool allow = true;

                Events.InvokeScp914KnobChange(__instance.gameObject, ref allow, ref knobSetting);

                if (allow)
                {
                    Scp914Machine.singleton.ChangeKnobStatus();
                    __instance.OnInteract();
                }

                return(false);
            }
            catch (Exception exception)
            {
                Log.Error($"Scp914KnobChangeEvent error: {exception}");
                return(true);
            }
        }
Example #10
0
        private static bool Prefix(PlayerInteract __instance, GameObject elevator)
        {
            try
            {
                if (!__instance._playerInteractRateLimit.CanExecute(true) ||
                    ((__instance._hc.CufferId > 0 || __instance._hc.ForceCuff) && !PlayerInteract.CanDisarmedInteract) || elevator == null)
                {
                    return(false);
                }

                Lift component = elevator.GetComponent <Lift>();
                if (component == null)
                {
                    return(false);
                }

                foreach (Lift.Elevator elevator2 in component.elevators)
                {
                    if (__instance.ChckDis(elevator2.door.transform.position))
                    {
                        var ev = new InteractingElevatorEventArgs(API.Features.Player.Get(__instance.gameObject), elevator2, component);

                        Handlers.Player.OnInteractingElevator(ev);

                        if (!ev.IsAllowed)
                        {
                            return(false);
                        }

                        component.UseLift();
                        __instance.OnInteract();
                        return(false);
                    }
                }

                return(false);
            }
            catch (Exception e)
            {
                Exiled.API.Features.Log.Error($"Exiled.Events.Patches.Events.Player.InteractingElevator:\n{e}");

                return(true);
            }
        }
        public static bool Prefix(PlayerInteract __instance)
        {
            Better914Config Config = Better914Plugin.instance.Config;

            if (!Config.IsEnabled)
            {
                return(false);
            }
            if (!__instance._playerInteractRateLimit.CanExecute(true))
            {
                return(true);
            }
            if (__instance._hc.CufferId > 0 && (Config.OverrideHandcuffConfig ? !Config.CanDisarmedInteract : !PlayerInteract.CanDisarmedInteract))
            {
                return(true);
            }
            if (!Config.CanChangeKnobWhileWorking && Scp914Machine.singleton.working)
            {
                return(true);
            }
            if (!__instance.ChckDis(Scp914Machine.singleton.knob.position))
            {
                return(true);
            }
            if (Math.Abs(Scp914Machine.singleton.curKnobCooldown) > 0.001f)
            {
                return(true);
            }

            var ev = new ChangingKnobSettingEventArgs(Exiled.API.Features.Player.Get(__instance.gameObject), Scp914Machine.singleton.knobState + 1);

            Exiled.Events.Handlers.Scp914.OnChangingKnobSetting(ev);

            if (!ev.IsAllowed)
            {
                return(true);
            }

            Scp914Machine.singleton.curKnobCooldown  = Scp914Machine.singleton.knobCooldown;
            Scp914Machine.singleton.NetworkknobState = ev.KnobSetting;
            __instance.OnInteract();
            return(true);
        }
Example #12
0
        private static bool Prefix(PlayerInteract __instance)
        {
            if (!__instance._playerInteractRateLimit.CanExecute(true) || (__instance._hc.CufferId > 0 && !PlayerInteract.CanDisarmedInteract))
            {
                return(false);
            }

            GameObject gameObject = GameObject.Find("OutsitePanelScript");

            if (!__instance.ChckDis(gameObject.transform.position) || !AlphaWarheadOutsitePanel.nukeside.enabled)
            {
                return(false);
            }

            if (!gameObject.GetComponent <AlphaWarheadOutsitePanel>().keycardEntered || Recontainer079.isLocked)
            {
                return(false);
            }

            AlphaWarheadController.Host.doorsOpen = false;

            ServerLogs.AddLog(ServerLogs.Modules.Warhead, "Countdown started.", ServerLogs.ServerLogType.GameEvent);
            if ((AlphaWarheadController._resumeScenario == -1 && AlphaWarheadController.Host.scenarios_start[AlphaWarheadController._startScenario].SumTime() == AlphaWarheadController.Host.timeToDetonation) ||
                (AlphaWarheadController._resumeScenario != -1 && AlphaWarheadController.Host.scenarios_resume[AlphaWarheadController._resumeScenario].SumTime() == AlphaWarheadController.Host.timeToDetonation))
            {
                var ev = new StartingEventArgs(API.Features.Player.Get(__instance.gameObject) ?? API.Features.Server.Host);

                Warhead.OnStarting(ev);

                if (!ev.IsAllowed)
                {
                    return(false);
                }

                AlphaWarheadController.Host.NetworkinProgress = true;
            }

            ServerLogs.AddLog(ServerLogs.Modules.Warhead, __instance.GetComponent <NicknameSync>().MyNick + " (" + __instance.GetComponent <CharacterClassManager>().UserId + ") started the Alpha Warhead detonation.", ServerLogs.ServerLogType.GameEvent);

            __instance.OnInteract();

            return(false);
        }
Example #13
0
        private static bool Prefix(PlayerInteract __instance)
        {
            try
            {
                if (!__instance._playerInteractRateLimit.CanExecute() ||
                    (__instance._hc.CufferId > 0 && !PlayerInteract.CanDisarmedInteract))
                {
                    return(false);
                }

                GameObject gameObject = GameObject.Find("OutsitePanelScript");

                if (!__instance.ChckDis(gameObject.transform.position))
                {
                    return(false);
                }

                Item itemById = __instance._inv.GetItemByID(__instance._inv.curItem);

                if (!__instance._sr.BypassMode &&
                    (itemById == null || !Enumerable.Contains(itemById.permissions, "CONT_LVL_3")))
                {
                    return(false);
                }

                var ev = new ActivatingWarheadPanelEventArgs(API.Features.Player.Get(__instance.gameObject), new List <string> {
                    "CONT_LVL_3"
                });

                Handlers.Player.OnActivatingWarheadPanel(ev);

                gameObject.GetComponentInParent <AlphaWarheadOutsitePanel>().NetworkkeycardEntered = true;
                __instance.OnInteract();

                return(false);
            }
            catch (Exception e)
            {
                Exiled.API.Features.Log.Error($"Exiled.Events.Patches.Events.Player.ActivatingWarheadPanel: {e}\n{e.StackTrace}");

                return(true);
            }
        }
Example #14
0
        private static bool Prefix(PlayerInteract __instance, UnityEngine.GameObject elevator)
        {
            try
            {
                if (!__instance.CanInteract || elevator is null)
                {
                    return(false);
                }

                Lift component = elevator.GetComponent <Lift>();
                if (component is null)
                {
                    return(false);
                }

                foreach (Lift.Elevator elevator1 in component.elevators)
                {
                    if (!__instance.ChckDis(elevator1.door.transform.position))
                    {
                        continue;
                    }

                    InteractingElevatorEventArgs interactingEventArgs = new(API.Features.Player.Get(__instance._hub), elevator1, component);
                    Handlers.Player.OnInteractingElevator(interactingEventArgs);

                    if (interactingEventArgs.IsAllowed)
                    {
                        elevator.GetComponent <Lift>().UseLift();
                        __instance.OnInteract();
                    }
                }

                return(false);
            }
            catch (System.Exception e)
            {
                API.Features.Log.Error($"Exiled.Events.Patches.Events.Player.InteractingElevator:\n{e}");

                return(true);
            }
        }
Example #15
0
        private static bool Prefix(PlayerInteract __instance)
        {
            if (!__instance._playerInteractRateLimit.CanExecute(true) ||
                (__instance._hc.CufferId > 0 && !PlayerInteract.CanDisarmedInteract) ||
                (Scp914Machine.singleton.working || !__instance.ChckDis(Scp914Machine.singleton.button.position)))
            {
                return(false);
            }

            var ev = new ActivatingEventArgs(API.Features.Player.Get(__instance.gameObject), 0);

            Scp914.OnActivating(ev);

            if (ev.IsAllowed)
            {
                Scp914Machine.singleton.RpcActivate(NetworkTime.time + ev.Duration);
                __instance.OnInteract();
            }

            return(false);
        }
        public static bool Prefix(PlayerInteract __instance)
        {
            if (EventPlugin.WarheadKeycardAccessEventDisable)
            {
                return(true);
            }

            try
            {
                if (!__instance._playerInteractRateLimit.CanExecute(true) || (__instance._hc.CufferId > 0 && !__instance.CanDisarmedInteract))
                {
                    return(false);
                }

                GameObject gameObject = GameObject.Find("OutsitePanelScript");

                if (!__instance.ChckDis(gameObject.transform.position))
                {
                    return(false);
                }

                bool   allow = true;
                string requiredPermission = "CONT_LVL_3";

                Events.InvokeWarheadKeycardAccess(__instance.gameObject, ref allow, ref requiredPermission);

                if (allow && __instance._inv.GetItemByID(__instance._inv.curItem).permissions.Contains(requiredPermission))
                {
                    gameObject.GetComponentInParent <AlphaWarheadOutsitePanel>().NetworkkeycardEntered = true;
                    __instance.OnInteract();
                }

                return(false);
            }
            catch (Exception exception)
            {
                Log.Error($"WarheadKeycardAccessEvent error: {exception}");
                return(true);
            }
        }
Example #17
0
        private static bool Prefix(PlayerInteract __instance)
        {
            if (!__instance._playerInteractRateLimit.CanExecute(true) ||
                (__instance._hc.CufferId > 0 && !PlayerInteract.CanDisarmedInteract) ||
                Scp914Machine.singleton.working || !__instance.ChckDis(Scp914Machine.singleton.knob.position) ||
                Math.Abs(Scp914Machine.singleton.curKnobCooldown) > 0.001f)
            {
                return(false);
            }

            var ev = new ChangingKnobSettingEventArgs(API.Features.Player.Get(__instance.gameObject), Scp914Machine.singleton.knobState + 1);

            Scp914.OnChangingKnobSetting(ev);

            if (ev.IsAllowed)
            {
                Scp914Machine.singleton.NetworkknobState = ev.KnobSetting;
                Scp914Machine.singleton.curKnobCooldown  = Scp914Machine.singleton.knobCooldown;
                __instance.OnInteract();
            }

            return(false);
        }
Example #18
0
        public static bool Prefix(PlayerInteract __instance, int lockerId, int chamberNumber)
        {
            if (!__instance._playerInteractRateLimit.CanExecute(true) || (__instance._hc.CufferId > 0 && !__instance.CanDisarmedInteract))
            {
                return(false);
            }
            LockerManager singleton = LockerManager.singleton;

            if (lockerId < 0 || lockerId >= singleton.lockers.Length)
            {
                return(false);
            }
            if (!__instance.ChckDis(singleton.lockers[lockerId].gameObject.position) || !singleton.lockers[lockerId].supportsStandarizedAnimation)
            {
                return(false);
            }
            if (chamberNumber < 0 || chamberNumber >= singleton.lockers[lockerId].chambers.Length)
            {
                return(false);
            }
            if (singleton.lockers[lockerId].chambers[chamberNumber].doorAnimator == null)
            {
                return(false);
            }
            if (!singleton.lockers[lockerId].chambers[chamberNumber].CooldownAtZero())
            {
                return(false);
            }
            singleton.lockers[lockerId].chambers[chamberNumber].SetCooldown();
            string accessToken = singleton.lockers[lockerId].chambers[chamberNumber].accessToken;
            Item   itemByID    = __instance._inv.GetItemByID(__instance._inv.curItem);
            bool   allow       = string.IsNullOrEmpty(accessToken) || (itemByID != null && itemByID.permissions.Contains(accessToken)) || __instance._sr.BypassMode;

            Events.InvokeLockerInteract(__instance.gameObject, singleton.lockers[lockerId], lockerId, ref allow);
            if (allow)
            {
                bool flag = ((int)singleton.openLockers[lockerId] & 1 << chamberNumber) != 1 << chamberNumber;
                singleton.ModifyOpen(lockerId, chamberNumber, flag);
                singleton.RpcDoSound(lockerId, chamberNumber, flag);
                bool state = true;
                for (int i = 0; i < singleton.lockers[lockerId].chambers.Length; i++)
                {
                    if (((int)singleton.openLockers[lockerId] & 1 << i) == 1 << i)
                    {
                        state = false;
                        break;
                    }
                }
                singleton.lockers[lockerId].LockPickups(state);
                if (!string.IsNullOrEmpty(accessToken))
                {
                    singleton.RpcChangeMaterial(lockerId, chamberNumber, false);
                }
            }
            else
            {
                singleton.RpcChangeMaterial(lockerId, chamberNumber, true);
            }
            __instance.OnInteract();
            return(false);
        }
Example #19
0
        private static bool Prefix(PlayerInteract __instance, GameObject doorId)
        {
            if (!__instance._playerInteractRateLimit.CanExecute() ||
                (__instance._hc.CufferId > 0 && !PlayerInteract.CanDisarmedInteract) ||
                doorId == null ||
                !doorId.TryGetComponent(out Door door) ||
                (__instance._ccm.CurClass == RoleType.None || __instance._ccm.CurClass == RoleType.Spectator) ||
                (door.buttons.Count == 0 ?
                 (__instance.ChckDis(doorId.transform.position) ? 1 : 0) :
                 (door.buttons.Any(item => __instance.ChckDis(item.transform.position)) ? 1 : 0)) == 0)
            {
                return(false);
            }

            var ev = new InteractingDoorEventArgs(API.Features.Player.Get(__instance.gameObject), door);

            __instance.OnInteract();

            if (__instance._sr.BypassMode)
            {
                ev.IsAllowed = true;
            }
            else if (ev.Door.PermissionLevels.HasPermission(Door.AccessRequirements.Checkpoints) && __instance._ccm.CurRole.team == Team.SCP)
            {
                ev.IsAllowed = true;
            }
            else
            {
                try
                {
                    if (ev.Door.PermissionLevels == 0)
                    {
                        ev.IsAllowed = !ev.Door.locked;
                    }
                    else if (!ev.Door.RequireAllPermissions)
                    {
                        var itemPerms = __instance._inv.GetItemByID(__instance._inv.curItem).permissions;

                        ev.IsAllowed = itemPerms.Any(p =>
                                                     ev.Door.backwardsCompatPermissions.TryGetValue(p, out var flag) &&
                                                     ev.Door.PermissionLevels.HasPermission(flag)) || false;
                    }
                    else
                    {
                        ev.IsAllowed = false;
                    }
                }
                catch
                {
                    ev.IsAllowed = false;
                }
            }

            Player.OnInteractingDoor(ev);

            if (ev.IsAllowed)
            {
                ev.Door.ChangeState(__instance._sr.BypassMode);
            }
            else
            {
                __instance.RpcDenied(doorId);
            }

            return(false);
        }
Example #20
0
        public static bool Prefix(PlayerInteract __instance, GameObject doorId)
        {
            try
            {
                var  allowTheAccess = true;
                Door door           = null;

                if (!__instance._playerInteractRateLimit.CanExecute() || (__instance._hc.CufferId > 0 && !PlayerInteract.CanDisarmedInteract))
                {
                    return(false);
                }

                if (doorId == null)
                {
                    return(false);
                }

                if (__instance._ccm.CurClass == RoleType.None || __instance._ccm.CurClass == RoleType.Spectator)
                {
                    return(false);
                }

                if (!doorId.TryGetComponent(out door))
                {
                    return(false);
                }


                if ((door.Buttons.Count == 0) ? (!__instance.ChckDis(doorId.transform.position)) : Enumerable.All(door.Buttons, item => !__instance.ChckDis(item.button.transform.position)))
                {
                    return(false);
                }

                __instance.OnInteract();

                if (!__instance._sr.BypassMode && !(door.PermissionLevels.HasPermission(Door.AccessRequirements.Checkpoints) &&
                                                    __instance._ccm.CurRole.team == Team.SCP))
                {
                    try
                    {
                        if (door.PermissionLevels == 0)
                        {
                            allowTheAccess = !door.locked;
                        }
                        else if (!door.RequireAllPermissions)
                        {
                            var itemPerms = __instance._inv.GetItemByID(__instance._inv.curItem).permissions;
                            allowTheAccess = itemPerms.Any(p =>
                                                           Door.backwardsCompatPermissions.TryGetValue(p, out var flag) &&
                                                           door.PermissionLevels.HasPermission(flag));
                        }
                        else
                        {
                            allowTheAccess = false;
                        }
                    }
                    catch
                    {
                        allowTheAccess = false;
                    }
                }

                Events.InvokeDoorInteraction(__instance.gameObject.GetPlayer(), door, ref allowTheAccess);

                if (allowTheAccess)
                {
                    door.ChangeState(__instance._sr.BypassMode);
                }
                else
                {
                    __instance.RpcDenied(doorId);
                }

                return(false);
            }
            catch (Exception e)
            {
                Log.Error($"DoorInteraction Error: {e}");

                return(true);
            }
        }
        public static bool Prefix(PlayerInteract __instance, GameObject doorId)
        {
            if (EventPlugin.DoorInteractionEventPatchDisable)
            {
                return(true);
            }

            try
            {
                bool allow = true;
                if (!__instance._playerInteractRateLimit.CanExecute() ||
                    __instance._hc.CufferId > 0 && !__instance.CanDisarmedInteract ||
                    (doorId == null || __instance._ccm.CurClass == RoleType.None ||
                     __instance._ccm.CurClass == RoleType.Spectator))
                {
                    return(false);
                }
                Door component1 = doorId.GetComponent <Door>();
                if (component1 == null || (component1.buttons.Count == 0
                                            ? (__instance.ChckDis(doorId.transform.position) ? 1 : 0)
                                            : (component1.buttons.Any(item => __instance.ChckDis(item.transform.position)) ? 1 : 0)) == 0)
                {
                    return(false);
                }
                Scp096PlayerScript component2 = __instance.GetComponent <Scp096PlayerScript>();
                if (component1.destroyedPrefab != null && (!component1.isOpen || component1.curCooldown > 0.0) &&
                    (component2.iAm096 && component2.enraged == Scp096PlayerScript.RageState.Enraged))
                {
                    if (!__instance._096DestroyLockedDoors && component1.locked && !__instance._sr.BypassMode)
                    {
                        return(false);
                    }
                    component1.DestroyDoor(true);
                }
                else
                {
                    __instance.OnInteract();
                    if (__instance._sr.BypassMode)
                    {
                        try
                        {
                            Events.InvokeDoorInteract(__instance.gameObject, component1, ref allow);

                            if (allow == false)
                            {
                                __instance.RpcDenied(doorId);
                                return(false);
                            }

                            component1.ChangeState();
                        }
                        catch (Exception e)
                        {
                            Log.Error($"Door interaction error: {e}");

                            if (allow)
                            {
                                component1.ChangeState();
                            }
                            else
                            {
                                __instance.RpcDenied(doorId);
                            }
                            return(false);
                        }
                    }
                    else if (string.Equals(component1.permissionLevel, "CHCKPOINT_ACC",
                                           StringComparison.OrdinalIgnoreCase) && __instance.GetComponent <CharacterClassManager>()
                             .Classes.SafeGet(__instance.GetComponent <CharacterClassManager>().CurClass).team ==
                             Team.SCP)
                    {
                        try
                        {
                            Events.InvokeDoorInteract(__instance.gameObject, component1, ref allow);

                            if (allow == false)
                            {
                                __instance.RpcDenied(doorId);
                                return(false);
                            }

                            component1.ChangeState();
                        }
                        catch (Exception e)
                        {
                            Log.Error($"Door interaction error: {e}");

                            if (allow)
                            {
                                component1.ChangeState();
                            }
                            else
                            {
                                __instance.RpcDenied(doorId);
                            }
                        }
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(component1.permissionLevel))
                        {
                            if (component1.locked)
                            {
                                __instance.RpcDenied(doorId);
                                return(false);
                            }

                            try
                            {
                                Events.InvokeDoorInteract(__instance.gameObject, component1, ref allow);

                                if (allow == false)
                                {
                                    __instance.RpcDenied(doorId);
                                    return(false);
                                }

                                component1.ChangeState();
                                return(false);
                            }
                            catch (Exception e)
                            {
                                Log.Error($"Door interaction error: {e}");

                                if (allow)
                                {
                                    component1.ChangeState();
                                }
                                else
                                {
                                    __instance.RpcDenied(doorId);
                                }
                                return(false);
                            }
                        }

                        Item item = __instance._inv.GetItemByID(__instance._inv.curItem);
                        if (item != null && item.permissions.Contains(component1.permissionLevel))
                        {
                            if (!component1.locked)
                            {
                                try
                                {
                                    Events.InvokeDoorInteract(__instance.gameObject, component1, ref allow);

                                    if (allow == false)
                                    {
                                        __instance.RpcDenied(doorId);
                                        return(false);
                                    }

                                    component1.ChangeState();
                                }
                                catch (Exception e)
                                {
                                    Log.Error($"Door interaction error: {e}");

                                    if (allow)
                                    {
                                        component1.ChangeState();
                                    }
                                    else
                                    {
                                        __instance.RpcDenied(doorId);
                                    }
                                }
                            }
                            else
                            {
                                __instance.RpcDenied(doorId);
                            }
                        }
                        else
                        {
                            // Let the plugins decide in case the default options to open the door weren't met
                            if (!component1.locked)
                            {
                                // Instead of passing allow as true, pass it as false
                                allow = false;
                                try
                                {
                                    Events.InvokeDoorInteract(__instance.gameObject, component1, ref allow);

                                    if (allow == false)
                                    {
                                        __instance.RpcDenied(doorId);
                                        return(false);
                                    }

                                    component1.ChangeState();
                                }
                                catch (Exception e)
                                {
                                    Log.Error($"Door interaction error: {e}");

                                    if (allow)
                                    {
                                        component1.ChangeState();
                                    }
                                    else
                                    {
                                        __instance.RpcDenied(doorId);
                                    }
                                }
                            }
                            else
                            {
                                __instance.RpcDenied(doorId);
                            }
                        }
                    }
                }

                return(false);
            }
            catch (Exception e)
            {
                Log.Error($"DoorInteraction Error: {e}");
                return(true);
            }
        }
Example #22
0
        private static bool Prefix(PlayerInteract __instance, byte lockerId, byte chamberNumber)
        {
            try
            {
                if (!__instance._playerInteractRateLimit.CanExecute(true) ||
                    (__instance._hc.CufferId > 0 && !PlayerInteract.CanDisarmedInteract))
                {
                    return(false);
                }

                LockerManager singleton = LockerManager.singleton;

                if (lockerId >= singleton.lockers.Length)
                {
                    return(false);
                }

                if (!__instance.ChckDis(singleton.lockers[lockerId].gameObject.position) ||
                    !singleton.lockers[lockerId].supportsStandarizedAnimation)
                {
                    return(false);
                }

                if (chamberNumber >= singleton.lockers[lockerId].chambers.Length)
                {
                    return(false);
                }

                if (singleton.lockers[lockerId].chambers[chamberNumber].doorAnimator == null)
                {
                    return(false);
                }

                if (!singleton.lockers[lockerId].chambers[chamberNumber].CooldownAtZero())
                {
                    return(false);
                }

                singleton.lockers[lockerId].chambers[chamberNumber].SetCooldown();

                string accessToken = singleton.lockers[lockerId].chambers[chamberNumber].accessToken;
                var    itemById    = __instance._inv.GetItemByID(__instance._inv.curItem);

                var ev = new InteractingLockerEventArgs(
                    API.Features.Player.Get(__instance.gameObject),
                    singleton.lockers[lockerId],
                    singleton.lockers[lockerId].chambers[chamberNumber],
                    lockerId,
                    chamberNumber,
                    string.IsNullOrEmpty(accessToken) || (itemById != null && itemById.permissions.Contains(accessToken)) || __instance._sr.BypassMode);

                Player.OnInteractingLocker(ev);

                if (ev.IsAllowed)
                {
                    bool flag = (singleton.openLockers[lockerId] & 1 << chamberNumber) != 1 << chamberNumber;
                    singleton.ModifyOpen(lockerId, chamberNumber, flag);
                    singleton.RpcDoSound(lockerId, chamberNumber, flag);
                    bool anyOpen = true;
                    for (int i = 0; i < singleton.lockers[lockerId].chambers.Length; i++)
                    {
                        if ((singleton.openLockers[lockerId] & 1 << i) == 1 << i)
                        {
                            anyOpen = false;
                            break;
                        }
                    }

                    singleton.lockers[lockerId].LockPickups(!flag, chamberNumber, anyOpen);
                    if (!string.IsNullOrEmpty(accessToken))
                    {
                        singleton.RpcChangeMaterial(lockerId, chamberNumber, false);
                    }
                }
                else
                {
                    singleton.RpcChangeMaterial(lockerId, chamberNumber, true);
                }

                __instance.OnInteract();

                return(false);
            }
            catch (Exception e)
            {
                Exiled.API.Features.Log.Error($"Exiled.Events.Patches.Events.Player.InteractingLocker:\n{e}");

                return(true);
            }
        }
Example #23
0
        public static bool Prefix(PlayerInteract __instance, GameObject doorId)
        {
            if (EventPlugin.DoorInteractionEventPatchDisable)
            {
                return(true);
            }

            bool allow = true;
            Door door  = doorId.GetComponent <Door>();

            try
            {
                if (!__instance._playerInteractRateLimit.CanExecute() ||
                    __instance._hc.CufferId > 0 && !__instance.CanDisarmedInteract ||
                    (doorId == null || __instance._ccm.CurClass == RoleType.None ||
                     __instance._ccm.CurClass == RoleType.Spectator))
                {
                    return(false);
                }

                if (door == null || (door.buttons.Count == 0
                                                ? (__instance.ChckDis(doorId.transform.position) ? 1 : 0)
                                                : (door.buttons.Any(item => __instance.ChckDis(item.transform.position)) ? 1 : 0)) == 0)
                {
                    return(false);
                }

                Scp096PlayerScript component2 = __instance.GetComponent <Scp096PlayerScript>();

                if (door.destroyedPrefab != null && (!door.isOpen || door.curCooldown > 0.0) &&
                    (component2.iAm096 && component2.enraged == Scp096PlayerScript.RageState.Enraged))
                {
                    if (!__instance._096DestroyLockedDoors && door.locked && !__instance._sr.BypassMode)
                    {
                        return(false);
                    }

                    door.DestroyDoor(true);
                }
                else
                {
                    __instance.OnInteract();
                    if (__instance._sr.BypassMode)
                    {
                        allow = true;
                    }
                    else if (string.Equals(door.permissionLevel, "CHCKPOINT_ACC", StringComparison.OrdinalIgnoreCase) &&
                             __instance.GetComponent <CharacterClassManager>().Classes.SafeGet(__instance.GetComponent <CharacterClassManager>().CurClass).team == Team.SCP)
                    {
                        allow = true;
                    }
                    else
                    {
                        Item item = __instance._inv.GetItemByID(__instance._inv.curItem);
                        if (string.IsNullOrEmpty(door.permissionLevel))
                        {
                            allow = !door.locked;
                        }
                        else if (item != null && item.permissions.Contains(door.permissionLevel))
                        {
                            allow = !door.locked;
                        }
                        else
                        {
                            allow = false;
                        }
                    }

                    Events.InvokeDoorInteract(__instance.gameObject, door, ref allow);

                    if (!allow)
                    {
                        __instance.RpcDenied(doorId);
                        return(false);
                    }

                    door.ChangeState();
                }

                return(false);
            }
            catch (Exception exception)
            {
                Log.Error($"DoorInteractionEvent error: {exception}");

                if (allow)
                {
                    door.ChangeState();
                }
                else
                {
                    __instance.RpcDenied(doorId);
                }

                return(false);
            }
        }