コード例 #1
0
ファイル: EmpGrenade.cs プロジェクト: 4310V343k/CustomItems
        private void OnExplodingGrenade(ExplodingGrenadeEventArgs ev)
        {
            if (!Check(ev.Grenade))
            {
                return;
            }

            ev.IsAllowed = false;

            Room room = Exiled.API.Features.Map.FindParentRoom(ev.Grenade);

            Log.Debug($"{ev.Grenade.transform.position} - {room.Position} - {Exiled.API.Features.Map.Rooms.Count}", CustomItems.Instance.Config.IsDebugEnabled);

            LockedRooms079.Add(room);

            room.TurnOffLights(Duration);

            Log.Debug($"{room.Doors.Count()} - {room.Type}", CustomItems.Instance.Config.IsDebugEnabled);

            foreach (DoorVariant door in room.Doors)
            {
                if (door == null ||
                    (!string.IsNullOrEmpty(door.GetNametag()) && BlacklistedDoorNames.Contains(door.GetNametag())) ||
                    (door.NetworkActiveLocks > 0 && !OpenLockedDoors) ||
                    (door.RequiredPermissions.RequiredPermissions != KeycardPermissions.None && !OpenKeycardDoors))
                {
                    continue;
                }

                Log.Debug("Opening a door!", CustomItems.Instance.Config.IsDebugEnabled);

                door.NetworkTargetState = true;
                door.ServerChangeLock(DoorLockReason.NoPower, true);

                if (lockedDoors.Contains(door))
                {
                    lockedDoors.Add(door);
                }

                Timing.CallDelayed(Duration, () =>
                {
                    door.ServerChangeLock(DoorLockReason.NoPower, false);
                    lockedDoors.Remove(door);
                });
            }

            foreach (Player player in Player.Get(RoleType.Scp079))
            {
                if (player.Camera != null && player.Camera.Room() == room)
                {
                    player.SetCamera(198);
                }
            }

            Timing.CallDelayed(Duration, () => LockedRooms079.Remove(room));
        }
コード例 #2
0
ファイル: EmpGrenade.cs プロジェクト: Michal78900/CustomItems
        /// <inheritdoc/>
        protected override void OnExploding(ExplodingGrenadeEventArgs ev)
        {
            ev.IsAllowed = false;
            Room      room = Exiled.API.Features.Map.FindParentRoom(ev.Grenade.gameObject);
            TeslaGate gate = null;

            Log.Debug($"{ev.Grenade.transform.position} - {room.Position} - {Room.List.Count()}", CustomItems.Instance.Config.IsDebugEnabled);

            LockedRooms079.Add(room);

            room.TurnOffLights(Duration);

            if (DisableTeslaGates)
            {
                foreach (TeslaGate teslaGate in TeslaGate.List)
                {
                    if (Exiled.API.Features.Map.FindParentRoom(teslaGate.GameObject) == room)
                    {
                        disabledTeslaGates.Add(teslaGate);
                        gate = teslaGate;
                        break;
                    }
                }
            }

            Log.Debug($"{room.Doors.Count()} - {room.Type}", CustomItems.Instance.Config.IsDebugEnabled);

            foreach (Door door in room.Doors)
            {
                if (door == null ||
                    (!string.IsNullOrEmpty(door.Nametag) && BlacklistedDoorNames.Contains(door.Nametag)) ||
                    (door.DoorLockType > 0 && !OpenLockedDoors) ||
                    (door.RequiredPermissions.RequiredPermissions != KeycardPermissions.None && !OpenKeycardDoors))
                {
                    continue;
                }

                Log.Debug("Opening a door!", CustomItems.Instance.Config.IsDebugEnabled);

                door.IsOpen = true;
                door.ChangeLock(DoorLockType.NoPower);

                if (!lockedDoors.Contains(door))
                {
                    lockedDoors.Add(door);
                }

                Timing.CallDelayed(Duration, () =>
                {
                    door.Unlock();
                    lockedDoors.Remove(door);
                });
            }

            foreach (Player player in Player.List)
            {
                if (player.Role.As <Scp079Role>() is Scp079Role scp079)
                {
                    if (scp079.Camera != null && scp079.Camera.Room == room)
                    {
                        scp079.SetCamera(198);
                    }
                }

                if (player.CurrentRoom != room)
                {
                    continue;
                }

                foreach (Item item in player.Items)
                {
                    switch (item)
                    {
                    case Radio radio:
                        radio.Disable();
                        break;

                    case Flashlight flashlight:
                        flashlight.Active = false;
                        break;

                    case Firearm firearm:
                    {
                        foreach (FirearmAttachment attachment in firearm.Attachments)
                        {
                            if (attachment.Name == AttachmentNameTranslation.Flashlight)
                            {
                                attachment.IsEnabled = false;
                            }
                        }
                        break;
                    }
                    }
                }
            }

            Timing.CallDelayed(Duration, () =>
            {
                try
                {
                    LockedRooms079.Remove(room);
                }
                catch (Exception e)
                {
                    Log.Debug($"REMOVING LOCKED ROOM: {e}");
                }

                if (gate != null)
                {
                    try
                    {
                        disabledTeslaGates.Remove(gate);
                    }
                    catch (Exception e)
                    {
                        Log.Debug($"REMOVING DISABLED TESLA: {e}");
                    }
                }
            });
        }
コード例 #3
0
        private void OnExplodingGrenade(ExplodingGrenadeEventArgs ev)
        {
            if (!Check(ev.Grenade))
            {
                return;
            }

            ev.IsAllowed = false;

            Room      room = Exiled.API.Features.Map.FindParentRoom(ev.Grenade);
            TeslaGate gate = null;

            Log.Debug($"{ev.Grenade.transform.position} - {room.Position} - {Exiled.API.Features.Map.Rooms.Count}", CustomItems.Instance.Config.IsDebugEnabled);

            LockedRooms079.Add(room);

            room.TurnOffLights(Duration);

            if (DisableTeslaGates)
            {
                foreach (TeslaGate teslaGate in Exiled.API.Features.Map.TeslaGates)
                {
                    if (Exiled.API.Features.Map.FindParentRoom(teslaGate.gameObject) == room)
                    {
                        disabledTeslaGates.Add(teslaGate);
                        gate = teslaGate;
                        break;
                    }
                }
            }

            Log.Debug($"{room.Doors.Count()} - {room.Type}", CustomItems.Instance.Config.IsDebugEnabled);

            foreach (DoorVariant door in room.Doors)
            {
                if (door == null ||
                    (!string.IsNullOrEmpty(door.GetNametag()) && BlacklistedDoorNames.Contains(door.GetNametag())) ||
                    (door.NetworkActiveLocks > 0 && !OpenLockedDoors) ||
                    (door.RequiredPermissions.RequiredPermissions != KeycardPermissions.None && !OpenKeycardDoors))
                {
                    continue;
                }

                Log.Debug("Opening a door!", CustomItems.Instance.Config.IsDebugEnabled);

                door.NetworkTargetState = true;
                door.ServerChangeLock(DoorLockReason.NoPower, true);

                if (lockedDoors.Contains(door))
                {
                    lockedDoors.Add(door);
                }

                Timing.CallDelayed(Duration, () =>
                {
                    door.ServerChangeLock(DoorLockReason.NoPower, false);
                    lockedDoors.Remove(door);
                });
            }

            foreach (Player player in Player.List)
            {
                if (player.Role == RoleType.Scp079)
                {
                    if (player.Camera != null && player.Camera.Room() == room)
                    {
                        player.SetCamera(198);
                    }
                }
                if (player.CurrentRoom != room)
                {
                    continue;
                }

                foreach (Inventory.SyncItemInfo item in player.ReferenceHub.inventory.items)
                {
                    if (item.id == ItemType.Radio)
                    {
                        player.ReferenceHub.inventory.items.ModifyDuration(player.ReferenceHub.GetComponent <Radio>().myRadio, 0f);
                    }
                    else if (player.ReferenceHub.weaponManager.syncFlash)
                    {
                        player.ReferenceHub.weaponManager.syncFlash = false;
                    }
                }
            }

            Timing.CallDelayed(Duration, () =>
            {
                LockedRooms079.Remove(room);
                if (gate != null)
                {
                    disabledTeslaGates.Remove(gate);
                }
            });
        }