Пример #1
0
 private static void HandleGeneratorInsert(InsertingGeneratorTabletEventArgs ev)
 {
     if (!Plugin.Config.GeneratorInsertTeams.Contains(ev.Player.Team))
     {
         ev.IsAllowed = false;
     }
 }
Пример #2
0
 public void OnGeneratorInsert(InsertingGeneratorTabletEventArgs ev)
 {
     if (shPlayers.Contains(ev.Player.Id) && !SerpentsHand.instance.Config.FriendlyFire)
     {
         ev.IsAllowed = false;
     }
 }
Пример #3
0
 internal void OnAddTablet(InsertingGeneratorTabletEventArgs ev)
 {
     if (!config.Generator.canInsertTabletGlobal && !config.Generator.canInsertTablet[ev.Player.Role])
     {
         ev.IsAllowed = false;
     }
 }
#pragma warning disable SA1600 // Elements should be documented
        public async void OnInsertingGeneratorTablet(InsertingGeneratorTabletEventArgs ev)
        {
            if (Instance.Config.EventsToLog.PlayerInsertingGeneratorTablet && (!ev.Player.DoNotTrack || !Instance.Config.ShouldRespectDoNotTrack))
            {
                await Network.SendAsync(new RemoteCommand("log", "gameEvents", string.Format(Language.GeneratorInserted, ev.Player.Nickname, Instance.Config.ShouldLogUserIds ? ev.Player.UserId : Language.Redacted, ev.Player.Role))).ConfigureAwait(false);
            }
        }
Пример #5
0
 private static void OnInsertingGeneratorTablet(InsertingGeneratorTabletEventArgs ev)
 {
     if (_player == ev.Player && !_config.ScpFriendlyFire)
     {
         ev.IsAllowed = false;
     }
 }
Пример #6
0
 // Token: 0x0600000D RID: 13 RVA: 0x00002690 File Offset: 0x00000890
 private static void HandleGeneratorInsert(InsertingGeneratorTabletEventArgs ev)
 {
     if (SameThings.GeneratorInsertTeams.Count == 0)
     {
         return;
     }
     ev.IsAllowed = SameThings.GeneratorInsertTeams.Contains((int)ev.Player.Team);
 }
Пример #7
0
        internal void InsertingGeneratorTablet(InsertingGeneratorTabletEventArgs ev)
        {
            if (Plugin.Instance.Config.InsertingGeneratorTablet == "")
            {
                return;
            }
            string message = Plugin.Instance.Config.InsertingGeneratorTablet.Replace("%player%", ev.Player.ToString());


            if (Plugin.Instance.Config.debug_to_console)
            {
                Log.Debug(message: "[ " + Plugin.Instance.Config.player_name + "] " + message);
            }
            Plugin.sendWebHook(Plugin.Instance.Config.player_url, message, Plugin.Instance.Config.player_name);
        }
Пример #8
0
 /// <summary>
 /// Called before inserting a generator.
 /// </summary>
 /// <param name="ev">The <see cref="InsertingGeneratorTabletEventArgs"/> instance.</param>
 public static void OnInsertingGeneratorTablet(InsertingGeneratorTabletEventArgs ev) => InsertingGeneratorTablet.InvokeSafely(ev);
Пример #9
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);
            }
        }
Пример #10
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);
            }
        }
Пример #11
0
 public void OnInsertingGeneratorTablet(InsertingGeneratorTabletEventArgs ev)
 {
     CheckForEvent("OnRoundStarting", true, false, ev.Player);
 }