diff --git a/EXILED/Exiled.API/Extensions/DoorTypeExtensions.cs b/EXILED/Exiled.API/Extensions/DoorTypeExtensions.cs index a4380d81cf..f8733ac717 100644 --- a/EXILED/Exiled.API/Extensions/DoorTypeExtensions.cs +++ b/EXILED/Exiled.API/Extensions/DoorTypeExtensions.cs @@ -7,34 +7,116 @@ namespace Exiled.API.Extensions { + using System.Collections.Generic; + using System.Linq; + using Exiled.API.Enums; + using Exiled.API.Features.Doors; /// /// A set of extensions for . /// public static class DoorTypeExtensions { + private static readonly List GateEnum = GetEnumByType("Gate"); + + private static readonly List CheckpointEnum = GetEnumByType("Checkpoint"); + + private static readonly List ElevatorEnum = GetEnumByType("Elevator"); + + private static readonly List HIDEnum = GetEnumByType("HID"); + + private static readonly List ScpEnum = GetEnumByType("Scp"); + + private static readonly List EscapeEnum = GetEnumByType("Escape"); + + private static readonly List UnknownEnum = GetEnumByType("Unknown"); + /// /// Checks if a door type is a gate. /// /// The door to be checked. /// Returns whether the is a gate. - public static bool IsGate(this DoorType door) => door is DoorType.GateA or DoorType.GateB or DoorType.Scp914Gate or - DoorType.Scp049Gate or DoorType.GR18Gate or DoorType.SurfaceGate or DoorType.Scp173Gate; + public static bool IsGate(this DoorType door) => GateEnum.Contains(door); /// /// Checks if a door type is a checkpoint. /// /// The door to be checked. /// Returns whether the is a checkpoint. - public static bool IsCheckpoint(this DoorType door) => door is DoorType.CheckpointLczA or DoorType.CheckpointLczB or DoorType.CheckpointEzHczA or DoorType.CheckpointEzHczB; + public static bool IsCheckpoint(this DoorType door) => CheckpointEnum.Contains(door); /// /// Checks if a door type is an elevator. /// /// The door to be checked. /// Returns whether the is an elevator. - public static bool IsElevator(this DoorType door) => door is DoorType.ElevatorGateA or DoorType.ElevatorGateB - or DoorType.ElevatorLczA or DoorType.ElevatorLczB or DoorType.ElevatorNuke or DoorType.ElevatorScp049 or DoorType.ElevatorServerRoom; + public static bool IsElevator(this DoorType door) => ElevatorEnum.Contains(door); + + /// + /// Checks if a door type is an HID door. + /// + /// The door to be checked. + /// Returns whether the is an HID door. + public static bool IsHID(this DoorType door) => HIDEnum.Contains(door); + + /// + /// Checks if a door type is an SCP-related door. + /// + /// The door to be checked. + /// Returns whether the is an SCP-related door. + public static bool IsScp(this DoorType door) => ScpEnum.Contains(door); + + /// + /// Checks if a door type is an escape door. + /// + /// The door to be checked. + /// Returns whether the is an escape door. + public static bool IsEscape(this DoorType door) => EscapeEnum.Contains(door); + + /// + /// Checks if a is located in the Light Containment Zone (LCZ). + /// + /// The door to be checked. + /// Returns true if the is a door from LCZ; otherwise, false. + public static bool IsLCZ(this DoorType door) => door is DoorType.Airlock or DoorType.Scp914Door or DoorType.Scp330 or DoorType.Scp173Armory + or DoorType.Scp173Gate or DoorType.Scp173Connector or DoorType.Scp173Bottom or DoorType.Scp914Gate or DoorType.Scp330Chamber or DoorType.LczWc + or DoorType.LczArmory or DoorType.ElevatorLczA or DoorType.ElevatorLczB or DoorType.CheckpointLczA or DoorType.CheckpointLczB or DoorType.GR18Gate + or DoorType.GR18Inner or DoorType.LczCafe or DoorType.LightContainmentDoor or DoorType.PrisonDoor; + + /// + /// Checks if a is located in the Heavy Containment Zone (HCZ). + /// + /// The door to be checked. + /// Returns true if the is a door from HCZ; otherwise, false. + public static bool IsHCZ(this DoorType door) => door is DoorType.HczArmory or DoorType.Scp049Armory or DoorType.Scp049Gate or DoorType.Scp079Armory + or DoorType.Scp079First or DoorType.Scp079Second or DoorType.Scp096 or DoorType.Scp106Primary or DoorType.Scp106Secondary or DoorType.Scp173NewGate + or DoorType.Scp939Cryo or DoorType.ElevatorScp049 or DoorType.HeavyBulkDoor or DoorType.HeavyContainmentDoor or DoorType.HIDChamber or DoorType.HIDLab + or DoorType.Hcz127Lab or DoorType.CheckpointEzHczA or DoorType.CheckpointEzHczB or DoorType.CheckpointGateA or DoorType.CheckpointGateB; + + /// + /// Checks if a is located in the Entrance Zone (EZ). + /// + /// The door to be checked. + /// Returns true if the is a door from EZ; otherwise, false. + public static bool IsEZ(this DoorType door) => door is DoorType.GateA or DoorType.GateB or DoorType.ElevatorGateA or DoorType.ElevatorGateB + or DoorType.CheckpointEzHczA or DoorType.CheckpointEzHczB or DoorType.CheckpointGateA or DoorType.CheckpointGateB or DoorType.Intercom; + + /// + /// Checks if a is located on the Surface. + /// + /// The door to be checked. + /// Returns true if the is a door from Surface; otherwise, false. + public static bool IsSurface(this DoorType door) => door is DoorType.SurfaceGate or DoorType.NukeSurface + or DoorType.EscapePrimary or DoorType.EscapeSecondary or DoorType.EscapeFinal; + + /// + /// Checks if a is of an unknown type. + /// + /// The door to be checked. + /// Returns true if the is unknown; otherwise, false. + public static bool IsUnknown(this DoorType door) => UnknownEnum.Contains(door); + + private static List GetEnumByType(string doorName) => EnumUtils.Values.Where(x => x.ToString().Contains(doorName)).ToList(); } } \ No newline at end of file