From b33f211bf0f20e8a082f3c0e014470742a9feb1d Mon Sep 17 00:00:00 2001 From: VALERA771 <72030575+VALERA771@users.noreply.github.com> Date: Fri, 10 Jan 2025 23:40:58 +0300 Subject: [PATCH] feat: LockerType extension (#384) * feat: LockerType extension * fix: fix of fix * fix: init fix for play gun sound * Revert "fix: init fix for play gun sound" This reverts commit f4d55418d2f782d46465c9dc7f8153f5fa0c2145. --- EXILED/Exiled.API/Enums/LockerType.cs | 63 +++++++++++++++++++ .../Exiled.API/Extensions/LockerExtensions.cs | 15 ++++- EXILED/Exiled.API/Features/Lockers/Locker.cs | 11 +++- 3 files changed, 85 insertions(+), 4 deletions(-) diff --git a/EXILED/Exiled.API/Enums/LockerType.cs b/EXILED/Exiled.API/Enums/LockerType.cs index ca176fb21..b38b592c0 100644 --- a/EXILED/Exiled.API/Enums/LockerType.cs +++ b/EXILED/Exiled.API/Enums/LockerType.cs @@ -7,6 +7,8 @@ namespace Exiled.API.Enums { + using System; + /// /// Unique identifier for different types of s. /// @@ -15,6 +17,7 @@ public enum LockerType /// /// The pedestal used by SCP items. /// + [Obsolete("This value is not used.")] Pedestal, /// @@ -46,5 +49,65 @@ public enum LockerType /// Unknow type of locker. /// Unknow, + + /// + /// MircoHid pedestal. + /// + MicroHid, + + /// + /// Experimental weapon locker. + /// + ExperimentalWeapon, + + /// + /// SCP-500 pedestal. + /// + Scp500Pedestal, + + /// + /// SCP-207? (Anti SCP-207) pedestal. + /// + AntiScp207Pedestal, + + /// + /// SCP-207 pedestal. + /// + Scp207Pedestal, + + /// + /// SCP-268 pedestal. + /// + Scp268Pedestal, + + /// + /// SCP-1344 pedestal. + /// + Scp1344Pedestal, + + /// + /// SCP-018 pedestal. + /// + Scp018Pedestal, + + /// + /// SCP-1576 pedestal. + /// + Scp1576Pedestal, + + /// + /// SCP-244 pedestal. + /// + Scp244Pedestal, + + /// + /// SCP-2176 pedestal. + /// + Scp2176Pedestal, + + /// + /// SCP-1853 pedestal. + /// + Scp1853Pedestal, } } diff --git a/EXILED/Exiled.API/Extensions/LockerExtensions.cs b/EXILED/Exiled.API/Extensions/LockerExtensions.cs index c7c1a78ab..bdf3689bb 100644 --- a/EXILED/Exiled.API/Extensions/LockerExtensions.cs +++ b/EXILED/Exiled.API/Extensions/LockerExtensions.cs @@ -29,14 +29,25 @@ public static class LockerExtensions /// /// The name to check. /// The corresponding . - public static LockerType GetLockerTypeByName(this string name) => name.Replace("(Clone)", string.Empty) switch + public static LockerType GetLockerTypeByName(this string name) => name.Split('(')[0].Trim() switch { - "Scp500PedestalStructure Variant" => LockerType.Pedestal, + "Scp500PedestalStructure Variant" => LockerType.Scp500Pedestal, + "AntiScp207PedestalStructure Variant" => LockerType.AntiScp207Pedestal, + "Scp207PedestalStructure Variant" => LockerType.Scp207Pedestal, + "Experimental Weapon Locker" => LockerType.ExperimentalWeapon, + "Scp1344PedestalStructure Variant" => LockerType.Scp1344Pedestal, + "Scp1576PedestalStructure Variant" => LockerType.Scp1576Pedestal, + "Scp2176PedestalStructure Variant" => LockerType.Scp2176Pedestal, + "Scp1853PedestalStructure Variant" => LockerType.Scp1853Pedestal, + "Scp268PedestalStructure Variant" => LockerType.Scp268Pedestal, + "Scp244PedestalStructure Variant" => LockerType.Scp244Pedestal, + "Scp018PedestalStructure Variant" => LockerType.Scp018Pedestal, "LargeGunLockerStructure" => LockerType.LargeGun, "RifleRackStructure" => LockerType.RifleRack, "MiscLocker" => LockerType.Misc, "RegularMedkitStructure" => LockerType.Medkit, "AdrenalineMedkitStructure" => LockerType.Adrenaline, + "MicroHIDpedestal" => LockerType.MicroHid, _ => LockerType.Unknow, }; } diff --git a/EXILED/Exiled.API/Features/Lockers/Locker.cs b/EXILED/Exiled.API/Features/Lockers/Locker.cs index 739015590..3b5dfe7c1 100644 --- a/EXILED/Exiled.API/Features/Lockers/Locker.cs +++ b/EXILED/Exiled.API/Features/Lockers/Locker.cs @@ -110,7 +110,7 @@ public Vector3 RandomChamberPosition Chamber randomChamber = Chambers.GetRandomValue(); // Determine if the chamber uses multiple spawn points and has at least one available spawn point. - if (randomChamber.UseMultipleSpawnpoints && randomChamber.Spawnpoints.Count() > 0) + if (randomChamber.UseMultipleSpawnpoints && randomChamber.Spawnpoints.Any()) { // Return the position of a random spawn point within the chamber. return randomChamber.Spawnpoints.GetRandomValue().position; @@ -136,11 +136,18 @@ public Vector3 RandomChamberPosition /// The with the given or if not found. public static IEnumerable Get(ZoneType zoneType) => Get(room => room.Zone.HasFlag(zoneType)); + /// + /// Gets an of given the specified . + /// + /// The to search for. + /// An of which contains elements that satisfy the condition. + public static IEnumerable Get(LockerType lockerType) => Get(x => x.Type == lockerType); + /// /// Gets a of filtered based on a predicate. /// /// The condition to satify. - /// A of which contains elements that satify the condition. + /// A of which contains elements that satisfy the condition. public static IEnumerable Get(Func predicate) => List.Where(predicate); ///