Пример #1
0
        public static bool Prefix(Generator079 __instance)
        {
            if (EventPlugin.GeneratorFinishedEventPatchDisable)
            {
                return(true);
            }

            if (__instance.prevFinish || __instance.localTime > 0.0)
            {
                return(false);
            }

            try
            {
                Events.InvokeGeneratorFinish(__instance);

                __instance.prevFinish = true;
                __instance.epsenRenderer.sharedMaterial  = __instance.matLetGreen;
                __instance.epsdisRenderer.sharedMaterial = __instance.matLedBlack;
                __instance.asource.PlayOneShot(__instance.unlockSound);

                return(false);
            }
            catch (Exception exception)
            {
                Log.Error($"GeneratorFinishedEvent error: {exception}");
                return(true);
            }
        }
        private static bool Prefix(Generator079 __instance, GameObject person, PlayerInteract.Generator079Operations command)
        {
            try
            {
                var player    = person.GetPlayer();
                var generator = __instance.GetGenerator();

                switch (command)
                {
                case PlayerInteract.Generator079Operations.Tablet:

                    if (generator.IsTabletConnected || !generator.Open || __instance._localTime <= 0f || Generator079.mainGenerator.forcedOvercharge || !SynapseExtensions.CanHarmScp(player))
                    {
                        return(false);
                    }

                    Inventory component = person.GetComponent <Inventory>();

                    using (SyncList <Inventory.SyncItemInfo> .SyncListEnumerator enumerator = component.items.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            Inventory.SyncItemInfo syncItemInfo = enumerator.Current;
                            if (syncItemInfo.id == ItemType.WeaponManagerTablet)
                            {
                                bool allow2 = true;
                                var  item   = syncItemInfo.GetSynapseItem();
                                Server.Get.Events.Player.InvokePlayerGeneratorInteractEvent(player, generator, GeneratorInteraction.TabletInjected, ref allow2);
                                Server.Get.Events.Player.InvokePlayerItemUseEvent(player, item, Api.Events.SynapseEventArguments.ItemInteractState.Finalizing, ref allow2);
                                if (!allow2)
                                {
                                    break;
                                }

                                generator.ConnectedTablet = item;
                                break;
                            }
                        }
                    }
                    return(false);

                case PlayerInteract.Generator079Operations.Cancel:
                    if (!generator.IsTabletConnected)
                    {
                        return(false);
                    }

                    bool allow = true;
                    Server.Get.Events.Player.InvokePlayerGeneratorInteractEvent(player, generator, GeneratorInteraction.TabledEjected, ref allow);
                    return(allow);
                }
                return(true);
            }
            catch (Exception e)
            {
                Logger.Get.Error($"Synapse-Event: PlayerGenerator failed!!\n{e}\nStackTrace:\n{e.StackTrace}");
                return(true);
            }
        }
Пример #3
0
        public static bool Prefix(Generator079 __instance, GameObject person, PlayerInteract.Generator079Operations command)
        {
            try
            {
                switch (command)
                {
                case PlayerInteract.Generator079Operations.Tablet:

                    if (__instance.isTabletConnected || !__instance.isDoorOpen || __instance._localTime <= 0f || Generator079.mainGenerator.forcedOvercharge)
                    {
                        return(false);
                    }
                    Inventory component = person.GetComponent <Inventory>();
                    using (SyncList <Inventory.SyncItemInfo> .SyncListEnumerator enumerator = component.items.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            Inventory.SyncItemInfo syncItemInfo = enumerator.Current;
                            if (syncItemInfo.id == ItemType.WeaponManagerTablet)
                            {
                                var allow2 = true;
                                Events.InvokeGeneratorInserted(person.GetPlayer(), __instance, ref allow2);
                                if (!allow2)
                                {
                                    break;
                                }

                                component.items.Remove(syncItemInfo);
                                __instance.NetworkisTabletConnected = true;
                                break;
                            }
                        }
                    }
                    return(false);

                case PlayerInteract.Generator079Operations.Cancel:
                    if (!__instance.isTabletConnected)
                    {
                        return(false);
                    }

                    var allow = true;
                    Events.InvokeGeneratorEjected(person.GetPlayer(), __instance, ref allow);
                    return(allow);
                }
                return(true);
            }
            catch (Exception e)
            {
                Log.Error($"GeneratorTablet Event Error: {e}");
                return(true);
            }
        }
Пример #4
0
 private static bool Prefix(Generator079 __instance)
 {
     if (__instance.isTabletConnected)
     {
         var gen = __instance.GetGenerator();
         __instance.NetworkisTabletConnected = false;
         if (gen.ConnectedTablet != null)
         {
             gen.ConnectedTablet.Drop(gen.TabletEjectionPoint);
         }
     }
     return(false);
 }
Пример #5
0
        public static void InvokeGeneratorFinish(Generator079 generator)
        {
            if (GeneratorFinishedEvent == null)
            {
                return;
            }

            GeneratorFinishEvent ev = new GeneratorFinishEvent()
            {
                Generator = generator,
            };

            GeneratorFinishedEvent.Invoke(ref ev);
        }
Пример #6
0
        private static void Postfix(Generator079 __instance)
        {
            while (Map.Get.Generators.Select(x => x.GameObject).Contains(null))
            {
                Map.Get.Doors.Remove(Map.Get.Doors.FirstOrDefault(x => x.GameObject == null));
            }

            if (!__instance.name.Contains("("))
            {
                Map.Get.Generators.Add(new Api.Generator(__instance, true));
                return;
            }

            Map.Get.Generators.Add(new Api.Generator(__instance, false));
        }
        public static bool Prefix(Generator079 __instance, GameObject person, PlayerInteract.Generator079Operations command)
        {
            Plugin.Log.Debug("Generator079InteractPatch");
            Player ply = Player.Get(__instance.gameObject);

            if (!Plugin.GhostList.Contains(ply))
            {
                return(true);
            }

            ply.ClearBroadcasts();
            ply.Broadcast(3, Translation.Translation.GetText().GeneratorDenied);

            return(false);
        }
Пример #8
0
        public static void InvokeGeneratorClose(GameObject player, Generator079 generator, ref bool allow)
        {
            if (GeneratorClosedEvent == null)
            {
                return;
            }

            GeneratorCloseEvent ev = new GeneratorCloseEvent()
            {
                Player    = player.GetPlayer(),
                Generator = generator,
                Allow     = allow
            };

            GeneratorClosedEvent.InvokeSafely(ev);

            allow = ev.Allow;
        }
Пример #9
0
        public static void InvokeGeneratorInsert(GameObject player, Generator079 generator, ref bool allow)
        {
            GeneratorInsert generatorInsert = GeneratorInsertedEvent;

            if (generatorInsert == null)
            {
                return;
            }
            GeneratorInsertTabletEvent ev = new GeneratorInsertTabletEvent()
            {
                Player    = Player.GetPlayer(player),
                Generator = generator,
                Allow     = allow
            };

            generatorInsert.Invoke(ref ev);
            allow = ev.Allow;
        }
Пример #10
0
        public static void InvokeGeneratorClose(GameObject player, Generator079 generator, ref bool allow)
        {
            GeneratorClose generatorClose = GeneratorClosedEvent;

            if (generatorClose == null)
            {
                return;
            }
            GeneratorCloseEvent ev = new GeneratorCloseEvent()
            {
                Player    = Player.GetPlayer(player),
                Generator = generator,
                Allow     = allow
            };

            generatorClose.Invoke(ref ev);
            allow = ev.Allow;
        }
Пример #11
0
        internal static void InvokeGeneratorClose(Player player, Generator079 generator, ref bool allow)
        {
            if (GeneratorCloseEvent == null)
            {
                return;
            }

            var ev = new GeneratorEvent
            {
                Allow     = allow,
                Generator = generator,
                Player    = player
            };

            GeneratorCloseEvent.Invoke(ev);

            allow = ev.Allow;
        }
Пример #12
0
        internal static void InvokeGeneratorUnlock(GameObject player, Generator079 generator, ref bool allow)
        {
            if (GeneratorUnlockEvent == null)
            {
                return;
            }

            GeneratorUnlockEvent ev = new GeneratorUnlockEvent()
            {
                Player    = player.GetPlayer(),
                Generator = generator,
                Allow     = allow
            };

            GeneratorUnlockEvent.Invoke(ref ev);

            allow = ev.Allow;
        }
Пример #13
0
        private static bool Prefix(Generator079 __instance)
        {
            if (__instance.prevFinish || __instance._localTime > 0.0)
            {
                return(false);
            }

            var ev = new GeneratorActivatedEventArgs(__instance);

            Map.OnGeneratorActivated(ev);

            __instance.prevFinish = true;
            __instance.epsenRenderer.sharedMaterial  = __instance.matLetGreen;
            __instance.epsdisRenderer.sharedMaterial = __instance.matLedBlack;
            __instance._asource.PlayOneShot(__instance.unlockSound);

            return(false);
        }
Пример #14
0
        internal static void InvokeGeneratorUnlock(GameObject person, Generator079 generator, ref bool allow)
        {
            GeneratorUnlock generatorUnlock = GeneratorUnlockEvent;

            if (generatorUnlock == null)
            {
                return;
            }
            GeneratorUnlockEvent ev = new GeneratorUnlockEvent()
            {
                Allow     = allow,
                Generator = generator,
                Player    = Player.GetPlayer(person)
            };

            generatorUnlock.Invoke(ref ev);
            allow = ev.Allow;
        }
Пример #15
0
        public static void InvokeGeneratorEject(GameObject player, Generator079 generator, ref bool allow)
        {
            if (GeneratorEjectedEvent == null)
            {
                return;
            }

            GeneratorEjectTabletEvent ev = new GeneratorEjectTabletEvent()
            {
                Player    = player.GetPlayer(),
                Generator = generator,
                Allow     = allow
            };

            GeneratorEjectedEvent.Invoke(ref ev);

            allow = ev.Allow;
        }
Пример #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ClosingGeneratorEventArgs"/> class.
 /// </summary>
 /// <param name="player">The player who's closing the generator.</param>
 /// <param name="generator">The <see cref="Generator079"/> instance.</param>
 /// <param name="isAllowed">Indicates whether the event can be executed or not.</param>
 public ClosingGeneratorEventArgs(Player player, Generator079 generator, bool isAllowed = true)
     : base(player, generator, isAllowed)
 {
 }
Пример #17
0
        private static bool Prefix(Generator079 __instance, GameObject person, string command)
        {
            try
            {
                if (command.StartsWith("EPS_TABLET"))
                {
                    if (__instance.isTabletConnected || !__instance.isDoorOpen || __instance._localTime <= 0.0 ||
                        Generator079.mainGenerator.forcedOvercharge)
                    {
                        return(false);
                    }
                    Inventory component = person.GetComponent <Inventory>();
                    foreach (Inventory.SyncItemInfo syncItemInfo in component.items)
                    {
                        if (syncItemInfo.id == ItemType.WeaponManagerTablet)
                        {
                            var ev = new InsertingGeneratorTabletEventArgs(API.Features.Player.Get(person), __instance);

                            Player.OnInsertingGeneratorTablet(ev);

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

                            component.items.Remove(syncItemInfo);
                            __instance.NetworkisTabletConnected = true;
                            break;
                        }
                    }
                }
                else if (command.StartsWith("EPS_CANCEL"))
                {
                    if (!__instance.isTabletConnected)
                    {
                        return(false);
                    }

                    var ev = new EjectingGeneratorTabletEventArgs(API.Features.Player.Get(person), __instance);

                    Player.OnEjectingGeneratorTablet(ev);

                    if (ev.IsAllowed)
                    {
                        __instance.EjectTablet();
                    }
                }
                else if (command.StartsWith("EPS_DOOR"))
                {
                    Inventory component = person.GetComponent <Inventory>();
                    if (component == null || __instance._doorAnimationCooldown > 0.0 ||
                        __instance._deniedCooldown > 0.0)
                    {
                        return(false);
                    }
                    if (!__instance.isDoorUnlocked)
                    {
                        var ev = new UnlockingGeneratorEventArgs(API.Features.Player.Get(person), __instance, person.GetComponent <ServerRoles>().BypassMode);

                        if (component.curItem > ItemType.KeycardJanitor)
                        {
                            foreach (string permission in component.GetItemByID(component.curItem).permissions)
                            {
                                if (permission == "ARMORY_LVL_2")
                                {
                                    ev.IsAllowed = true;
                                }
                            }
                        }

                        Player.OnUnlockingGenerator(ev);

                        if (ev.IsAllowed)
                        {
                            __instance.NetworkisDoorUnlocked  = true;
                            __instance._doorAnimationCooldown = 0.5f;
                        }
                        else
                        {
                            __instance.RpcDenied();
                        }
                    }
                    else
                    {
                        OpeningGeneratorEventArgs ev;

                        if (!__instance.NetworkisDoorOpen)
                        {
                            ev = new OpeningGeneratorEventArgs(API.Features.Player.Get(person), __instance);

                            Player.OnOpeningGenerator(ev);
                        }
                        else
                        {
                            ev = new ClosingGeneratorEventArgs(API.Features.Player.Get(person), __instance);

                            Player.OnClosingGenerator((ClosingGeneratorEventArgs)ev);
                        }

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

                        __instance._doorAnimationCooldown = 1.5f;
                        __instance.NetworkisDoorOpen      = !__instance.isDoorOpen;
                        __instance.RpcDoSound(__instance.isDoorOpen);
                    }
                }

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

                return(true);
            }
        }
Пример #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="InsertingGeneratorTabletEventArgs"/> class.
 /// </summary>
 /// <param name="player"><inheritdoc cref="Player"/></param>
 /// <param name="generator"><inheritdoc cref="Generator"/></param>
 /// <param name="isAllowed"><inheritdoc cref="IsAllowed"/></param>
 public InsertingGeneratorTabletEventArgs(Player player, Generator079 generator, bool isAllowed = true)
 {
     Player    = player;
     Generator = generator;
     IsAllowed = isAllowed;
 }
Пример #19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OpeningGeneratorEventArgs"/> class.
 /// </summary>
 /// <param name="player"><inheritdoc cref="Player"/></param>
 /// <param name="generator"><inheritdoc cref="Generator"/></param>
 /// <param name="isAllowed"><inheritdoc cref="IsAllowed"/></param>
 public OpeningGeneratorEventArgs(Player player, Generator079 generator, bool isAllowed = true)
 {
     Player    = player;
     Generator = generator;
     IsAllowed = isAllowed;
 }
Пример #20
0
 internal Generator(Generator079 gen, bool main)
 {
     generator     = gen;
     MainGenerator = main;
 }
Пример #21
0
        private static bool Prefix(Generator079 __instance, GameObject person, PlayerInteract.Generator079Operations command)
        {
            try
            {
                API.Features.Player player = API.Features.Player.Get(person);

                switch (command)
                {
                case PlayerInteract.Generator079Operations.Door:
                    bool isAllowed = true;

                    switch (__instance.isDoorOpen)
                    {
                    case false:
                        var openingEventArgs = new OpeningGeneratorEventArgs(player, __instance, isAllowed);

                        Player.OnOpeningGenerator(openingEventArgs);

                        isAllowed = openingEventArgs.IsAllowed;
                        break;

                    case true:
                        var closingEventArgs = new ClosingGeneratorEventArgs(player, __instance, isAllowed);

                        Player.OnClosingGenerator(closingEventArgs);

                        isAllowed = closingEventArgs.IsAllowed;
                        break;
                    }

                    if (isAllowed)
                    {
                        __instance.OpenClose(person);
                    }
                    else
                    {
                        __instance.RpcDenied();
                    }
                    break;

                case PlayerInteract.Generator079Operations.Tablet:
                    if (__instance.isTabletConnected || !__instance.isDoorOpen || (__instance._localTime <= 0.0 || Generator079.mainGenerator.forcedOvercharge))
                    {
                        break;
                    }
                    Inventory component = person.GetComponent <Inventory>();
                    using (SyncList <Inventory.SyncItemInfo> .SyncListEnumerator enumerator = component.items.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            Inventory.SyncItemInfo current = enumerator.Current;
                            if (current.id == ItemType.WeaponManagerTablet)
                            {
                                var insertingEventArgs = new InsertingGeneratorTabletEventArgs(player, __instance);

                                Player.OnInsertingGeneratorTablet(insertingEventArgs);

                                if (insertingEventArgs.IsAllowed)
                                {
                                    component.items.Remove(current);
                                    __instance.NetworkisTabletConnected = true;
                                }

                                break;
                            }
                        }

                        break;
                    }

                case PlayerInteract.Generator079Operations.Cancel:
                    var ejectingEventArgs = new EjectingGeneratorTabletEventArgs(player, __instance);

                    Player.OnEjectingGeneratorTablet(ejectingEventArgs);

                    if (ejectingEventArgs.IsAllowed)
                    {
                        __instance.EjectTablet();
                    }

                    break;
                }

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

                return(true);
            }
        }
Пример #22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GeneratorActivatedEventArgs"/> class.
 /// </summary>
 /// <param name="generator"><inheritdoc cref="Generator"/></param>
 /// <param name="isAllowed"><inheritdoc cref="IsAllowed"/></param>
 public GeneratorActivatedEventArgs(Generator079 generator, bool isAllowed = true)
 {
     Generator = generator;
     IsAllowed = isAllowed;
 }
Пример #23
0
        public static bool Prefix(Generator079 __instance, GameObject person)
        {
            var player = person.GetPlayer();

            var component = person.GetComponent <Inventory>();

            if (component == null || __instance._doorAnimationCooldown > 0f || __instance._deniedCooldown > 0f)
            {
                return(false);
            }

            //Check if the Generator can be open or must be unlocked
            if (__instance.isDoorUnlocked)
            {
                var allow = true;
                if (!__instance.NetworkisDoorOpen)
                {
                    Events.InvokeGeneratorOpen(player, __instance, ref allow);
                }
                else
                {
                    Events.InvokeGeneratorClose(player, __instance, ref allow);
                }

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

                __instance._doorAnimationCooldown = 1.5f;
                __instance.NetworkisDoorOpen      = !__instance.isDoorOpen;
                __instance.RpcDoSound(__instance.isDoorOpen);
                return(false);
            }

            //Unlock The Generator
            var flag  = player.Bypass;
            var flag2 = player.Team != Team.SCP;

            if (flag2 && component.curItem > ItemType.KeycardJanitor)
            {
                var permissions = component.GetItemByID(component.curItem).permissions;

                foreach (var t in permissions)
                {
                    if (t == "ARMORY_LVL_2")
                    {
                        flag = true;
                    }
                }
            }

            Events.InvokeGeneratorUnlock(player, __instance, ref flag);

            if (flag)
            {
                __instance.NetworkisDoorUnlocked  = true;
                __instance._doorAnimationCooldown = 0.5f;
                return(false);
            }
            __instance.RpcDenied();

            return(false);
        }
        public static bool Prefix(Generator079 __instance, GameObject person)
        {
            try
            {
                var player    = person.GetPlayer();
                var generator = __instance.GetGenerator();

                if (player.VanillaInventory == null || __instance._doorAnimationCooldown > 0f || __instance._deniedCooldown > 0f)
                {
                    return(false);
                }

                if (!generator.Locked)
                {
                    var allow = true;
                    if (!generator.Open)
                    {
                        Server.Get.Events.Player.InvokePlayerGeneratorInteractEvent(player, generator, GeneratorInteraction.OpenDoor, ref allow);
                    }
                    else
                    {
                        Server.Get.Events.Player.InvokePlayerGeneratorInteractEvent(player, generator, GeneratorInteraction.CloseDoor, ref allow);
                    }

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

                    generator.Open = !generator.Open;
                    return(false);
                }

                if (!SynapseExtensions.CanHarmScp(player))
                {
                    __instance.RpcDenied();
                    return(false);
                }

                //Unlock The Generator
                var flag = player.Bypass;

                var items = new List <Synapse.Api.Items.SynapseItem>();
                if (Server.Get.Configs.SynapseConfiguration.RemoteKeyCard)
                {
                    items.AddRange(player.Inventory.Items.Where(x => x.ItemCategory == ItemCategory.Keycard));
                }
                else if (player.ItemInHand != null && player.ItemInHand.ItemCategory == ItemCategory.Keycard)
                {
                    items.Add(player.ItemInHand);
                }


                foreach (var item in items)
                {
                    var keycardcanopen = false;
                    var permissions    = player.VanillaInventory.GetItemByID(item.ItemType).permissions;

                    foreach (var t in permissions)
                    {
                        if (t == "ARMORY_LVL_2")
                        {
                            keycardcanopen = true;
                        }
                    }

                    try
                    {
                        Server.Get.Events.Player.InvokePlayerItemUseEvent(player, item, Api.Events.SynapseEventArguments.ItemInteractState.Finalizing, ref keycardcanopen);
                    }
                    catch (Exception e)
                    {
                        Logger.Get.Error($"Synapse-Event: PlayerItemUseEvent(Keycard) failed!!\n{e}\nStackTrace:\n{e.StackTrace}");
                    }

                    if (keycardcanopen)
                    {
                        flag = true;
                        break;
                    }
                }

                Server.Get.Events.Player.InvokePlayerGeneratorInteractEvent(player, generator, GeneratorInteraction.Unlocked, ref flag);

                if (flag)
                {
                    generator.Locked = false;
                    return(false);
                }
                __instance.RpcDenied();

                return(false);
            }
            catch (Exception e)
            {
                Logger.Get.Error($"Synapse-Event: DoorInteract failed!!\n{e}\nStackTrace:\n{e.StackTrace}");
                return(true);
            }
        }
Пример #25
0
 public static Generator GetGenerator(this Generator079 generator079) => Map.Get.Generators.FirstOrDefault(x => x.GameObject == generator079.gameObject);
Пример #26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EjectingGeneratorTabletEventArgs"/> class.
 /// </summary>
 /// <param name="player">The player who's ejecting the tablet.</param>
 /// <param name="generator">The <see cref="Generator079"/> instance.</param>
 /// <param name="isAllowed">Indicates whether the event can be executed or not.</param>
 public EjectingGeneratorTabletEventArgs(Player player, Generator079 generator, bool isAllowed = true)
     : base(player, generator, isAllowed)
 {
 }
Пример #27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GeneratorActivatedEventArgs"/> class.
 /// </summary>
 /// <param name="generator"><inheritdoc cref="Generator"/></param>
 public GeneratorActivatedEventArgs(Generator079 generator) => Generator = generator;
Пример #28
0
        public static bool Prefix(Generator079 __instance, GameObject person, string command)
        {
            if (EventPlugin.Generator079EventPatchDisable)
            {
                return(true);
            }

            try
            {
                if (command.StartsWith("EPS_TABLET"))
                {
                    if (__instance.isTabletConnected || !__instance.isDoorOpen || __instance.localTime <= 0.0 ||
                        Generator079.mainGenerator.forcedOvercharge)
                    {
                        return(false);
                    }
                    Inventory component = person.GetComponent <Inventory>();
                    foreach (Inventory.SyncItemInfo syncItemInfo in component.items)
                    {
                        if (syncItemInfo.id == ItemType.WeaponManagerTablet)
                        {
                            bool allow = true;

                            Events.InvokeGeneratorInsert(person, __instance, ref allow);

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

                            component.items.Remove(syncItemInfo);
                            __instance.NetworkisTabletConnected = true;
                            break;
                        }
                    }
                }
                else if (command.StartsWith("EPS_CANCEL"))
                {
                    if (!__instance.isTabletConnected)
                    {
                        return(false);
                    }
                    bool allow = true;
                    Events.InvokeGeneratorEject(person, __instance, ref allow);
                    if (allow)
                    {
                        __instance.EjectTablet();
                    }
                }
                else if (command.StartsWith("EPS_DOOR"))
                {
                    Inventory component = person.GetComponent <Inventory>();
                    if (component == null || __instance.doorAnimationCooldown > 0.0 || __instance.deniedCooldown > 0.0)
                    {
                        return(false);
                    }
                    if (!__instance.isDoorUnlocked)
                    {
                        bool allow = person.GetComponent <ServerRoles>().BypassMode;
                        if (component.curItem > ItemType.KeycardJanitor)
                        {
                            foreach (string permission in component.GetItemByID(component.curItem).permissions)
                            {
                                if (permission == "ARMORY_LVL_2")
                                {
                                    allow = true;
                                }
                            }
                        }

                        Events.InvokeGeneratorUnlock(person, __instance, ref allow);

                        if (allow)
                        {
                            __instance.NetworkisDoorUnlocked = true;
                            __instance.doorAnimationCooldown = 0.5f;
                        }
                        else
                        {
                            __instance.RpcDenied();
                        }
                    }
                    else
                    {
                        bool allow = true;
                        if (!__instance.NetworkisDoorOpen)
                        {
                            Events.InvokeGeneratorOpen(person, __instance, ref allow);
                        }
                        else
                        {
                            Events.InvokeGeneratorClose(person, __instance, ref allow);
                        }

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

                        __instance.doorAnimationCooldown = 1.5f;
                        __instance.NetworkisDoorOpen     = !__instance.isDoorOpen;
                        __instance.RpcDoSound(__instance.isDoorOpen);
                    }
                }

                return(false);
            }
            catch (Exception exception)
            {
                Log.Error($"GeneratorUnlockEvent/GeneratorOpenedEvent/GeneratorClosedEvent error: {exception}");
                return(true);
            }
        }