diff --git a/LabApi/Events/Arguments/Interfaces/IItemEvent.cs b/LabApi/Events/Arguments/Interfaces/IItemEvent.cs index 5c3b2901..cea0e79b 100644 --- a/LabApi/Events/Arguments/Interfaces/IItemEvent.cs +++ b/LabApi/Events/Arguments/Interfaces/IItemEvent.cs @@ -1,4 +1,5 @@ using LabApi.Features.Wrappers; + namespace LabApi.Events.Arguments.Interfaces; /// diff --git a/LabApi/Events/Arguments/Interfaces/IPickupEvent.cs b/LabApi/Events/Arguments/Interfaces/IPickupEvent.cs index 78745bd1..06e6fb4c 100644 --- a/LabApi/Events/Arguments/Interfaces/IPickupEvent.cs +++ b/LabApi/Events/Arguments/Interfaces/IPickupEvent.cs @@ -1,4 +1,5 @@ using LabApi.Features.Wrappers; + namespace LabApi.Events.Arguments.Interfaces; /// diff --git a/LabApi/Events/Arguments/Interfaces/IPlayerEvent.cs b/LabApi/Events/Arguments/Interfaces/IPlayerEvent.cs index 8b667313..8a87a73c 100644 --- a/LabApi/Events/Arguments/Interfaces/IPlayerEvent.cs +++ b/LabApi/Events/Arguments/Interfaces/IPlayerEvent.cs @@ -1,4 +1,5 @@ using LabApi.Features.Wrappers; + namespace LabApi.Events.Arguments.Interfaces; /// diff --git a/LabApi/Events/Arguments/Interfaces/IUsableItem.cs b/LabApi/Events/Arguments/Interfaces/IUsableItem.cs index a032b63c..26ee0ed8 100644 --- a/LabApi/Events/Arguments/Interfaces/IUsableItem.cs +++ b/LabApi/Events/Arguments/Interfaces/IUsableItem.cs @@ -3,7 +3,7 @@ namespace LabApi.Events.Arguments.Interfaces; /// -/// Represents an event that involves an usable item. +/// Represents an event that involves a usable item. /// public interface IUsableItem { diff --git a/LabApi/Events/Arguments/PlayerEvents/PlayerAimedWeaponEventArgs.cs b/LabApi/Events/Arguments/PlayerEvents/PlayerAimedWeaponEventArgs.cs index 1a3c908b..8fc57473 100644 --- a/LabApi/Events/Arguments/PlayerEvents/PlayerAimedWeaponEventArgs.cs +++ b/LabApi/Events/Arguments/PlayerEvents/PlayerAimedWeaponEventArgs.cs @@ -16,7 +16,7 @@ public class PlayerAimedWeaponEventArgs : EventArgs, IPlayerEvent, IWeaponEvent /// /// The player who aimed the weapon. /// The weapon that the player aimed. - /// Whether or not the player was aiming or unaiming their weapon. + /// Whether the player was aiming or unaiming their weapon. public PlayerAimedWeaponEventArgs(ReferenceHub player, ItemBase weapon, bool aiming) { Player = Player.Get(player); @@ -30,7 +30,7 @@ public PlayerAimedWeaponEventArgs(ReferenceHub player, ItemBase weapon, bool aim public Player Player { get; } /// - /// Whether or not the player is aiming or unaiming. + /// Whether the player is aiming or unaiming. /// public bool Aiming { get; } diff --git a/LabApi/Events/Arguments/PlayerEvents/PlayerCancelledUsingItemEventArgs.cs b/LabApi/Events/Arguments/PlayerEvents/PlayerCancelledUsingItemEventArgs.cs index 5daefbd6..b93f29db 100644 --- a/LabApi/Events/Arguments/PlayerEvents/PlayerCancelledUsingItemEventArgs.cs +++ b/LabApi/Events/Arguments/PlayerEvents/PlayerCancelledUsingItemEventArgs.cs @@ -1,5 +1,4 @@ -using InventorySystem.Items.Usables; -using LabApi.Events.Arguments.Interfaces; +using LabApi.Events.Arguments.Interfaces; using LabApi.Features.Wrappers; using System; using UsableItem = InventorySystem.Items.Usables.UsableItem; diff --git a/LabApi/Events/Arguments/PlayerEvents/PlayerCancellingUsingItemEventArgs.cs b/LabApi/Events/Arguments/PlayerEvents/PlayerCancellingUsingItemEventArgs.cs index dbf7848c..62b40adf 100644 --- a/LabApi/Events/Arguments/PlayerEvents/PlayerCancellingUsingItemEventArgs.cs +++ b/LabApi/Events/Arguments/PlayerEvents/PlayerCancellingUsingItemEventArgs.cs @@ -1,5 +1,4 @@ -using InventorySystem.Items.Usables; -using LabApi.Events.Arguments.Interfaces; +using LabApi.Events.Arguments.Interfaces; using LabApi.Features.Wrappers; using System; using UsableItem = InventorySystem.Items.Usables.UsableItem; diff --git a/LabApi/Events/Arguments/PlayerEvents/PlayerEffectUpdatedEventArgs.cs b/LabApi/Events/Arguments/PlayerEvents/PlayerEffectUpdatedEventArgs.cs index 4bf3a4d6..8f40efab 100644 --- a/LabApi/Events/Arguments/PlayerEvents/PlayerEffectUpdatedEventArgs.cs +++ b/LabApi/Events/Arguments/PlayerEvents/PlayerEffectUpdatedEventArgs.cs @@ -6,7 +6,7 @@ namespace LabApi.Events.Arguments.PlayerEvents; /// -/// Represents the arguments for the event. +/// Represents the arguments for the event. /// public class PlayerEffectUpdatedEventArgs : EventArgs, IPlayerEvent { diff --git a/LabApi/Events/Arguments/PlayerEvents/PlayerEscapedEventArgs.cs b/LabApi/Events/Arguments/PlayerEvents/PlayerEscapedEventArgs.cs index 7aebc7e2..bd427268 100644 --- a/LabApi/Events/Arguments/PlayerEvents/PlayerEscapedEventArgs.cs +++ b/LabApi/Events/Arguments/PlayerEvents/PlayerEscapedEventArgs.cs @@ -16,11 +16,12 @@ public class PlayerEscapedEventArgs : EventArgs, IPlayerEvent /// /// The player who escaped. /// The new role. - /// The amount of tokens granted to team after escape. + /// The scenario of the escape. public PlayerEscapedEventArgs(ReferenceHub player, RoleTypeId newRole, EscapeScenarioType escapeScenarioType) { Player = Player.Get(player); NewRole = newRole; + EscapeScenarioType = escapeScenarioType; } /// diff --git a/LabApi/Events/Arguments/PlayerEvents/PlayerEscapingEventArgs.cs b/LabApi/Events/Arguments/PlayerEvents/PlayerEscapingEventArgs.cs index 284a1889..44db8e60 100644 --- a/LabApi/Events/Arguments/PlayerEvents/PlayerEscapingEventArgs.cs +++ b/LabApi/Events/Arguments/PlayerEvents/PlayerEscapingEventArgs.cs @@ -16,8 +16,7 @@ public class PlayerEscapingEventArgs : EventArgs, ICancellableEvent /// /// The player who is escaping. /// The new role that is set after escape. - /// The team that will be granted tickets. - /// The amount of tokens granted to team after escape. + /// The scenario of the escape. public PlayerEscapingEventArgs(ReferenceHub player, RoleTypeId newRole, EscapeScenarioType escapeScenario) { IsAllowed = true; diff --git a/LabApi/Events/Arguments/PlayerEvents/PlayerLeavingPocketDimensionEventArgs.cs b/LabApi/Events/Arguments/PlayerEvents/PlayerLeavingPocketDimensionEventArgs.cs index 572ba421..e480979c 100644 --- a/LabApi/Events/Arguments/PlayerEvents/PlayerLeavingPocketDimensionEventArgs.cs +++ b/LabApi/Events/Arguments/PlayerEvents/PlayerLeavingPocketDimensionEventArgs.cs @@ -37,7 +37,7 @@ public PlayerLeavingPocketDimensionEventArgs(ReferenceHub player, PocketDimensio public PocketTeleport? Teleport { get; } /// - /// Gets whether it is gonna be success. + /// Gets or sets whether it is going to be success. /// public bool IsSuccessful { get; set; } diff --git a/LabApi/Events/Arguments/PlayerEvents/PlayerPickingUpAmmoEventArgs.cs b/LabApi/Events/Arguments/PlayerEvents/PlayerPickingUpAmmoEventArgs.cs index 3bc89c21..b37758f2 100644 --- a/LabApi/Events/Arguments/PlayerEvents/PlayerPickingUpAmmoEventArgs.cs +++ b/LabApi/Events/Arguments/PlayerEvents/PlayerPickingUpAmmoEventArgs.cs @@ -13,8 +13,8 @@ public class PlayerPickingUpAmmoEventArgs : EventArgs, ICancellableEvent /// /// Initializes a new instance of the class. /// - /// The player who is pickup the the ammo pickup. - /// Type of the ammo./param> + /// The player who is pickup the ammo pickup. + /// Type of the ammo. /// Amount of ammo that is being picked up. /// Ammo pickup. public PlayerPickingUpAmmoEventArgs(ReferenceHub player, ItemType ammoType, ushort ammoAmount, ItemPickupBase pickup) @@ -27,7 +27,7 @@ public PlayerPickingUpAmmoEventArgs(ReferenceHub player, ItemType ammoType, usho } /// - /// Gets the player who is pickup the the ammo pickup. + /// Gets the player who is picking up the ammo pickup. /// public Player Player { get; } diff --git a/LabApi/Events/Arguments/PlayerEvents/PlayerPreAuthenticatedEventArgs.cs b/LabApi/Events/Arguments/PlayerEvents/PlayerPreAuthenticatedEventArgs.cs index 50e385b0..05b2294d 100644 --- a/LabApi/Events/Arguments/PlayerEvents/PlayerPreAuthenticatedEventArgs.cs +++ b/LabApi/Events/Arguments/PlayerEvents/PlayerPreAuthenticatedEventArgs.cs @@ -11,7 +11,6 @@ public class PlayerPreAuthenticatedEventArgs : EventArgs /// /// Initializes a new instance of the class. /// - /// Whenever the player can join. /// User ID of the player. /// IP Address the of player. /// Expiration of the authentication. diff --git a/LabApi/Events/Arguments/PlayerEvents/PlayerPreAuthenticatingEventArgs.cs b/LabApi/Events/Arguments/PlayerEvents/PlayerPreAuthenticatingEventArgs.cs index d6953c93..7eace2d9 100644 --- a/LabApi/Events/Arguments/PlayerEvents/PlayerPreAuthenticatingEventArgs.cs +++ b/LabApi/Events/Arguments/PlayerEvents/PlayerPreAuthenticatingEventArgs.cs @@ -13,7 +13,7 @@ public class PlayerPreAuthenticatingEventArgs : EventArgs, ICancellableEvent /// /// Initializes a new instance of the class. /// - /// Whenever the player can join. + /// Whether the player can join. /// User ID of the player. /// IP Address the of player. /// Expiration of the authentication. diff --git a/LabApi/Events/Arguments/PlayerEvents/PlayerReportedPlayerEventArgs.cs b/LabApi/Events/Arguments/PlayerEvents/PlayerReportedPlayerEventArgs.cs index bacbe4f8..c2fa1535 100644 --- a/LabApi/Events/Arguments/PlayerEvents/PlayerReportedPlayerEventArgs.cs +++ b/LabApi/Events/Arguments/PlayerEvents/PlayerReportedPlayerEventArgs.cs @@ -7,7 +7,7 @@ namespace LabApi.Events.Arguments.PlayerEvents; /// /// Represents the arguments for the event. /// -public class PlayerReportedPlayerEventArgs : EventArgs, IPlayerEvent +public class PlayerReportedPlayerEventArgs : EventArgs, IPlayerEvent, ITargetEvent { /// /// Initializes a new instance of the class. diff --git a/LabApi/Events/Arguments/PlayerEvents/PlayerReportingCheaterEventArgs.cs b/LabApi/Events/Arguments/PlayerEvents/PlayerReportingCheaterEventArgs.cs index 0e373c6c..a0415daa 100644 --- a/LabApi/Events/Arguments/PlayerEvents/PlayerReportingCheaterEventArgs.cs +++ b/LabApi/Events/Arguments/PlayerEvents/PlayerReportingCheaterEventArgs.cs @@ -7,7 +7,7 @@ namespace LabApi.Events.Arguments.PlayerEvents; /// /// Represents the arguments for the event. /// -public class PlayerReportingCheaterEventArgs : EventArgs, IPlayerEvent, ICancellableEvent +public class PlayerReportingCheaterEventArgs : EventArgs, IPlayerEvent, ITargetEvent, ICancellableEvent { /// /// Initializes a new instance of the class. diff --git a/LabApi/Events/Arguments/PlayerEvents/PlayerTogglingNoclipEventArgs.cs b/LabApi/Events/Arguments/PlayerEvents/PlayerTogglingNoclipEventArgs.cs index d6bd3a53..da70a0de 100644 --- a/LabApi/Events/Arguments/PlayerEvents/PlayerTogglingNoclipEventArgs.cs +++ b/LabApi/Events/Arguments/PlayerEvents/PlayerTogglingNoclipEventArgs.cs @@ -31,9 +31,9 @@ public PlayerTogglingNoclipEventArgs(ReferenceHub player, bool newState) public bool NewNoclipState { get; } /// - /// Whether the event is allowed to run.
- /// This value is assigned on based on whether the player has noclip permitted. So it may not be allowed by default for some players. + /// Whether the event is allowed to run. ///
+ /// This value is assigned on based on whether the player has noclip permitted. So it may not be allowed by default for some players. public bool IsAllowed { get; set; } } } diff --git a/LabApi/Events/Arguments/Scp079Events/Scp079BlackingOutZoneEventArgs.cs b/LabApi/Events/Arguments/Scp079Events/Scp079BlackingOutZoneEventArgs.cs index 9ee4f724..c5094b39 100644 --- a/LabApi/Events/Arguments/Scp079Events/Scp079BlackingOutZoneEventArgs.cs +++ b/LabApi/Events/Arguments/Scp079Events/Scp079BlackingOutZoneEventArgs.cs @@ -21,6 +21,7 @@ public Scp079BlackingOutZoneEventArgs(ReferenceHub player, FacilityZone zone) Zone = zone; IsAllowed = true; } + /// /// The SCP-079 player instance. /// diff --git a/LabApi/Events/Arguments/Scp079Events/Scp079ChangedCameraEventArgs.cs b/LabApi/Events/Arguments/Scp079Events/Scp079ChangedCameraEventArgs.cs index 0efb0af4..eb14eb65 100644 --- a/LabApi/Events/Arguments/Scp079Events/Scp079ChangedCameraEventArgs.cs +++ b/LabApi/Events/Arguments/Scp079Events/Scp079ChangedCameraEventArgs.cs @@ -20,6 +20,7 @@ public Scp079ChangedCameraEventArgs(ReferenceHub player, Scp079Camera camera) Player = Player.Get(player); Camera = camera; } + /// /// The SCP-079 player instance. /// diff --git a/LabApi/Events/Arguments/ServerEvents/GrenadeExplodedEventArgs.cs b/LabApi/Events/Arguments/ServerEvents/GrenadeExplodedEventArgs.cs index 58f21278..666c2e4c 100644 --- a/LabApi/Events/Arguments/ServerEvents/GrenadeExplodedEventArgs.cs +++ b/LabApi/Events/Arguments/ServerEvents/GrenadeExplodedEventArgs.cs @@ -40,6 +40,6 @@ public GrenadeExplodedEventArgs(ExplosionGrenade grenade, ReferenceHub player, V /// /// Gets if grenade should destroy doors. - /// + ///
public bool ExplodeDoors { get; } } diff --git a/LabApi/Events/Arguments/ServerEvents/GrenadeExplodingEventArgs.cs b/LabApi/Events/Arguments/ServerEvents/GrenadeExplodingEventArgs.cs index 64fc449f..7b0c72b3 100644 --- a/LabApi/Events/Arguments/ServerEvents/GrenadeExplodingEventArgs.cs +++ b/LabApi/Events/Arguments/ServerEvents/GrenadeExplodingEventArgs.cs @@ -42,7 +42,7 @@ public GrenadeExplodingEventArgs(ExplosionGrenade grenade, ReferenceHub player, /// /// Gets or sets if grenade should destroy doors. - /// + ///
public bool ExplodeDoors { get; set; } = true; /// diff --git a/LabApi/Events/Arguments/ServerEvents/WaveRespawningEventArgs.cs b/LabApi/Events/Arguments/ServerEvents/WaveRespawningEventArgs.cs index e4dd6a56..e5263217 100644 --- a/LabApi/Events/Arguments/ServerEvents/WaveRespawningEventArgs.cs +++ b/LabApi/Events/Arguments/ServerEvents/WaveRespawningEventArgs.cs @@ -12,6 +12,8 @@ namespace LabApi.Events.Arguments.ServerEvents; ///
public class WaveRespawningEventArgs : EventArgs, ICancellableEvent { + private readonly Dictionary _roles; + /// /// Initializes a new instance of the class. /// @@ -37,8 +39,6 @@ public WaveRespawningEventArgs(Team team, Dictionary r /// public IEnumerable SpawningPlayers => _roles.Keys.Select(n => Player.Get(n)); - private readonly Dictionary _roles; - /// /// Gets whether is this player spawning. /// diff --git a/LabApi/Features/Console/Logger.cs b/LabApi/Features/Console/Logger.cs index 05a54c94..0be65923 100644 --- a/LabApi/Features/Console/Logger.cs +++ b/LabApi/Features/Console/Logger.cs @@ -25,7 +25,7 @@ public static class Logger /// Logs a debug message to the server console. /// /// The message to log. - /// Whether or not the message can be printed. + /// Whether the message can be printed. public static void Debug(object message, bool canBePrinted = true) { if (!canBePrinted) diff --git a/LabApi/Features/Interfaces/IScp914ItemProcessor.cs b/LabApi/Features/Interfaces/IScp914ItemProcessor.cs index 1e039000..ce9f8f9f 100644 --- a/LabApi/Features/Interfaces/IScp914ItemProcessor.cs +++ b/LabApi/Features/Interfaces/IScp914ItemProcessor.cs @@ -9,7 +9,7 @@ namespace LabApi.Features.Interfaces; public interface IScp914ItemProcessor { /// - /// Whether or not to use the for inventory items and skip using . + /// Whether to use the for inventory items and skip using . /// public bool UsePickupMethodOnly { get; } @@ -21,7 +21,7 @@ public interface IScp914ItemProcessor /// The upgrade result. /// /// This is not called if is true. - /// Instead items are converted to pickups and is used, and then the pickups are converted back to items. + /// Instead, items are converted to pickups and is used, and then the pickups are converted back to items. /// public Scp914Result UpgradeItem(Scp914KnobSetting setting, Item item); diff --git a/LabApi/Features/LabApiProperties.cs b/LabApi/Features/LabApiProperties.cs index c2042463..c75063c9 100644 --- a/LabApi/Features/LabApiProperties.cs +++ b/LabApi/Features/LabApiProperties.cs @@ -4,7 +4,7 @@ namespace LabApi.Features; /// /// Contains LabAPI properties which can be accessed by plugins. -/// + /// Those properties are a mix of constants and static fields such as . /// public static class LabApiProperties diff --git a/LabApi/Features/Permissions/PermissionsManager.cs b/LabApi/Features/Permissions/PermissionsManager.cs index 330c68b5..d10822cf 100644 --- a/LabApi/Features/Permissions/PermissionsManager.cs +++ b/LabApi/Features/Permissions/PermissionsManager.cs @@ -16,7 +16,7 @@ public static class PermissionsManager /// /// Internal dictionary to store the registered permission providers. /// - private static readonly Dictionary PermissionProviders = new (); + private static readonly Dictionary PermissionProviders = new(); /// /// Registers the given . @@ -62,7 +62,7 @@ public static class PermissionsManager return provider; Logger.Warn($"{LoggerPrefix} The permission provider of type {typeof(T).FullName} is not registered."); - return default; + return null; } /// diff --git a/LabApi/Features/Permissions/Providers/PermissionGroup.cs b/LabApi/Features/Permissions/Providers/PermissionGroup.cs index 21e66229..5aeea9e2 100644 --- a/LabApi/Features/Permissions/Providers/PermissionGroup.cs +++ b/LabApi/Features/Permissions/Providers/PermissionGroup.cs @@ -12,10 +12,10 @@ public class PermissionGroup /// /// Constructor for deserialization. /// - #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. public PermissionGroup() - #pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. { + InheritedGroups = []; + Permissions = []; } /// diff --git a/LabApi/Features/Wrappers/Facility/Cassie.cs b/LabApi/Features/Wrappers/Facility/Cassie.cs index a38dc3f3..256517e8 100644 --- a/LabApi/Features/Wrappers/Facility/Cassie.cs +++ b/LabApi/Features/Wrappers/Facility/Cassie.cs @@ -5,105 +5,104 @@ using System.Linq; using static NineTailedFoxAnnouncer; -namespace LabApi.Features.Wrappers +namespace LabApi.Features.Wrappers; + +/// +/// The wrapper for in game Cassie announcer. +/// +public static class Cassie { /// - /// The wrapper for in game Cassie announcer. + /// Gets whether Cassie is currently speaking. /// - public static class Cassie - { - /// - /// Gets whether Cassie is currently speaking. - /// - public static bool IsSpeaking => singleton.queue.Count != 0; + public static bool IsSpeaking => singleton.queue.Count != 0; - /// - /// Gets all available voice lines for Cassie. - /// - public static VoiceLine[] AllLines => singleton.voiceLines; + /// + /// Gets all available voice lines for Cassie. + /// + public static VoiceLine[] AllLines => singleton.voiceLines; - /// - /// Gets all collection names in which voicelines are in. - /// - public static string[] CollectionNames => singleton.voiceLines.Select(n => n.collection).Distinct().ToArray(); + /// + /// Gets all collection names in which voicelines are in. + /// + public static string[] CollectionNames => singleton.voiceLines.Select(n => n.collection).Distinct().ToArray(); - /// - /// Checks whether a specified word is valid for cassie. - /// String comparison is case insensitive. - /// - /// The word to check. - /// Whether the word is valid. - public static bool IsValid(string word) => singleton.voiceLines.Any(line => line.apiName.Equals(word, StringComparison.InvariantCultureIgnoreCase)); + /// + /// Checks whether a specified word is valid for cassie. + /// String comparison is case-insensitive. + /// + /// The word to check. + /// Whether the word is valid. + public static bool IsValid(string word) => singleton.voiceLines.Any(line => line.apiName.Equals(word, StringComparison.InvariantCultureIgnoreCase)); - /// - /// Calculates duration of specific message. - /// - /// The message. - /// Raw numbers. - /// The speed of message. - /// Duration of the specific message in seconds. - public static float CalculateDuration(string message, bool rawNumber = false) => singleton.CalculateDuration(message, rawNumber); + /// + /// Calculates duration of specific message. + /// + /// The message. + /// Raw numbers. + /// The speed of message. + /// Duration of the specific message in seconds. + public static float CalculateDuration(string message, bool rawNumber = false) => singleton.CalculateDuration(message, rawNumber); - /// - /// Plays a custom announcement. - /// - /// The sentence Cassie is supposed to say. - /// Sets a minimal 3-second moment of silence before the announcement. For most cases you wanna keep it true. - /// Whether the background noises play. - /// Show subtitles. - /// Custom subtitles to appear instead of the actual message. - //TODO: Perhaps add the custom subtitles functionality to RA & base game commands? - public static void Message(string message, bool isHeld = false, bool isNoisy = true, bool isSubtitles = false, string customSubtitles = "") => RespawnEffectsController.PlayCassieAnnouncement(message, isHeld, isNoisy, isSubtitles, customSubtitles); + /// + /// Plays a custom announcement. + /// + /// The sentence Cassie is supposed to say. + /// Sets a minimal 3-second moment of silence before the announcement. For most cases you wanna keep it true. + /// Whether the background noises play. + /// Show subtitles. + /// Custom subtitles to appear instead of the actual message. + //TODO: Perhaps add the custom subtitles functionality to RA & base game commands? + public static void Message(string message, bool isHeld = false, bool isNoisy = true, bool isSubtitles = false, string customSubtitles = "") => RespawnEffectsController.PlayCassieAnnouncement(message, isHeld, isNoisy, isSubtitles, customSubtitles); - /// - /// Plays the custom announcement with chance of 0f to 1f of adding a glitch or jam before each word. Values closer to 1f are higher chances. - /// - /// The sentence Cassie is supposed to say. - /// The chance for glitch sound to be added before each word. Range from 0f to 1f. - /// The chance for jam sound to be added before each word. Range from 0f to 1f. - public static void GlitchyMessage(string message, float glitchChance, float jamChance) => singleton.ServerOnlyAddGlitchyPhrase(message, glitchChance, jamChance); + /// + /// Plays the custom announcement with chance of 0f to 1f of adding a glitch or jam before each word. Values closer to 1f are higher chances. + /// + /// The sentence Cassie is supposed to say. + /// The chance for glitch sound to be added before each word. Range from 0f to 1f. + /// The chance for jam sound to be added before each word. Range from 0f to 1f. + public static void GlitchyMessage(string message, float glitchChance, float jamChance) => singleton.ServerOnlyAddGlitchyPhrase(message, glitchChance, jamChance); - /// - /// Plays the termination announcement of a SCP player. If the specified player does not have an SCP role then nothing is played. - /// - /// The player who is being terminated as an SCP. - /// Damage handler causing the death of the player. - public static void ScpTermination(Player player, DamageHandlerBase info) => AnnounceScpTermination(player.ReferenceHub, info); + /// + /// Plays the termination announcement of a SCP player. If the specified player does not have an SCP role then nothing is played. + /// + /// The player who is being terminated as an SCP. + /// Damage handler causing the death of the player. + public static void ScpTermination(Player player, DamageHandlerBase info) => AnnounceScpTermination(player.ReferenceHub, info); - /// - /// Clears the Cassie announcements queue. - /// - public static void Clear() => singleton.ClearQueue(); + /// + /// Clears the Cassie announcements queue. + /// + public static void Clear() => singleton.ClearQueue(); - /// - /// Converts player's team into Cassie-able word. Unit names are converted into NATO_X words, followed by a number. For example "Alpha-5" is converted to "NATO_A 5". - /// - /// Target team. - /// MTF Unit name (for team ). - /// Converted name. - public static string ConvertTeam(Team team, string unitName) => NineTailedFoxAnnouncer.ConvertTeam(team, unitName); + /// + /// Converts player's team into Cassie-able word. Unit names are converted into NATO_X words, followed by a number. For example "Alpha-5" is converted to "NATO_A 5". + /// + /// Target team. + /// MTF Unit name (for team ). + /// Converted name. + public static string ConvertTeam(Team team, string unitName) => NineTailedFoxAnnouncer.ConvertTeam(team, unitName); - /// - /// Converts number into string. - /// - /// The number. - /// Number converted to string. - public static string ConvertNumber(int num) => NineTailedFoxAnnouncer.ConvertNumber(num); + /// + /// Converts number into string. + /// + /// The number. + /// Number converted to string. + public static string ConvertNumber(int num) => NineTailedFoxAnnouncer.ConvertNumber(num); - /// - /// Converts player's into an SCP number identifier. - /// - /// The target role id. - /// The SCP number without spaces between. Used by Cassie. - /// The SCP number with spaces between. Used by Subtitles. - public static void ConvertSCP(RoleTypeId role, out string withoutSpace, out string withSpace) => NineTailedFoxAnnouncer.ConvertSCP(role, out withoutSpace, out withSpace); + /// + /// Converts player's into an SCP number identifier. + /// + /// The target . + /// The SCP number without spaces between. Used by Cassie. + /// The SCP number with spaces between. Used by Subtitles. + public static void ConvertScp(RoleTypeId role, out string withoutSpace, out string withSpace) => NineTailedFoxAnnouncer.ConvertSCP(role, out withoutSpace, out withSpace); - /// - /// Converts player's role name into an SCP number identifier. - /// - /// The targets role name - /// The SCP number without spaces between. Used by Cassie. - /// The SCP number with spaces between. Used by Subtitles. - public static void ConvertSCP(string roleName, out string withoutSpace, out string withSpace) => NineTailedFoxAnnouncer.ConvertSCP(roleName, out withoutSpace, out withSpace); - } + /// + /// Converts player's role name into an SCP number identifier. + /// + /// The targets role name + /// The SCP number without spaces between. Used by Cassie. + /// The SCP number with spaces between. Used by Subtitles. + public static void ConvertScp(string roleName, out string withoutSpace, out string withSpace) => NineTailedFoxAnnouncer.ConvertSCP(roleName, out withoutSpace, out withSpace); } \ No newline at end of file diff --git a/LabApi/Features/Wrappers/Facility/Doors/BreakableDoor.cs b/LabApi/Features/Wrappers/Facility/Doors/BreakableDoor.cs index cfbf7440..03d0d0f3 100644 --- a/LabApi/Features/Wrappers/Facility/Doors/BreakableDoor.cs +++ b/LabApi/Features/Wrappers/Facility/Doors/BreakableDoor.cs @@ -21,7 +21,7 @@ public class BreakableDoor : Door public new static IReadOnlyCollection List => Dictionary.Values; /// - /// An internal constructor the prevent external instantiation. + /// An internal constructor to prevent external instantiation. /// /// The base object. internal BreakableDoor(BaseBreakableDoor baseBreakableDoor) @@ -46,7 +46,7 @@ internal override void OnRemove() public new BaseBreakableDoor Base { get; } /// - /// Gets or sets whether or not SCP-106 can pass through the door when its not closed and locked. + /// Gets or sets whether SCP-106 can pass through the door when it's not closed and locked. /// public bool Is106Passable { @@ -73,7 +73,7 @@ public float Health } /// - /// Gets or sets whether or not the door is broken. + /// Gets or sets whether the door is broken. /// /// /// Some doors can not be unbroken. @@ -100,9 +100,7 @@ public DoorDamageType IgnoreDamageSources /// The to apply. /// True if the doors took damage, otherwise false. public bool TryDamage(float damage, DoorDamageType type = DoorDamageType.ServerCommand) - { - return Base.ServerDamage(damage, type); - } + => Base.ServerDamage(damage, type); /// /// Break the door. @@ -110,19 +108,14 @@ public bool TryDamage(float damage, DoorDamageType type = DoorDamageType.ServerC /// The to apply. /// True if the doors took damage, otherwise false. public bool TryBreak(DoorDamageType type = DoorDamageType.ServerCommand) - { - return Base.ServerDamage(float.MaxValue, type); - } + => TryDamage(float.MaxValue, type); /// /// Tries to repair the door. /// Sets the doors health back to if the door is broken otherwise it does nothing. /// /// True if the door was repaired, otherwise false. - public bool TryRepair() - { - return Base.ServerRepair(); - } + public bool TryRepair() => Base.ServerRepair(); /// /// Gets the wrapper from the , or creates a new one if it doesn't exist. diff --git a/LabApi/Features/Wrappers/Facility/Doors/BulkheadDoor.cs b/LabApi/Features/Wrappers/Facility/Doors/BulkheadDoor.cs index 48609f4e..a3061dcf 100644 --- a/LabApi/Features/Wrappers/Facility/Doors/BulkheadDoor.cs +++ b/LabApi/Features/Wrappers/Facility/Doors/BulkheadDoor.cs @@ -30,7 +30,7 @@ internal BulkheadDoor(PryableDoor pryableDoor) Dictionary.Add(pryableDoor, this); Base = pryableDoor; DoorCrusherExtension extension = pryableDoor.gameObject.GetComponent(); - if(extension != null) + if (extension != null) Crusher = new DoorCrusher(extension); } diff --git a/LabApi/Features/Wrappers/Facility/Doors/CheckpointDoor.cs b/LabApi/Features/Wrappers/Facility/Doors/CheckpointDoor.cs index ece427de..705bfebc 100644 --- a/LabApi/Features/Wrappers/Facility/Doors/CheckpointDoor.cs +++ b/LabApi/Features/Wrappers/Facility/Doors/CheckpointDoor.cs @@ -55,7 +55,7 @@ internal override void OnRemove() public Door[] SubDoors { get; } /// - /// Gets or sets whether or not all the sub doors are open. + /// Gets or sets whether all the sub doors are open. /// public bool IsSubOpened { @@ -64,7 +64,7 @@ public bool IsSubOpened } /// - /// Gets or sets whether or not the doors are broken. + /// Gets or sets whether the doors are broken. /// /// /// Some doors can not be unbroken. @@ -74,7 +74,7 @@ public bool IsBroken get => Base.IsDestroyed; set { - foreach(DoorVariant doorVariant in Base.SubDoors) + foreach (DoorVariant doorVariant in Base.SubDoors) { if (doorVariant is not IDamageableDoor damageableDoor) continue; @@ -115,7 +115,7 @@ public BaseCheckpointDoor.CheckpointSequenceStage SequenceState /// Gets or sets the time in seconds to open the doors after the was set to . /// /// - /// Does not effect the speed of the animations of the door it only influences the timing of when when to move on to the next stage. + /// Does not affect the speed of the animations of the door it only influences the timing of when when to move on to the next stage. /// is set to after the delay. /// public float OpeningDuration @@ -152,7 +152,7 @@ public float WarningDuration /// Gets or sets the current sequence time in seconds. /// /// - /// Represents the value of the internal timer used to switch depending on , and . + /// Represents the value of the internal timer used to switch depending on , and . /// public float SequenceTime { @@ -172,9 +172,7 @@ public float SequenceTime /// The to apply. /// True if the doors took damage, otherwise false. public bool TryDamage(float damage, DoorDamageType type = DoorDamageType.ServerCommand) - { - return Base.ServerDamage(damage, type); - } + => Base.ServerDamage(damage, type); /// /// Break all the sub doors. @@ -182,17 +180,12 @@ public bool TryDamage(float damage, DoorDamageType type = DoorDamageType.ServerC /// The to apply. /// True if the doors took damage, otherwise false. public bool TryBreak(DoorDamageType type = DoorDamageType.ServerCommand) - { - return Base.ServerDamage(float.MaxValue, type); - } + => TryDamage(float.MaxValue, type); /// /// Plays a sound and sets the panel state to error. Error state can not be undone. /// - public void PlayErrorAnimation() - { - Base.RpcPlayBeepSound(2); - } + public void PlayErrorAnimation() => Base.RpcPlayBeepSound(2); /// /// Gets the wrapper from the , or creates a new one if it doesn't exist. diff --git a/LabApi/Features/Wrappers/Facility/Doors/Door.cs b/LabApi/Features/Wrappers/Facility/Doors/Door.cs index b89633bd..96ee677e 100644 --- a/LabApi/Features/Wrappers/Facility/Doors/Door.cs +++ b/LabApi/Features/Wrappers/Facility/Doors/Door.cs @@ -3,10 +3,8 @@ using Interactables.Interobjects.DoorUtils; using LabApi.Features.Enums; using MapGeneration; -using MapGeneration.RoomConnectors; using System; using System.Collections.Generic; -using System.Collections.ObjectModel; using System.Diagnostics.CodeAnalysis; using System.Linq; using UnityEngine; @@ -27,13 +25,7 @@ internal static void Initialize() Register(x => new BreakableDoor(x)); Register(x => new ElevatorDoor(x)); Register(x => new Timed173Gate(x)); - Register(x => - { - if (x.name.StartsWith("HCZ BulkDoor")) - return new BulkheadDoor(x); - else - return new Gate(x); - }); + Register(x => x.name.StartsWith("HCZ BulkDoor") ? new BulkheadDoor(x) : new Gate(x)); Register(x => new NonInteractableDoor(x)); Register(x => new CheckpointDoor(x)); Register(x => new DummyDoor(x)); @@ -48,7 +40,7 @@ internal static void Initialize() /// /// Contains all the values for the associated . /// - private readonly static Dictionary doorNameDictionary = new() + private static readonly Dictionary doorNameDictionary = new() { { "LCZ_CAFE", DoorName.LczPc }, { "LCZ_WC", DoorName.LczWc }, @@ -107,7 +99,7 @@ protected Door(DoorVariant doorVariant) Dictionary.Add(doorVariant, this); Base = doorVariant; - if(doorVariant.TryGetComponent(out DoorNametagExtension nametag) && !string.IsNullOrEmpty(nametag.GetName)) + if (doorVariant.TryGetComponent(out DoorNametagExtension nametag) && !string.IsNullOrEmpty(nametag.GetName)) { if (doorNameDictionary.TryGetValue(nametag.GetName, out DoorName doorName)) DoorName = doorName; @@ -156,7 +148,7 @@ internal virtual void OnRemove() public FacilityZone Zone => Rooms.FirstOrDefault()?.Zone ?? FacilityZone.Other; /// - /// Gets or sets whether or not the door is open. + /// Gets or sets whether the door is open. /// public bool IsOpened { @@ -165,7 +157,7 @@ public bool IsOpened } /// - /// Gets whether or not the door can be interacted with by a . + /// Gets whether the door can be interacted with by a . /// public bool CanInteract => Base.AllowInteracting(null, 0); @@ -179,7 +171,7 @@ public bool IsOpened public float ExactState => Base.GetExactState(); /// - /// Gets or sets whether or not the door is locked. + /// Gets or sets whether the door is locked. /// public bool IsLocked { @@ -196,7 +188,7 @@ public bool IsLocked /// Locks the door. /// /// The reason. - /// Whether or not the door lock reason is new. + /// Whether the door lock reason is new. public void Lock(DoorLockReason reason, bool enabled) => Base.ServerChangeLock(reason, enabled); /// @@ -209,7 +201,7 @@ public KeycardPermissions Permissions } /// - /// Gets or sets whether or not the door will bypass 2176. + /// Gets or sets whether the door will bypass 2176. /// public bool Bypass2176 { @@ -240,18 +232,12 @@ public bool Bypass2176 /// /// Plays a sound that indicates that lock bypass was denied. /// - public void PlayLockBypassDeniedSound() - { - Base.LockBypassDenied(null, 0); - } + public void PlayLockBypassDeniedSound() => Base.LockBypassDenied(null, 0); /// /// Plays a sound and flashes permission denied on the panel. /// - public void PlayPermissionDeniedAnimation() - { - Base.PermissionsDenied(null, 0); - } + public void PlayPermissionDeniedAnimation() => Base.PermissionsDenied(null, 0); /// /// Gets the door wrapper from the , or creates a new one if it doesn't exist. diff --git a/LabApi/Features/Wrappers/Facility/Doors/DummyDoor.cs b/LabApi/Features/Wrappers/Facility/Doors/DummyDoor.cs index c32cde66..e9947feb 100644 --- a/LabApi/Features/Wrappers/Facility/Doors/DummyDoor.cs +++ b/LabApi/Features/Wrappers/Facility/Doors/DummyDoor.cs @@ -24,7 +24,7 @@ public class DummyDoor : Door /// /// The base object. internal DummyDoor(BaseDummyDoor baseDummyDoor) - :base(baseDummyDoor) + : base(baseDummyDoor) { Dictionary.Add(baseDummyDoor, this); Base = baseDummyDoor; diff --git a/LabApi/Features/Wrappers/Facility/Doors/ElevatorDoor.cs b/LabApi/Features/Wrappers/Facility/Doors/ElevatorDoor.cs index 1d4a1a38..342499dd 100644 --- a/LabApi/Features/Wrappers/Facility/Doors/ElevatorDoor.cs +++ b/LabApi/Features/Wrappers/Facility/Doors/ElevatorDoor.cs @@ -26,7 +26,7 @@ public class ElevatorDoor : Door /// /// The base object. internal ElevatorDoor(BaseElevatorDoor baseElevatorDoor) - :base(baseElevatorDoor) + : base(baseElevatorDoor) { Dictionary.Add(baseElevatorDoor, this); Base = baseElevatorDoor; diff --git a/LabApi/Features/Wrappers/Facility/Doors/Extensions/DoorCrusher.cs b/LabApi/Features/Wrappers/Facility/Doors/Extensions/DoorCrusher.cs index 9924873d..fdcd92a9 100644 --- a/LabApi/Features/Wrappers/Facility/Doors/Extensions/DoorCrusher.cs +++ b/LabApi/Features/Wrappers/Facility/Doors/Extensions/DoorCrusher.cs @@ -55,7 +55,7 @@ public float ScpDamage } /// - /// Gets or sets whether or not SCPs should be excluded from taking damage from the crusher. + /// Gets or sets whether SCPs should be excluded from taking damage from the crusher. /// public bool IgnoreScps { diff --git a/LabApi/Features/Wrappers/Facility/Doors/Gate.cs b/LabApi/Features/Wrappers/Facility/Doors/Gate.cs index f53c4f8b..da0e144c 100644 --- a/LabApi/Features/Wrappers/Facility/Doors/Gate.cs +++ b/LabApi/Features/Wrappers/Facility/Doors/Gate.cs @@ -24,7 +24,7 @@ public class Gate : Door /// /// The base object. internal Gate(PryableDoor pryableDoor) - :base(pryableDoor) + : base(pryableDoor) { Dictionary.Add(pryableDoor, this); Base = pryableDoor; @@ -45,7 +45,7 @@ internal override void OnRemove() public new PryableDoor Base { get; } /// - /// Gets or sets whether or not SCP-106 can pass through the door when its not closed and locked. + /// Gets or sets whether SCP-106 can pass through the door when its not closed and locked. /// public bool Is106Passable { @@ -58,18 +58,12 @@ public bool Is106Passable /// /// The player to pry the gate. /// True if the player can pry the gate, otherwise false. - public bool TryPry(Player player) - { - return Base.TryPryGate(player.ReferenceHub); - } + public bool TryPry(Player player) => Base.TryPryGate(player.ReferenceHub); /// /// Play the Pry animation. /// - public void Pry() - { - Base.RpcPryGate(); - } + public void Pry() => Base.RpcPryGate(); /// /// Gets the wrapper from the , or creates a new one if it doesn't exist. diff --git a/LabApi/Features/Wrappers/Facility/Doors/NonInteractableDoor.cs b/LabApi/Features/Wrappers/Facility/Doors/NonInteractableDoor.cs index 3154e961..632e7a03 100644 --- a/LabApi/Features/Wrappers/Facility/Doors/NonInteractableDoor.cs +++ b/LabApi/Features/Wrappers/Facility/Doors/NonInteractableDoor.cs @@ -24,7 +24,7 @@ public class NonInteractableDoor : Door /// /// The base object. internal NonInteractableDoor(BasicNonInteractableDoor basicNonInteractableDoor) - :base(basicNonInteractableDoor) + : base(basicNonInteractableDoor) { Dictionary.Add(basicNonInteractableDoor, this); Base = basicNonInteractableDoor; @@ -45,7 +45,7 @@ internal override void OnRemove() public new BasicNonInteractableDoor Base { get; } /// - /// Gets or sets whether or not SCP-106 can pass through the door when its not closed and locked. + /// Gets or sets whether SCP-106 can pass through the door when its not closed and locked. /// public bool Is106Passable { diff --git a/LabApi/Features/Wrappers/Facility/Doors/Timed173Gate.cs b/LabApi/Features/Wrappers/Facility/Doors/Timed173Gate.cs index db6a0142..1c9f63ee 100644 --- a/LabApi/Features/Wrappers/Facility/Doors/Timed173Gate.cs +++ b/LabApi/Features/Wrappers/Facility/Doors/Timed173Gate.cs @@ -28,7 +28,7 @@ public class Timed173Gate : Gate /// /// The base object. internal Timed173Gate(Timed173PryableDoor timed173PryableDoor) - :base(timed173PryableDoor) + : base(timed173PryableDoor) { Dictionary.Add(timed173PryableDoor, this); Base = timed173PryableDoor; @@ -54,7 +54,7 @@ internal override void OnRemove() public Stopwatch Stopwatch => Base.Stopwatch; /// - /// Gets or sets whether or not the gate will open if a SCP-173 is present. + /// Gets or sets whether the gate will open if an SCP-173 is present. /// /// /// The gate is still unlocked after the specified time regardless of this setting. diff --git a/LabApi/Features/Wrappers/Facility/Elevator.cs b/LabApi/Features/Wrappers/Facility/Elevator.cs index 7c005180..05b34fc9 100644 --- a/LabApi/Features/Wrappers/Facility/Elevator.cs +++ b/LabApi/Features/Wrappers/Facility/Elevator.cs @@ -180,5 +180,5 @@ public static Elevator Get(ElevatorChamber elevatorChamber) => /// /// The specified elevator group. /// Enumerable where the group is equal to the one specified. - public static IEnumerable? GetByGroup(ElevatorGroup group) => List.Where(n => n.Group == group); + public static IEnumerable GetByGroup(ElevatorGroup group) => List.Where(n => n.Group == group); } \ No newline at end of file diff --git a/LabApi/Features/Wrappers/Facility/Hazards/AmnesticCloudHazard.cs b/LabApi/Features/Wrappers/Facility/Hazards/AmnesticCloudHazard.cs index 0064347a..2f2d6d11 100644 --- a/LabApi/Features/Wrappers/Facility/Hazards/AmnesticCloudHazard.cs +++ b/LabApi/Features/Wrappers/Facility/Hazards/AmnesticCloudHazard.cs @@ -4,170 +4,171 @@ using UnityEngine; using static PlayerRoles.PlayableScps.Scp939.Scp939AmnesticCloudInstance; -namespace LabApi.Features.Wrappers +namespace LabApi.Features.Wrappers; + +public class AmnesticCloudHazard : DecayableHazard { - public class AmnesticCloudHazard : DecayableHazard + /// + /// Contains all the cached items, accessible through their . + /// + public new static Dictionary Dictionary { get; } = []; + + /// + /// Gets all currently active tantrum hazards. + /// + public new IReadOnlyCollection List => Dictionary.Values; + + /// + /// Prefab used to spawn the hazard. + /// + protected static new Scp939AmnesticCloudInstance? BasePrefab; + + /// + /// Gets or sets the world position of the hazard as it is synchronized with the client. + /// Note that this value is slightly inaccurate and is purely for visual effects.
+ /// For actual world position used to calculate whether the player is inside of this hazard use . + ///
+ public Vector3 SyncedPosition { - /// - /// Contains all the cached items, accessible through their . - /// - public new static Dictionary Dictionary { get; } = []; - - /// - /// Gets all currently active tantrum hazards. - /// - public new IReadOnlyCollection List => Dictionary.Values; - - /// - /// Prefab used to spawn the hazard. - /// - protected static new Scp939AmnesticCloudInstance? BasePrefab; - - /// - /// Gets or sets the world position of the hazard as it is synchronized with the client. - /// Note that this value is slightly inaccurate and is purely for visual effects.
- /// For actual world position used to calculate whether the player is inside of this hazard use . - ///
- public Vector3 SyncedPosition - { - get => Base.SyncedPosition.Position; - set => Base.SyncedPosition = new RelativePositioning.RelativePosition(value); - } + get => Base.SyncedPosition.Position; + set => Base.SyncedPosition = new RelativePositioning.RelativePosition(value); + } - /// - /// Gets or sets the visual size of the amnestic cloud. Only visible to SCP-939. For actual effect size use . - /// - public byte VisualSize - { - get => Base.HoldDuration; - set => Base.HoldDuration = value; - } - /// - /// Pause duration that the uses. - /// - public float PauseDuration - { - get => Base.PauseDuration; - set => Base.PauseDuration = value; - } + /// + /// Gets or sets the visual size of the amnestic cloud. Only visible to SCP-939. For actual effect size use . + /// + public byte VisualSize + { + get => Base.HoldDuration; + set => Base.HoldDuration = value; + } - /// - /// Duration of the amnesia that is applied when the player is inside this hazard. - /// - public float AmnesiaDuration - { - get => Base.AmnesiaDuration; - set => Base.AmnesiaDuration = value; - } + /// + /// Pause duration that the uses. + /// + public float PauseDuration + { + get => Base.PauseDuration; + set => Base.PauseDuration = value; + } + + /// + /// Duration of the amnesia that is applied when the player is inside this hazard. + /// + public float AmnesiaDuration + { + get => Base.AmnesiaDuration; + set => Base.AmnesiaDuration = value; + } - /// - /// Gets or sets the owner of this amnestic cloud. - /// - public Player? Owner + /// + /// Gets or sets the owner of this amnestic cloud. + /// + public Player? Owner + { + get => Player.Get(Base.Owner); + set { - get => Player.Get(Base.Owner); - set + if (value == null) { - if (value == null) - { - Base.Network_syncOwner = 0; - return; - } - - Base.Owner = value.ReferenceHub; + Base.Network_syncOwner = 0; + return; } - } - /// - /// Gets the state of this amnestic cloud. - /// - public CloudState State - { - get => Base.State; + Base.Owner = value.ReferenceHub; } + } - /// - /// The base object. - /// - public new Scp939AmnesticCloudInstance Base { get; private set; } - - /// - /// Internal constructor preventing external instantiation. - /// - /// The base amnestic cloud hazard. - internal AmnesticCloudHazard(Scp939AmnesticCloudInstance hazard) : base(hazard) - { - Base = hazard; - Dictionary.Add(hazard, this); - } + /// + /// Gets the state of this amnestic cloud. + /// + public CloudState State => Base.State; + + /// + /// The base object. + /// + public new Scp939AmnesticCloudInstance Base { get; } + + /// + /// Internal constructor preventing external instantiation. + /// + /// The base amnestic cloud hazard. + internal AmnesticCloudHazard(Scp939AmnesticCloudInstance hazard) + : base(hazard) + { + Base = hazard; + Dictionary.Add(hazard, this); + } - /// - /// Spawns a at specified position with specified rotation, scale duration and size. - /// Do note that changing scale doesn't change the effect size. Use the and to match the visual size. - /// - /// The target position to spawn this hazard at. - /// The target rotation to spawn this hazard with. - /// The target scale to spawn with. - /// The duration in seconds for which this cloud will be alive for. - /// The size of the cloud. - /// A new hazard. - public static AmnesticCloudHazard Spawn(Vector3 position, Quaternion rotation, Vector3 scale, float duration = 90f, byte size = 255, Player? owner = null) - { - if (BasePrefab == null) - BasePrefab = Hazard.GetPrefab(); + /// + /// Spawns a at specified position with specified rotation, scale duration and size. + /// Do note that changing scale doesn't change the effect size. Use the and to match the visual size. + /// + /// The target position to spawn this hazard at. + /// The target rotation to spawn this hazard with. + /// The target scale to spawn with. + /// The duration in seconds for which this cloud will be alive for. + /// The size of the cloud. + /// The owner of the cloud. + /// A new hazard. + public static AmnesticCloudHazard Spawn(Vector3 position, Quaternion rotation, Vector3 scale, float duration = 90f, byte size = 255, Player? owner = null) + { + if (BasePrefab == null) + BasePrefab = GetPrefab(); - AmnesticCloudHazard hazard = (AmnesticCloudHazard)Hazard.Spawn(BasePrefab, position, rotation, scale); - hazard.Base.State = CloudState.Created; - hazard.LiveDuration = duration; - hazard.VisualSize = size; - hazard.SyncedPosition = position; + AmnesticCloudHazard hazard = (AmnesticCloudHazard)Hazard.Spawn(BasePrefab, position, rotation, scale); + hazard.Base.State = CloudState.Created; + hazard.LiveDuration = duration; + hazard.VisualSize = size; + hazard.SyncedPosition = position; - Vector2 minMax = hazard.Base.MinMaxTime; - hazard.MaxDistance = Mathf.Lerp(minMax.x, minMax.y, size / byte.MaxValue); + Vector2 minMax = hazard.Base.MinMaxTime; + hazard.MaxDistance = Mathf.Lerp(minMax.x, minMax.y, size / byte.MaxValue); - if (owner != null) - hazard.Owner = owner; - return hazard; - } + if (owner != null) + hazard.Owner = owner; + return hazard; + } - /// - /// Temporary pauses all amnesia effects based on or custom time. - /// - /// Custom duration of the pause. Values less than 0 will use the - public void Pause(float customDuration = -1f) + /// + /// Temporary pauses all amnesia effects based on or custom time. + /// + /// Custom duration of the pause. Values less than 0 will use the + public void Pause(float customDuration = -1f) + { + if (customDuration > 0f) { - if (customDuration > 0f) - { - float prev = PauseDuration; - PauseDuration = customDuration; - Base.PauseAll(); - PauseDuration = prev; - - return; - } + float prev = PauseDuration; + PauseDuration = customDuration; Base.PauseAll(); - } + PauseDuration = prev; - /// - /// An internal method to remove itself from the cache when the base object is destroyed. - /// - internal override void OnRemove() - { - base.OnRemove(); - Dictionary.Remove(Base); + return; } - /// - /// Gets the hazard wrapper from the or creates a new one if it doesn't exist and the provided was not . - /// - /// The of the hazard. - /// The requested hazard or . - [return: NotNullIfNotNull(nameof(hazard))] - public static AmnesticCloudHazard? Get(Scp939AmnesticCloudInstance? hazard) - { - if (hazard == null) - return null; - return Dictionary.TryGetValue(hazard, out AmnesticCloudHazard decHazard) ? decHazard : (AmnesticCloudHazard)CreateItemWrapper(hazard); - } + Base.PauseAll(); + } + + /// + /// An internal method to remove itself from the cache when the base object is destroyed. + /// + internal override void OnRemove() + { + base.OnRemove(); + Dictionary.Remove(Base); + } + + /// + /// Gets the hazard wrapper from the or creates a new one if it doesn't exist and the provided was not . + /// + /// The of the hazard. + /// The requested hazard or . + [return: NotNullIfNotNull(nameof(hazard))] + public static AmnesticCloudHazard? Get(Scp939AmnesticCloudInstance? hazard) + { + if (hazard == null) + return null; + + return Dictionary.TryGetValue(hazard, out AmnesticCloudHazard decHazard) ? decHazard : (AmnesticCloudHazard)CreateItemWrapper(hazard); } -} +} \ No newline at end of file diff --git a/LabApi/Features/Wrappers/Facility/Hazards/DecayableHazard.cs b/LabApi/Features/Wrappers/Facility/Hazards/DecayableHazard.cs index 521e6083..9f16f9a1 100644 --- a/LabApi/Features/Wrappers/Facility/Hazards/DecayableHazard.cs +++ b/LabApi/Features/Wrappers/Facility/Hazards/DecayableHazard.cs @@ -3,95 +3,92 @@ using System.Diagnostics.CodeAnalysis; using UnityEngine; -namespace LabApi.Features.Wrappers +namespace LabApi.Features.Wrappers; + +/// +/// A class representing the . +/// +public class DecayableHazard : Hazard { /// - /// A class representing the . + /// Contains all the cached items, accessible through their . /// - public class DecayableHazard : Hazard - { - /// - /// Contains all the cached items, accessible through their . - /// - public new static Dictionary Dictionary { get; } = []; + public new static Dictionary Dictionary { get; } = []; - /// - /// Gets all currently active decayable hazards. - /// - public new IReadOnlyCollection List => Dictionary.Values; + /// + /// Gets all currently active decayable hazards. + /// + public new IReadOnlyCollection List => Dictionary.Values; - /// - /// Gets or sets the modifier applied to when calculating how much time has passed.
- /// Setting this value will override any subclass modifiers. Setting it to values less than 0 will remove the override. - ///
- public float DecaySpeed - { - get => Base.DecaySpeed; - set => Base.DecaySpeed = value; - } + /// + /// Gets or sets the modifier applied to when calculating how much time has passed.
+ /// Setting this value will override any subclass modifiers. Setting it to values less than 0 will remove the override. + ///
+ public float DecaySpeed + { + get => Base.DecaySpeed; + set => Base.DecaySpeed = value; + } - /// - /// Gets or sets the amount of time this object will persist for (in seconds) before disappearing. - /// - public float LiveDuration - { - get => Base.HazardDuration; - set => Base.HazardDuration = value; - } + /// + /// Gets or sets the amount of time this object will persist for (in seconds) before disappearing. + /// + public float LiveDuration + { + get => Base.HazardDuration; + set => Base.HazardDuration = value; + } - /// - /// Gets or sets the amount of time in seconds this hazard is being active. - /// Doesn't progress if the is set to . - /// - public float Elapsed - { - get => Base.Elapsed; - set => Base.Elapsed = value; - } + /// + /// Gets or sets the amount of time in seconds this hazard is being active. + /// Doesn't progress if the is set to . + /// + public float Elapsed + { + get => Base.Elapsed; + set => Base.Elapsed = value; + } - /// - /// The base object. - /// - public TemporaryHazard Base { get; private set; } + /// + /// The base object. + /// + public new TemporaryHazard Base { get; } - /// - /// An internal constructor to prevent external instantiation. - /// - /// The base game object. - protected DecayableHazard(TemporaryHazard hazard) : base(hazard) - { - Base = hazard; - Dictionary.Add(hazard, this); - } + /// + /// An internal constructor to prevent external instantiation. + /// + /// The base game object. + protected DecayableHazard(TemporaryHazard hazard) + : base(hazard) + { + Base = hazard; + Dictionary.Add(hazard, this); + } - /// - /// Destroys this hazard.
- /// Do note that subclasses usually implement few seconds delay before the actual object is destroyed. (Usually to wait for animations to finish on clients) - ///
- public override void Destroy() - { - Base.ServerDestroy(); - } + /// + /// Destroys this hazard.
+ /// Do note that subclasses usually implement few seconds delay before the actual object is destroyed. (Usually to wait for animations to finish on clients) + ///
+ public override void Destroy() => Base.ServerDestroy(); - /// - internal override void OnRemove() - { - base.OnRemove(); - Dictionary.Remove(Base); - } + /// + internal override void OnRemove() + { + base.OnRemove(); + Dictionary.Remove(Base); + } - /// - /// Gets the hazard wrapper from the or creates a new one if it doesn't exist and the provided was not . - /// - /// The of the hazard. - /// The requested hazard or . - [return: NotNullIfNotNull(nameof(hazard))] - public static DecayableHazard? Get(TemporaryHazard? hazard) - { - if (hazard == null) - return null; + /// + /// Gets the hazard wrapper from the or creates a new one if it doesn't exist and the provided was not . + /// + /// The of the hazard. + /// The requested hazard or . + [return: NotNullIfNotNull(nameof(hazard))] + public static DecayableHazard? Get(TemporaryHazard? hazard) + { + if (hazard == null) + return null; - return Dictionary.TryGetValue(hazard, out DecayableHazard decHazard) ? decHazard : (DecayableHazard)CreateItemWrapper(hazard); - } + return Dictionary.TryGetValue(hazard, out DecayableHazard decHazard) ? decHazard : (DecayableHazard)CreateItemWrapper(hazard); } -} +} \ No newline at end of file diff --git a/LabApi/Features/Wrappers/Facility/Hazards/Hazard.cs b/LabApi/Features/Wrappers/Facility/Hazards/Hazard.cs index c0784fda..e06e96d4 100644 --- a/LabApi/Features/Wrappers/Facility/Hazards/Hazard.cs +++ b/LabApi/Features/Wrappers/Facility/Hazards/Hazard.cs @@ -9,268 +9,265 @@ using System.Diagnostics.CodeAnalysis; using PlayerRoles.PlayableScps.Scp939; -namespace LabApi.Features.Wrappers +namespace LabApi.Features.Wrappers; + +/// +/// A class representing all static and temporary . +/// +public class Hazard { /// - /// A class representing all static and temporary . + /// Contains all the handlers for constructing wrappers for the associated base game types. + /// + private static readonly Dictionary> typeWrappers = []; + + /// + /// Contains all the cached items, accessible through their . + /// + public static Dictionary Dictionary { get; } = []; + + /// + /// A reference to all instances of or its subclasses. + /// + public static IReadOnlyCollection List => Dictionary.Values; + + /// + /// Prefab used to spawn the hazard. + /// + protected static EnvironmentalHazard? BasePrefab; + + /// + /// Base game object. + /// + public EnvironmentalHazard Base { get; private set; } + + /// + /// Gets all affected players by this hazard. /// - public class Hazard + public IEnumerable AffectedPlayers => Base.AffectedPlayers.Select(n => Player.Get(n)); + + /// + /// Gets or sets the maximum distance players have to be at, for this hazard to affect them. + /// + public float MaxDistance { - /// - /// Contains all the handlers for constructing wrappers for the associated base game types. - /// - private static readonly Dictionary> typeWrappers = []; - - /// - /// Contains all the cached items, accessible through their . - /// - public static Dictionary Dictionary { get; } = []; - - /// - /// A reference to all instances of or its subclasses. - /// - public static IReadOnlyCollection List => Dictionary.Values; - - /// - /// Prefab used to spawn the hazard. - /// - protected static EnvironmentalHazard? BasePrefab; - - /// - /// Base game object. - /// - public EnvironmentalHazard Base { get; private set; } - - /// - /// Gets all affected players by this hazard. - /// - public IEnumerable AffectedPlayers => Base.AffectedPlayers.Select(n => Player.Get(n)); - - /// - /// Gets or sets the maximum distance players have to be at, for this hazard to affect them. - /// - public float MaxDistance - { - get => Base.MaxDistance; - set => Base.MaxDistance = value; - } + get => Base.MaxDistance; + set => Base.MaxDistance = value; + } - /// - /// Gets or sets the maximum height players have to be at, for this hazard to affect them. - /// - public float MaxHeightDistance - { - get => Base.MaxHeightDistance; - set => Base.MaxHeightDistance = value; - } + /// + /// Gets or sets the maximum height players have to be at, for this hazard to affect them. + /// + public float MaxHeightDistance + { + get => Base.MaxHeightDistance; + set => Base.MaxHeightDistance = value; + } - /// - /// Gets or sets the offset applied to the . - /// - public virtual Vector3 SourceOffset - { - get => Base.SourceOffset; - set => Base.SourceOffset = value; - } + /// + /// Gets or sets the offset applied to the . + /// + public virtual Vector3 SourceOffset + { + get => Base.SourceOffset; + set => Base.SourceOffset = value; + } - /// - /// Gets whether this environmental hazard and it's effects is enabled. - /// Setting to false also stops the decay of temporary hazards. - /// - public virtual bool IsActive - { - get => Base.IsActive; - set => Base.IsActive = value; - } + /// + /// Gets whether this environmental hazard and it's effects is enabled. + /// Setting to false also stops the decay of temporary hazards. + /// + public virtual bool IsActive + { + get => Base.IsActive; + set => Base.IsActive = value; + } - /// - /// Gets or sets the origin point from which the AoE effect will start. - /// - public virtual Vector3 SourcePosition - { - get => Base.SourcePosition; - set => Base.SourcePosition = value; - } + /// + /// Gets or sets the origin point from which the AoE effect will start. + /// + public virtual Vector3 SourcePosition + { + get => Base.SourcePosition; + set => Base.SourcePosition = value; + } - /// - /// Gets whether the hazard is destroyed. - /// - public bool IsDestroyed => Base.gameObject != null; + /// + /// Gets whether the hazard is destroyed. + /// + public bool IsDestroyed => Base.gameObject != null; - /// - /// Gets the room in which this hazard is in. - /// - public Room? Room => Room.GetRoomAtPosition(SourcePosition); + /// + /// Gets the room in which this hazard is in. + /// + public Room? Room => Room.GetRoomAtPosition(SourcePosition); - /// - /// Initializes the class to subscribe to events and handle the item caching. - /// - protected Hazard(EnvironmentalHazard hazard) - { - Base = hazard; - Dictionary.Add(hazard, this); - } + /// + /// Initializes the class to subscribe to events and handle the item caching. + /// + protected Hazard(EnvironmentalHazard hazard) + { + Base = hazard; + Dictionary.Add(hazard, this); + } - /// - /// Initializes the class to subscribe to events and handle the item caching. - /// - [InitializeWrapper] - internal static void Initialize() - { - Dictionary.Clear(); + /// + /// Initializes the class to subscribe to events and handle the item caching. + /// + [InitializeWrapper] + internal static void Initialize() + { + Dictionary.Clear(); - EnvironmentalHazard.OnAdded += AddHazard; - EnvironmentalHazard.OnRemoved += RemoveHazard; + EnvironmentalHazard.OnAdded += AddHazard; + EnvironmentalHazard.OnRemoved += RemoveHazard; - Register(x => new SinkholeHazard(x)); - Register(x => new TantrumHazard(x)); - Register(x => new AmnesticCloudHazard(x)); - } + Register(x => new SinkholeHazard(x)); + Register(x => new TantrumHazard(x)); + Register(x => new AmnesticCloudHazard(x)); + } - /// - /// An internal virtual method to signal to derived implementations to uncache when the base object is destroyed. - /// - internal virtual void OnRemove() - { + /// + /// An internal virtual method to signal to derived implementations to uncache when the base object is destroyed. + /// + internal virtual void OnRemove() + { + } - } + /// + /// Spawns a at specified position with specified rotation and scale. + /// + /// The target prefab. + /// The target position to spawn this hazard at. + /// The target rotation to spawn this hazard with. + /// The target scale to spawn with. + /// A new hazard. + public static Hazard Spawn(EnvironmentalHazard prefab, Vector3 position, Quaternion rotation, Vector3 scale) + { + EnvironmentalHazard hazard = GameObject.Instantiate(prefab); + hazard.transform.SetPositionAndRotation(position, rotation); + hazard.transform.localScale = scale; - /// - /// Spawns a at specified position with specified rotation and scale. - /// - /// The target prefab. - /// The target position to spawn this hazard at. - /// The target rotation to spawn this hazard with. - /// The target scale to spawn with. - /// A new hazard. - public static Hazard Spawn(EnvironmentalHazard prefab, Vector3 position, Quaternion rotation, Vector3 scale) + return Get(hazard); + } + + /// + /// Attempts to get the prefab from . + /// + /// Type of the hazard. + /// Prefab if it was found. Otherwise + protected static T? GetPrefab() where T : EnvironmentalHazard + { + foreach (GameObject prefab in NetworkClient.prefabs.Values) { - EnvironmentalHazard hazard = GameObject.Instantiate(prefab); - hazard.transform.SetPositionAndRotation(position, rotation); - hazard.transform.localScale = scale; + if (!prefab.TryGetComponent(out T hazard)) + continue; - return Get(hazard); + return hazard; } - /// - /// Attempts to get the prefab from . - /// - /// Type of the hazard. - /// Prefab gameobject if it was found. Otherwise - protected static T? GetPrefab() where T : EnvironmentalHazard - { - foreach (GameObject prefab in NetworkClient.prefabs.Values) - { - if (!prefab.TryGetComponent(out T hazard)) - continue; + return null; + } - return hazard; - } + /// + /// Gets whether the player is in the hazard area. + /// + /// Target player to check on. + /// Whether the player is within hazard area. + public bool IsInArea(Player player) => Base.IsInArea(SourcePosition, player.Position); - return null; - } + /// + /// Destroys this hazard. + /// + public virtual void Destroy() + { + if (Base.gameObject != null) + NetworkServer.Destroy(Base.gameObject); + } - /// - /// Gets whether the player is in the hazard area. - /// - /// Target player to check on. - /// Whether the player is within hazard area. - public bool IsInArea(Player player) => Base.IsInArea(SourcePosition, player.Position); - - /// - /// Destroys this hazard. - /// - public virtual void Destroy() - { - if (Base.gameObject != null) - NetworkServer.Destroy(Base.gameObject); - } + /// + /// A private method to handle the creation of new hazards in the server. + /// + /// The created instance. + private static void AddHazard(EnvironmentalHazard hazard) + { + if (!Dictionary.ContainsKey(hazard)) + _ = CreateItemWrapper(hazard); + } - /// - /// A private method to handle the creation of new hazards in the server. - /// - /// The created instance. - private static void AddHazard(EnvironmentalHazard hazard) + /// + /// A private method to handle the removal of hazards from the server. + /// + /// The to be destroyed instance. + private static void RemoveHazard(EnvironmentalHazard hazard) + { + if (Dictionary.Remove(hazard, out Hazard item)) { - if (!Dictionary.ContainsKey(hazard)) - _ = CreateItemWrapper(hazard); + item.OnRemove(); } + } - /// - /// A private method to handle the removal of hazards from the server. - /// - /// The to be destroyed instance. - private static void RemoveHazard(EnvironmentalHazard hazard) - { - if (Dictionary.TryGetValue(hazard, out Hazard item)) - { - Dictionary.Remove(hazard); - item.OnRemove(); - } - } + /// + /// A private method to handle the addition of wrapper handlers. + /// + /// The derived base game type to handle. + /// A handler to construct the wrapper with the base game instance. + private static void Register(Func constructor) where T : EnvironmentalHazard + { + typeWrappers.Add(typeof(T), x => constructor((T)x)); + } - /// - /// A private method to handle the addition of wrapper handlers. - /// - /// The derived base game type to handle. - /// A handler to construct the wrapper with the base game instance. - private static void Register(Func constructor) where T : EnvironmentalHazard - { - typeWrappers.Add(typeof(T), x => constructor((T)x)); - } + /// + /// Creates a new wrapper from the base envronental hazard object. + /// + /// The base object. + /// The newly created wrapper. + protected static Hazard CreateItemWrapper(EnvironmentalHazard hazard) + { + return typeWrappers[hazard.GetType()].Invoke(hazard); + } - /// - /// Creates a new wrapper from the base envronental hazard object. - /// - /// The base object. - /// The newly created wrapper. - protected static Hazard CreateItemWrapper(EnvironmentalHazard hazard) - { - return typeWrappers[hazard.GetType()].Invoke(hazard); - } + /// + /// Gets the hazard wrapper from the or creates a new one if it doesn't exist and the provided was not . + /// + /// The of the hazard. + /// The requested hazard or . + [return: NotNullIfNotNull(nameof(hazard))] + public static Hazard? Get(EnvironmentalHazard? hazard) + { + if (hazard == null) + return null; - /// - /// Gets the hazard wrapper from the or creates a new one if it doesn't exist and the provided was not . - /// - /// The of the hazard. - /// The requested hazard or . - [return: NotNullIfNotNull(nameof(hazard))] - public static Hazard? Get(EnvironmentalHazard? hazard) - { - if (hazard == null) - return null; + return Dictionary.TryGetValue(hazard, out Hazard wrapper) ? wrapper : CreateItemWrapper(hazard); + } - return Dictionary.TryGetValue(hazard, out Hazard wrapper) ? wrapper : CreateItemWrapper(hazard); - } + /// + /// Tries to get the hazard wrapper from the . + /// + /// The of the hazard. + /// The requested hazard. + /// if the item exists, otherwise . + public static bool TryGet(EnvironmentalHazard? envHazard, [NotNullWhen(true)] out Hazard? wrapper) + { + wrapper = Get(envHazard); + return wrapper != null; + } - /// - /// Tries to get the hazard wrapper from the . - /// - /// The of the hazard. - /// The requested hazard. - /// if the item exists, otherwise . - public static bool TryGet(EnvironmentalHazard? envHazard, [NotNullWhen(true)] out Hazard? wrapper) - { - wrapper = Get(envHazard); - return wrapper != null; - } + /// + /// Gets all hazards in a specified room. + /// + /// The target room to check on. + /// Hazards in specified room. + public static IEnumerable Get(Room? room) + { + if (room == null) + yield break; - /// - /// Gets all hazards in a specified room. - /// - /// The target room to check on. - /// Hazards in specified room. - public static IEnumerable Get(Room? room) + foreach (Hazard hazard in List) { - if (room == null) - yield break; - - foreach (Hazard hazard in List) - { - if (hazard.Room == room) - yield return hazard; - } + if (hazard.Room == room) + yield return hazard; } } -} +} \ No newline at end of file diff --git a/LabApi/Features/Wrappers/Facility/Hazards/SinkholeHazard.cs b/LabApi/Features/Wrappers/Facility/Hazards/SinkholeHazard.cs index 2f553407..3264a331 100644 --- a/LabApi/Features/Wrappers/Facility/Hazards/SinkholeHazard.cs +++ b/LabApi/Features/Wrappers/Facility/Hazards/SinkholeHazard.cs @@ -4,83 +4,83 @@ using Mirror; using System.Diagnostics.CodeAnalysis; -namespace LabApi.Features.Wrappers +namespace LabApi.Features.Wrappers; + +/// +/// A class representing the . +/// Note that this is static hazard and position, rotation and scale isn't applied on clients unless you respawn this object via . +/// +public class SinkholeHazard : Hazard { /// - /// A class representing the . - /// Note that this is static hazard and position, rotation and scale isn't applied on clients unless you respawn this object via . + /// Contains all the cached items, accessible through their . /// - public class SinkholeHazard : Hazard - { - /// - /// Contains all the cached items, accessible through their . - /// - public new static Dictionary Dictionary { get; } = []; + public new static Dictionary Dictionary { get; } = []; - /// - /// Gets all currently active sinkholes. - /// - public new IReadOnlyCollection List => Dictionary.Values; + /// + /// Gets all currently active sinkholes. + /// + public new IReadOnlyCollection List => Dictionary.Values; - /// - /// Prefab used to spawn the hazard. - /// - protected static new SinkholeEnvironmentalHazard BasePrefab; + /// + /// Prefab used to spawn the hazard. + /// + protected static new SinkholeEnvironmentalHazard? BasePrefab; - /// - /// The base object. - /// - public SinkholeEnvironmentalHazard Base { get; private set; } + /// + /// The base object. + /// + public new SinkholeEnvironmentalHazard Base { get; } - /// - /// An internal constructor to prevent external instantiation. - /// - /// The base object. - internal SinkholeHazard(SinkholeEnvironmentalHazard hazard) : base(hazard) - { - Base = hazard; - Dictionary.Add(hazard, this); - } + /// + /// An internal constructor to prevent external instantiation. + /// + /// The base object. + internal SinkholeHazard(SinkholeEnvironmentalHazard hazard) + : base(hazard) + { + Base = hazard; + Dictionary.Add(hazard, this); + } - /// - /// An internal method to remove itself from the cache when the base object is destroyed. - /// - internal override void OnRemove() - { - base.OnRemove(); - Dictionary.Remove(Base); - } + /// + /// An internal method to remove itself from the cache when the base object is destroyed. + /// + internal override void OnRemove() + { + base.OnRemove(); + Dictionary.Remove(Base); + } - /// - /// Spawns a at specified position with specified rotation and scale. - /// Do note that changing scale doesn't change the effect size. Use the and to match the visual size. - /// - /// The target position to spawn this hazard at. - /// The target rotation to spawn this hazard with. - /// The target scale to spawn with. Also affects the size of the decal. - /// A new hazard. - public static SinkholeHazard Spawn(Vector3 position, Quaternion rotation, Vector3 scale) - { - if (BasePrefab == null) - BasePrefab = Hazard.GetPrefab(); + /// + /// Spawns a at specified position with specified rotation and scale. + /// Do note that changing scale doesn't change the effect size. Use the and to match the visual size. + /// + /// The target position to spawn this hazard at. + /// The target rotation to spawn this hazard with. + /// The target scale to spawn with. Also affects the size of the decal. + /// The newly created hazard. + public static SinkholeHazard Spawn(Vector3 position, Quaternion rotation, Vector3 scale) + { + if (BasePrefab == null) + BasePrefab = GetPrefab(); - SinkholeHazard hazard = (SinkholeHazard)Hazard.Spawn(BasePrefab, position, rotation, scale); - hazard.IsActive = true; - return hazard; - } + SinkholeHazard hazard = (SinkholeHazard)Hazard.Spawn(BasePrefab, position, rotation, scale); + hazard.IsActive = true; + return hazard; + } - /// - /// Gets the sinkhole wrapper from the or creates a new one if it doesn't exist and the provided was not . - /// - /// The of the hazard. - /// The requested hazard or . - [return: NotNullIfNotNull(nameof(hazard))] - public static SinkholeHazard? Get(SinkholeEnvironmentalHazard? hazard) - { - if (hazard == null) - return null; + /// + /// Gets the sinkhole wrapper from the or creates a new one if it doesn't exist and the provided was not . + /// + /// The of the hazard. + /// The requested hazard or . + [return: NotNullIfNotNull(nameof(hazard))] + public static SinkholeHazard? Get(SinkholeEnvironmentalHazard? hazard) + { + if (hazard == null) + return null; - return Dictionary.TryGetValue(hazard, out SinkholeHazard sinkhole) ? sinkhole : (SinkholeHazard)CreateItemWrapper(hazard); - } + return Dictionary.TryGetValue(hazard, out SinkholeHazard sinkhole) ? sinkhole : (SinkholeHazard)CreateItemWrapper(hazard); } -} +} \ No newline at end of file diff --git a/LabApi/Features/Wrappers/Facility/Hazards/TantrumHazard.cs b/LabApi/Features/Wrappers/Facility/Hazards/TantrumHazard.cs index aac49ae5..185b05de 100644 --- a/LabApi/Features/Wrappers/Facility/Hazards/TantrumHazard.cs +++ b/LabApi/Features/Wrappers/Facility/Hazards/TantrumHazard.cs @@ -3,105 +3,105 @@ using System.Diagnostics.CodeAnalysis; using UnityEngine; -namespace LabApi.Features.Wrappers +namespace LabApi.Features.Wrappers; + +/// +/// A class representing the . +/// +public class TantrumHazard : DecayableHazard { /// - /// A class representing the . + /// Contains all the cached items, accessible through their . /// - public class TantrumHazard : DecayableHazard - { - /// - /// Contains all the cached items, accessible through their . - /// - public new static Dictionary Dictionary { get; } = []; + public new static Dictionary Dictionary { get; } = []; - /// - /// Gets all currently active tantrum hazards. - /// - public new IReadOnlyCollection List => Dictionary.Values; + /// + /// Gets all currently active tantrum hazards. + /// + public new IReadOnlyCollection List => Dictionary.Values; - /// - /// Prefab used to spawn the hazard. - /// - protected static new TantrumEnvironmentalHazard? BasePrefab; + /// + /// Prefab used to spawn the hazard. + /// + protected static new TantrumEnvironmentalHazard? BasePrefab; - /// - /// Gets or sets the world position of the hazard as it is synchronized with the client. - /// Note that this value is slightly inaccurate and is purely for visual effects.
- /// For actual world position used to calculate whether the player is inside of this hazard use . - ///
- public Vector3 SyncedPosition - { - get => Base.SynchronizedPosition.Position; - set => Base.SynchronizedPosition = new RelativePositioning.RelativePosition(value); - } + /// + /// Gets or sets the world position of the hazard as it is synchronized with the client. + /// Note that this value is slightly inaccurate and is purely for visual effects.
+ /// For actual world position used to calculate whether the player is inside of this hazard use . + ///
+ public Vector3 SyncedPosition + { + get => Base.SynchronizedPosition.Position; + set => Base.SynchronizedPosition = new RelativePositioning.RelativePosition(value); + } - /// - /// Gets or sets whether a slight sizzle sound effect will be played when this object is destroyed. - /// It is played by default if the tantrum gets destroyed by an explosion or by .
- /// Note that this state may change right before it is destroyed by standard game means. - ///
- public bool PlaySizzle - { - get => Base.PlaySizzle; - set => Base.PlaySizzle = value; - } + /// + /// Gets or sets whether a slight sizzle sound effect will be played when this object is destroyed. + /// It is played by default if the tantrum gets destroyed by an explosion or by .
+ /// Note that this state may change right before it is destroyed by standard game means. + ///
+ public bool PlaySizzle + { + get => Base.PlaySizzle; + set => Base.PlaySizzle = value; + } - /// - /// The base object. - /// - public new TantrumEnvironmentalHazard Base { get; private set; } + /// + /// The base object. + /// + public new TantrumEnvironmentalHazard Base { get; } - /// - /// An internal constructor to prevent external instantiation. - /// - /// The base game tantrum hazard. - internal TantrumHazard(TantrumEnvironmentalHazard hazard) : base(hazard) - { - Base = hazard; + /// + /// An internal constructor to prevent external instantiation. + /// + /// The base game tantrum hazard. + internal TantrumHazard(TantrumEnvironmentalHazard hazard) + : base(hazard) + { + Base = hazard; - Dictionary.Add(hazard, this); - } + Dictionary.Add(hazard, this); + } - /// - /// Spawns a at specified position with specified rotation and scale. - /// Do note that changing scale doesn't change the effect size. Use the and to match the visual size. - /// - /// The target position to spawn this hazard at. - /// The target rotation to spawn this hazard with. - /// The target scale to spawn with. - /// A new tantrum hazard. - public static TantrumHazard Spawn(Vector3 position, Quaternion rotation, Vector3 scale) - { - if (BasePrefab == null) - BasePrefab = Hazard.GetPrefab(); + /// + /// Spawns a at specified position with specified rotation and scale. + /// Do note that changing scale doesn't change the effect size. Use the and to match the visual size. + /// + /// The target position to spawn this hazard at. + /// The target rotation to spawn this hazard with. + /// The target scale to spawn with. + /// A new tantrum hazard. + public static TantrumHazard Spawn(Vector3 position, Quaternion rotation, Vector3 scale) + { + if (BasePrefab == null) + BasePrefab = Hazard.GetPrefab(); - TantrumHazard hazard = (TantrumHazard)Hazard.Spawn(BasePrefab, position, rotation, scale); - hazard.SyncedPosition = position; - return hazard; - } + TantrumHazard hazard = (TantrumHazard)Hazard.Spawn(BasePrefab, position, rotation, scale); + hazard.SyncedPosition = position; + return hazard; + } - /// - /// An internal method to remove itself from the cache when the base object is destroyed. - /// - internal override void OnRemove() - { - base.OnRemove(); - Dictionary.Remove(Base); - } + /// + /// An internal method to remove itself from the cache when the base object is destroyed. + /// + internal override void OnRemove() + { + base.OnRemove(); + Dictionary.Remove(Base); + } - /// - /// Gets the hazard wrapper from the or creates a new one if it doesn't exist and the provided was not . - /// - /// The of the hazard. - /// The requested hazard or - [return: NotNullIfNotNull(nameof(hazard))] - public static DecayableHazard? Get(TantrumEnvironmentalHazard? hazard) - { - if (hazard == null) - return null; + /// + /// Gets the hazard wrapper from the or creates a new one if it doesn't exist and the provided was not . + /// + /// The of the hazard. + /// The requested hazard or + [return: NotNullIfNotNull(nameof(hazard))] + public static DecayableHazard? Get(TantrumEnvironmentalHazard? hazard) + { + if (hazard == null) + return null; - return Dictionary.TryGetValue(hazard, out TantrumHazard decHazard) ? decHazard : (TantrumHazard)CreateItemWrapper(hazard); - } + return Dictionary.TryGetValue(hazard, out TantrumHazard decHazard) ? decHazard : (TantrumHazard)CreateItemWrapper(hazard); } -} +} \ No newline at end of file diff --git a/LabApi/Features/Wrappers/Facility/Hazards/Tesla.cs b/LabApi/Features/Wrappers/Facility/Hazards/Tesla.cs index 4391eae0..42908351 100644 --- a/LabApi/Features/Wrappers/Facility/Hazards/Tesla.cs +++ b/LabApi/Features/Wrappers/Facility/Hazards/Tesla.cs @@ -5,151 +5,145 @@ using Generators; using MapGeneration; -namespace LabApi.Features.Wrappers +namespace LabApi.Features.Wrappers; + +/// +/// The wrapper representing tesla gate. +/// +public class Tesla { /// - /// The wrapper representing tesla gate. + /// Contains all the cached tesla gates, accessible through their . + /// + public static Dictionary Dictionary { get; } = []; + + /// + /// Cached tesla gates by they are in. + /// + private static Dictionary TeslaByRoom { get; } = []; + + /// + /// A reference to all instances of . + /// + public static IReadOnlyCollection List => Dictionary.Values; + + /// + /// The base of the tesla. + /// + public TeslaGate Base { get; } + + /// + /// Gets tesla gate's position. + /// + public Vector3 Position => Base.Position; + + /// + /// Gets tesla gate's rotation. /// - public class Tesla + public Quaternion Rotation => Base.transform.rotation; + + /// + /// Gets or sets the inactive time of tesla gate. + /// + /// Inactive time is in seconds and is automatically decreased over time. + /// Any value greater than 0 will result in tesla gate not activating. + /// + /// + public float InactiveTime { - /// - /// Contains all the cached tesla gates, accessible through their . - /// - public static Dictionary Dictionary { get; } = []; - - /// - /// Cached tesla gates by they are in. - /// - private static Dictionary TeslaByRoom { get; } = []; - - /// - /// A reference to all instances of . - /// - public static IReadOnlyCollection List => Dictionary.Values; - - /// - /// The base of the tesla. - /// - public TeslaGate Base { get; } - - /// - /// Gets tesla gate's position. - /// - public Vector3 Position => Base.Position; - - /// - /// Gets tesla gate's rotation. - /// - public Quaternion Rotation => Base.transform.rotation; - - /// - /// Gets or sets the inactive time of tesla gate. - /// - /// Inactive time is in seconds and is automatically decreased over time. - /// Any value greater than 0 will result in tesla gate not activating. - /// - /// - public float InactiveTime + get => Base.NetworkInactiveTime; + set { - get => Base.NetworkInactiveTime; - set - { - Base.NetworkInactiveTime = value; + Base.NetworkInactiveTime = value; - if (value > 0f) - { - Base.ServerSideIdle(false); - } + if (value > 0f) + { + Base.ServerSideIdle(false); } } + } - /// - /// Gets the room the tesla gate is in. - /// - public Room Room => Room.Get(Base.Room); - - /// - /// Returns if is in range where tesla gate starts idling. - /// - /// The player to check on. - /// Whethet the player is in idle range. - public bool IsPlayerInIdleRange(Player player) => Base.IsInIdleRange(player.ReferenceHub); - - /// - /// Returns if is in range where tesla gate starts to burst. - /// - /// The player to check on. - /// Whether the player is within activation range. - public bool IsPlayerInRange(Player player) => Base.PlayerInRange(player.ReferenceHub); - - /// - /// Returns if any is in range where tesla gate starts idling. - /// - /// Whether any player is within the idle range. - public bool IsAnyPlayerInIdleRange() => HashsetExtensions.Any(ReferenceHub.AllHubs, Base.IsInIdleRange); - - /// - /// Returns if any is in range where tesla gate starts to burst. - /// - /// Whether any player is within activation range. - public bool IsAnyPlayerInRange() => HashsetExtensions.Any(ReferenceHub.AllHubs, Base.PlayerInRange); - - /// - /// Tesla gate electric burst. Will not do anything if burst is being active. - /// - public void Trigger() - { - Base.ServerSideCode(); - } + /// + /// Gets the room the tesla gate is in. + /// + public Room Room => Room.Get(Base.Room); - /// - /// Tesla gate instant burst. - /// - public void InstantTrigger() => Base.RpcInstantBurst(); + /// + /// Returns if is in range where tesla gate starts idling. + /// + /// The player to check on. + /// Whether the player is in idle range. + public bool IsPlayerInIdleRange(Player player) => Base.IsInIdleRange(player.ReferenceHub); - /// - /// Initializes the class to subscribe to events and handle the tesla caching. - /// - [InitializeWrapper] - internal static void Initialize() - { - Dictionary.Clear(); - TeslaByRoom.Clear(); - TeslaGate.OnAdded += (tesla) => _ = new Tesla(tesla); - TeslaGate.OnRemoved += (tesla) => - { - Dictionary.Remove(tesla); - TeslaByRoom.Remove(tesla.Room); - }; - } + /// + /// Returns if is in range where tesla gate starts to burst. + /// + /// The player to check on. + /// Whether the player is within activation range. + public bool IsPlayerInRange(Player player) => Base.PlayerInRange(player.ReferenceHub); - /// - /// A private constructor to prevent external instantiation. - /// - /// The of the item. - private Tesla(TeslaGate tesla) - { - Dictionary.Add(tesla, this); - TeslaByRoom.Add(tesla.Room, this); - Base = tesla; - } + /// + /// Returns if any is in range where tesla gate starts idling. + /// + /// Whether any player is within the idle range. + public bool IsAnyPlayerInIdleRange() => ReferenceHub.AllHubs.Any(Base.IsInIdleRange); + + /// + /// Returns if any is in range where tesla gate starts to burst. + /// + /// Whether any player is within activation range. + public bool IsAnyPlayerInRange() => ReferenceHub.AllHubs.Any(Base.PlayerInRange); + + /// + /// Tesla gate electric burst. Will not do anything if burst is being active. + /// + public void Trigger() => Base.ServerSideCode(); + + /// + /// Tesla gate instant burst. + /// + public void InstantTrigger() => Base.RpcInstantBurst(); - /// - /// Gets the tesla wrapper from the or creates a new one if it doesn't exist. - /// - /// The of the tesla. - /// The requested tesla. - public static Tesla Get(TeslaGate teslaGate) => Dictionary.TryGetValue(teslaGate, out Tesla tesla) ? tesla : new Tesla(teslaGate); - - /// - /// Gets the tesla wrapper inside of from the . - /// - /// The with the tesla. - /// The tesla to be returned. - /// Whether the tesla is in out parameter. - public static bool TryGet(Room room, [NotNullWhen(true)] out Tesla? tesla) + /// + /// Initializes the class to subscribe to events and handle the tesla caching. + /// + [InitializeWrapper] + internal static void Initialize() + { + Dictionary.Clear(); + TeslaByRoom.Clear(); + TeslaGate.OnAdded += (tesla) => _ = new Tesla(tesla); + TeslaGate.OnRemoved += (tesla) => { - return TeslaByRoom.TryGetValue(room.Base, out tesla); - } + Dictionary.Remove(tesla); + TeslaByRoom.Remove(tesla.Room); + }; } + + /// + /// A private constructor to prevent external instantiation. + /// + /// The of the item. + private Tesla(TeslaGate tesla) + { + Dictionary.Add(tesla, this); + TeslaByRoom.Add(tesla.Room, this); + Base = tesla; + } + + /// + /// Gets the tesla wrapper from the or creates a new one if it doesn't exist. + /// + /// The of the tesla. + /// The requested tesla. + public static Tesla Get(TeslaGate teslaGate) => Dictionary.TryGetValue(teslaGate, out Tesla tesla) ? tesla : new Tesla(teslaGate); + + /// + /// Gets the tesla wrapper inside of from the . + /// + /// The with the tesla. + /// The tesla to be returned. + /// Whether the tesla is in out parameter. + public static bool TryGet(Room room, [NotNullWhen(true)] out Tesla? tesla) + => TeslaByRoom.TryGetValue(room.Base, out tesla); } \ No newline at end of file diff --git a/LabApi/Features/Wrappers/Facility/Map.cs b/LabApi/Features/Wrappers/Facility/Map.cs index 3a3da1da..67a0cd18 100644 --- a/LabApi/Features/Wrappers/Facility/Map.cs +++ b/LabApi/Features/Wrappers/Facility/Map.cs @@ -344,7 +344,6 @@ public static void TurnOffLights(float duration) lc.FlickerLights(duration); } - /// /// Turns off all lights. /// diff --git a/LabApi/Features/Wrappers/Facility/Rooms/LightsController.cs b/LabApi/Features/Wrappers/Facility/Rooms/LightsController.cs index c99bc37e..eb7b3f45 100644 --- a/LabApi/Features/Wrappers/Facility/Rooms/LightsController.cs +++ b/LabApi/Features/Wrappers/Facility/Rooms/LightsController.cs @@ -2,83 +2,82 @@ using System.Collections.Generic; using UnityEngine; -namespace LabApi.Features.Wrappers +namespace LabApi.Features.Wrappers; + +/// +/// The wrapper representing room light controller. +/// +public class LightsController { /// - /// The wrapper representing room light controller. + /// Contains all the cached rooms in the game, accessible through their . /// - public class LightsController - { - /// - /// Contains all the cached rooms in the game, accessible through their . - /// - private static Dictionary Dictionary { get; } = []; + private static Dictionary Dictionary { get; } = []; - /// - /// A reference to all instances currently in the game. - /// - public static IReadOnlyCollection List => Dictionary.Values; - - /// - /// A private constructor to prevent external instantiation. - /// - /// The original object. - private LightsController(RoomLightController original) - { - Dictionary.Add(original, this); - Base = original; - } + /// + /// A reference to all instances currently in the game. + /// + public static IReadOnlyCollection List => Dictionary.Values; - /// - /// Initializes the Room wrapper by subscribing to the events. - /// - [InitializeWrapper] - internal static void Initialize() - { - RoomLightController.OnAdded += (roomLightController) => _ = new LightsController(roomLightController); - RoomLightController.OnRemoved += (roomLightController) => Dictionary.Remove(roomLightController); - } - /// - /// The base game object. - /// - public RoomLightController Base { get; private set; } + /// + /// A private constructor to prevent external instantiation. + /// + /// The original object. + private LightsController(RoomLightController original) + { + Dictionary.Add(original, this); + Base = original; + } - /// - /// The room this controller is assigned to. - /// - public Room Room => Room.Get(Base.Room); + /// + /// Initializes the Room wrapper by subscribing to the events. + /// + [InitializeWrapper] + internal static void Initialize() + { + RoomLightController.OnAdded += (roomLightController) => _ = new LightsController(roomLightController); + RoomLightController.OnRemoved += (roomLightController) => Dictionary.Remove(roomLightController); + } - /// - /// Gets or sets whether the lights are enabled in this room. - /// - public bool LightsEnabled - { - get => Base.NetworkLightsEnabled; - set => Base.NetworkLightsEnabled = value; - } + /// + /// The base game object. + /// + public RoomLightController Base { get; } - /// - /// Gets or sets the overriden room light color. Set the value to to reset override color. - /// - public Color OverrideLightsColor - { - get => Base.NetworkOverrideColor; - set => Base.NetworkOverrideColor = value; - } + /// + /// The room this controller is assigned to. + /// + public Room Room => Room.Get(Base.Room); - /// - /// Blackouts the room for specified duration. - /// - /// Duration of light shutdown in seconds. - public void FlickerLights(float duration) => - Base.ServerFlickerLights(duration); + /// + /// Gets or sets whether the lights are enabled in this room. + /// + public bool LightsEnabled + { + get => Base.NetworkLightsEnabled; + set => Base.NetworkLightsEnabled = value; + } - /// - /// Gets the controller wrapper from , or creates a new one if it doesnt exists. - /// - /// The original light controller. - /// The requested light controller wrapper. - public static LightsController Get(RoomLightController roomLightController) => - Dictionary.TryGetValue(roomLightController, out LightsController lightController) ? lightController : new LightsController(roomLightController); + /// + /// Gets or sets the overriden room light color. Set the value to to reset override color. + /// + public Color OverrideLightsColor + { + get => Base.NetworkOverrideColor; + set => Base.NetworkOverrideColor = value; } -} + + /// + /// Blackouts the room for specified duration. + /// + /// Duration of light shutdown in seconds. + public void FlickerLights(float duration) => Base.ServerFlickerLights(duration); + + /// + /// Gets the controller wrapper from , or creates a new one if it doesnt exists. + /// + /// The original light controller. + /// The requested light controller wrapper. + public static LightsController Get(RoomLightController roomLightController) => + Dictionary.TryGetValue(roomLightController, out LightsController lightController) ? lightController : new LightsController(roomLightController); +} \ No newline at end of file diff --git a/LabApi/Features/Wrappers/Facility/Rooms/PocketDimension/PocketDimension.cs b/LabApi/Features/Wrappers/Facility/Rooms/PocketDimension/PocketDimension.cs index a00aee29..071e4197 100644 --- a/LabApi/Features/Wrappers/Facility/Rooms/PocketDimension/PocketDimension.cs +++ b/LabApi/Features/Wrappers/Facility/Rooms/PocketDimension/PocketDimension.cs @@ -36,7 +36,7 @@ public class PocketDimension : Room /// Gets an array of the recycle chances. /// /// - /// Indexing the array by the rarity of the item see gives the chance for the item to be dropped from 0.0 to 1.0. + /// Indexing the array by the rarity of the item see gives the chance for the item to be dropped from 0.0 to 1.0. /// public static float[] RecycleChances => Scp106PocketItemManager.RecycleChances; @@ -69,7 +69,7 @@ public static float MaxPocketItemTriggerDelay /// /// The room identifier for the pocket dimension. internal PocketDimension(RoomIdentifier room) - :base(room) + : base(room) { Instance = this; } @@ -87,20 +87,14 @@ internal override void OnRemoved() /// Force a inside the pocket dimension. /// /// The to send. - public static void ForceInside(Player player) - { - player.EnableEffect(); - } + public static void ForceInside(Player player) => player.EnableEffect(); /// - /// Gets whether or not a is considered inside the pocket dimension. + /// Gets whether a is considered inside the pocket dimension. /// /// The to check. /// True if inside otherwise false. - public static bool IsPlayerInside(Player player) - { - return player.HasEffect(); - } + public static bool IsPlayerInside(Player player) => player.HasEffect(); /// /// Force a player to exit the pocket dimension. @@ -111,9 +105,7 @@ public static bool IsPlayerInside(Player player) /// Triggers pocket dimension leaving/left events. /// public static void ForceExit(Player player) - { - PocketDimensionTeleport.Exit(null, player.ReferenceHub); - } + => PocketDimensionTeleport.Exit(null, player.ReferenceHub); /// /// Force a player to be killed by the pocket dimension. @@ -124,9 +116,7 @@ public static void ForceExit(Player player) /// Triggers pocket dimension leaving/left events. /// public static void ForceKill(Player player) - { - PocketDimensionTeleport.Kill(null, player.ReferenceHub); - } + => PocketDimensionTeleport.Kill(null, player.ReferenceHub); /// /// Gets whether a is inside the pocket dimension. @@ -134,17 +124,12 @@ public static void ForceKill(Player player) /// The to check. /// True if inside otherwise false. public static bool IsPickupInside(Pickup pickup) - { - return Scp106PocketItemManager.TrackedItems.ContainsKey(pickup.Base); - } + => Scp106PocketItemManager.TrackedItems.ContainsKey(pickup.Base); /// /// Randomizes which pocket dimension's teleports are exits. /// - public static void RandomizeExits() - { - PocketDimensionGenerator.RandomizeTeleports(); - } + public static void RandomizeExits() => PocketDimensionGenerator.RandomizeTeleports(); /// /// Gets the poses used for exits for the pocket dimension. @@ -152,9 +137,7 @@ public static void RandomizeExits() /// The zone that the exits are associated with. /// A collection of exit instances. public static IReadOnlyCollection GetExitPosesForZone(FacilityZone zone) - { - return Scp106PocketExitFinder.GetPosesForZone(zone); - } + => Scp106PocketExitFinder.GetPosesForZone(zone); /// /// Adds the specified poses to be used as exits for the pocket dimension. @@ -182,15 +165,13 @@ public static void AddExitPosesForZone(FacilityZone zone, IEnumerable pose /// /// The zone to remove exits from. public static void RemoveAllExitPosesForZone(FacilityZone zone) - { - Scp106PocketExitFinder.PosesForZoneCache[zone] = []; - } - + => Scp106PocketExitFinder.PosesForZoneCache[zone] = []; + /// /// Removes the specified poses from use as exits for the pocket dimension. /// /// The zone to remove exits from. - /// the poses to remove. + /// the poses to remove. public static void RemoveExitPosesForZone(FacilityZone zone, IEnumerable poses) { // Attempts to generate the pose array as it could be empty. @@ -210,12 +191,10 @@ public static void RemoveExitPosesForZone(FacilityZone zone, IEnumerable p /// /// Gets the rarity of the item using its wrapper see . /// - /// The to get the rarity from. + /// The to get the rarity from. /// The rarity of the item. public static int GetRarity(Pickup pickup) - { - return GetRarity(InventoryItemLoader.AvailableItems[pickup.Type]); - } + => GetRarity(InventoryItemLoader.AvailableItems[pickup.Type]); /// /// Gets the rarity of the item using its wrapper see . @@ -230,7 +209,5 @@ public static int GetRarity(Pickup pickup) /// The to get the rarity from. /// The rarity of the item. public static int GetRarity(ItemBase item) - { - return Scp106PocketItemManager.GetRarity(item); - } + => Scp106PocketItemManager.GetRarity(item); } diff --git a/LabApi/Features/Wrappers/Facility/Rooms/PocketDimension/PocketItem.cs b/LabApi/Features/Wrappers/Facility/Rooms/PocketDimension/PocketItem.cs index 45a3f82a..97870095 100644 --- a/LabApi/Features/Wrappers/Facility/Rooms/PocketDimension/PocketItem.cs +++ b/LabApi/Features/Wrappers/Facility/Rooms/PocketDimension/PocketItem.cs @@ -41,7 +41,7 @@ internal static void Initialize() /// /// An internal constructor to prevent external instantiation. /// - /// The item pickup in the pocket dimension. + /// The item pickup in the pocket dimension. internal PocketItem(ItemPickupBase pickup, Scp106PocketItemManager.PocketItem pocketItem) { Dictionary.Add(pickup, this); @@ -69,7 +69,7 @@ public double TriggerDelay } /// - /// Gets or sets whether or not the item pickup is destroyed after the . + /// Gets or sets whether the item pickup is destroyed after the . /// public bool WillBeDestroyed { @@ -98,16 +98,14 @@ public Vector3 DropPosition /// The associated with or null if it doesn't exists. /// Whether the was successfully retrieved. public static bool TryGet(Pickup pickup, [NotNullWhen(true)] out PocketItem? pocketItem) - { - return Dictionary.TryGetValue(pickup.Base, out pocketItem); - } + => Dictionary.TryGetValue(pickup.Base, out pocketItem); /// /// Gets the associated with the . /// /// The inside the pocket dimension to get the from. /// The associated for the or null if it doesn't exist. - public static PocketItem? Get(Pickup pickup) => TryGet(pickup, out var pocketItem) ? pocketItem : null; + public static PocketItem? Get(Pickup pickup) => TryGet(pickup, out PocketItem? pocketItem) ? pocketItem : null; /// /// Gets or adds a . @@ -119,7 +117,7 @@ public static bool TryGet(Pickup pickup, [NotNullWhen(true)] out PocketItem? poc /// public static PocketItem GetOrAdd(Pickup pickup) { - if (Dictionary.TryGetValue(pickup.Base, out var pocketItem)) + if (Dictionary.TryGetValue(pickup.Base, out PocketItem? pocketItem)) return pocketItem; pickup.Position = PocketDimension.Instance!.Position + Vector3.up; diff --git a/LabApi/Features/Wrappers/Facility/Rooms/PocketDimension/PocketTeleport.cs b/LabApi/Features/Wrappers/Facility/Rooms/PocketDimension/PocketTeleport.cs index 75b0862e..46160e95 100644 --- a/LabApi/Features/Wrappers/Facility/Rooms/PocketDimension/PocketTeleport.cs +++ b/LabApi/Features/Wrappers/Facility/Rooms/PocketDimension/PocketTeleport.cs @@ -124,10 +124,7 @@ public PocketTeleport Spawn(Vector3 localPosition) /// /// Destroys the removing it from the server. /// - public void Destroy() - { - Object.Destroy(Base); - } + public void Destroy() => Object.Destroy(Base); /// /// Gets the wrapper given the base game instance. diff --git a/LabApi/Features/Wrappers/Facility/Rooms/Room.cs b/LabApi/Features/Wrappers/Facility/Rooms/Room.cs index 9eaf246e..bb1a4586 100644 --- a/LabApi/Features/Wrappers/Facility/Rooms/Room.cs +++ b/LabApi/Features/Wrappers/Facility/Rooms/Room.cs @@ -76,39 +76,21 @@ internal virtual void OnRemoved() public HashSet ConnectedRooms => Base.ConnectedRooms; /// - /// Gets the doors that are a part of this room. + /// Gets the doors that are a part of this room. TODO: Cache in base game code? /// - public IEnumerable Doors - { - get - { - return Doors.Where(n => n.Rooms.Contains(Base)); // TODO: Cache the result in base game code? - } - } + public IEnumerable Doors => Door.List.Where(d => d.Rooms.Contains(Base)); /// /// Gets the first light controller for this room.

/// Please see if you wish to modify all lights in this room. ///
- public LightsController? LightController - { - get - { - return Base.LightControllers.Count > 0 ? LightsController.Get(Base.LightControllers[0]) : null; - } - } + public LightsController? LightController => Base.LightControllers.Count > 0 ? LightsController.Get(Base.LightControllers[0]) : null; /// /// Gets all light controllers for this specified room.
/// Some rooms such as 049, warhead and etc may have multiple light controllers as they are split by the elevator. ///
- public IEnumerable AllLightControllers - { - get - { - return Base.LightControllers.Select(LightsController.Get); - } - } + public IEnumerable AllLightControllers => Base.LightControllers.Select(LightsController.Get); /// /// Gets the room's . @@ -130,6 +112,11 @@ public IEnumerable AllLightControllers /// public Quaternion Rotation => Transform.rotation; + /// + /// Gets a collection of players in the room. + /// + public IEnumerable Players => Player.List.Where(p => p.Room == this); + /// /// Gets the room wrapper from the , or creates a new one if it doesn't exist. /// @@ -170,7 +157,6 @@ public static IEnumerable Get(FacilityZone facilityZone) => public static IEnumerable Get(IEnumerable roomIdentifiers) => roomIdentifiers.Select(Get); - /// /// Gets the closest to the specified player. /// @@ -215,10 +201,7 @@ public static bool TryGetRoomAtPosition(Vector3 position, [NotNullWhen(true)] ou // TODO: use factory instead. private static void AddRoom(RoomIdentifier roomIdentifier) { - if (roomIdentifier.Name == RoomName.Pocket) - _ = new PocketDimension(roomIdentifier); - else - _ = new Room(roomIdentifier); + _ = roomIdentifier.Name == RoomName.Pocket ? new PocketDimension(roomIdentifier) : (PocketDimension)new Room(roomIdentifier); } /// diff --git a/LabApi/Features/Wrappers/Facility/Rooms/Scp914/BaseGameItemProcessor.cs b/LabApi/Features/Wrappers/Facility/Rooms/Scp914/BaseGameItemProcessor.cs index ee233d8e..7a42cefb 100644 --- a/LabApi/Features/Wrappers/Facility/Rooms/Scp914/BaseGameItemProcessor.cs +++ b/LabApi/Features/Wrappers/Facility/Rooms/Scp914/BaseGameItemProcessor.cs @@ -30,13 +30,9 @@ internal BaseGameItemProcessor(Scp914ItemProcessor processor) /// public Scp914Result UpgradeItem(Scp914KnobSetting setting, Item item) - { - return Processor.UpgradeInventoryItem(setting, item.Base); - } + => Processor.UpgradeInventoryItem(setting, item.Base); /// public Scp914Result UpgradePickup(Scp914KnobSetting setting, Pickup pickup) - { - return Processor.UpgradePickup(setting, pickup.Base); - } + => Processor.UpgradePickup(setting, pickup.Base); } diff --git a/LabApi/Features/Wrappers/Facility/Rooms/Scp914/ItemProcessorAdapter.cs b/LabApi/Features/Wrappers/Facility/Rooms/Scp914/ItemProcessorAdapter.cs index 0e10ae9b..8a127b83 100644 --- a/LabApi/Features/Wrappers/Facility/Rooms/Scp914/ItemProcessorAdapter.cs +++ b/LabApi/Features/Wrappers/Facility/Rooms/Scp914/ItemProcessorAdapter.cs @@ -23,15 +23,13 @@ public override Scp914Result UpgradeInventoryItem(Scp914KnobSetting setting, Ite { if (Processor.UsePickupMethodOnly) return base.UpgradeInventoryItem(setting, item); - else - return Processor.UpgradeItem(setting, Item.Get(item)); + + return Processor.UpgradeItem(setting, Item.Get(item)); } /// /// Used internally by the base game. /// public override Scp914Result UpgradePickup(Scp914KnobSetting setting, ItemPickupBase pickup) - { - return Processor.UpgradePickup(setting, Pickup.Get(pickup)); - } + => Processor.UpgradePickup(setting, Pickup.Get(pickup)); } diff --git a/LabApi/Features/Wrappers/Facility/Rooms/Scp914/Scp914.cs b/LabApi/Features/Wrappers/Facility/Rooms/Scp914/Scp914.cs index 614a943f..4b770262 100644 --- a/LabApi/Features/Wrappers/Facility/Rooms/Scp914/Scp914.cs +++ b/LabApi/Features/Wrappers/Facility/Rooms/Scp914/Scp914.cs @@ -35,7 +35,7 @@ public class Scp914 : Room /// /// The room identifier for the pocket dimension. internal Scp914(RoomIdentifier roomIdentifier) - :base(roomIdentifier) + : base(roomIdentifier) { Instance = this; } @@ -92,12 +92,12 @@ public static bool IsUpgrading if (value) Scp914Controller.Singleton.Upgrade(); else - { + { Scp914Controller.Singleton.IsUpgrading = value; SequenceCooldown = 0.0f; + } } } - } /// /// Gets or sets the used by SCP-914 for upgrading. @@ -202,8 +202,7 @@ public static float DoorOpenDelay /// public static void Interact(Scp914InteractCode interactCode, Player? player = null) { - if (player == null) - player = Server.Host; + player ??= Server.Host; Scp914Controller.Singleton.ServerInteract(player.ReferenceHub, (byte)interactCode); } @@ -213,9 +212,7 @@ public static void Interact(Scp914InteractCode interactCode, Player? player = nu /// /// The sound to play. public static void PlaySound(Scp914Sound sound) - { - Scp914Controller.Singleton.RpcPlaySound((byte)sound); - } + => Scp914Controller.Singleton.RpcPlaySound((byte)sound); /// /// Gets the for the specified type. @@ -232,17 +229,16 @@ public static void PlaySound(Scp914Sound sound) if (ItemProcessorCache.TryGetValue(item, out var processor)) return processor; - else if(item.TryGetComponent(out Scp914ItemProcessor baseProcessor)) - { - if (baseProcessor is ItemProcessorAdapter adaptor) - ItemProcessorCache[item] = adaptor.Processor; - else - ItemProcessorCache[item] = new BaseGameItemProcessor(baseProcessor); - return ItemProcessorCache[item]; - } - else + if (!item.TryGetComponent(out Scp914ItemProcessor baseProcessor)) return null; + + if (baseProcessor is ItemProcessorAdapter adaptor) + ItemProcessorCache[item] = adaptor.Processor; + else + ItemProcessorCache[item] = new BaseGameItemProcessor(baseProcessor); + + return ItemProcessorCache[item]; } /// @@ -331,7 +327,7 @@ public static void SetItemProcessor(Func predicate, T processor) /// public static void SetItemProcessor(Func predicate) where T : Scp914ItemProcessor, new() { - foreach(ItemType type in Enum.GetValues(typeof(ItemType))) + foreach (ItemType type in Enum.GetValues(typeof(ItemType))) { if (!InventoryItemLoader.TryGetItem(type, out ItemBase item) || !predicate(Item.Get(item))) continue; diff --git a/LabApi/Features/Wrappers/Facility/Round.cs b/LabApi/Features/Wrappers/Facility/Round.cs index f1f74a9c..9fb8c14a 100644 --- a/LabApi/Features/Wrappers/Facility/Round.cs +++ b/LabApi/Features/Wrappers/Facility/Round.cs @@ -6,168 +6,158 @@ using Utils.NonAllocLINQ; using static ServerStatic; -namespace LabApi.Features.Wrappers +namespace LabApi.Features.Wrappers; + +/// +/// A static wrapper for any round related features. +/// +public static class Round { /// - /// A static wrapper for any round related features. + /// Gets or sets whether the round has started or not. + /// + public static bool IsRoundStarted => RoundSummary.RoundInProgress(); + + /// + /// Gets a value indicating whether the round is ended or not. + /// + public static bool IsRoundEnded => !IsRoundStarted && Duration.Seconds > 1; + + /// + /// Gets whether the round can end if there is only 1 team alive remaining.
+ /// IMPORTANT: This does NOT check win conditions! Only whether the round is locked and if there is a required amount of players. ///
- public static class Round + public static bool CanRoundEnd { - /// - /// Gets or sets whether the round has started or not. - /// - public static bool IsRoundStarted + get { - get => RoundSummary.RoundInProgress(); - } + if (IsLocked || KeepRoundOnOne && ReferenceHub.AllHubs.Count(x => x.authManager.InstanceMode != ClientInstanceMode.DedicatedServer) < 2 || !IsRoundStarted) + return false; - /// - /// Gets a value indicating whether the round is ended or not. - /// - public static bool IsRoundEnded - { - get => !IsRoundStarted && Duration.Seconds > 1; + return IsRoundStarted && !IsLocked; } + } - /// - /// Gets whether the round can end if there is only 1 team alive remaining.
- /// IMPORTANT: This does NOT check win conditions! Only whether the round is locked and if there is a required amount of players. - ///
- public static bool CanRoundEnd - { - get - { - if (IsLocked || KeepRoundOnOne && ReferenceHub.AllHubs.Count(x => x.authManager.InstanceMode != ClientInstanceMode.DedicatedServer) < 2 || !IsRoundStarted) - return false; + /// + /// Gets or sets whether the round should end if is active and there is only one player on the server. + /// + public static bool KeepRoundOnOne + { + get => RoundSummary.singleton.KeepRoundOnOne; + set => RoundSummary.singleton.KeepRoundOnOne = value; + } - if (!IsRoundStarted || IsLocked) - return false; + /// + /// Gets or sets a value indicating whether the round is locked or not. + /// + public static bool IsLocked + { + get => RoundSummary.RoundLock; + set => RoundSummary.RoundLock = value; + } - return true; - } - } + /// + /// Gets or sets a value indicating whether the lobby is locked or not. + /// + public static bool IsLobbyLocked + { + get => RoundStart.LobbyLock; + set => RoundStart.LobbyLock = value; + } - /// - /// Gets or sets whether the round should end if is active and there is only one player on the server. - /// - public static bool KeepRoundOnOne - { - get => RoundSummary.singleton.KeepRoundOnOne; - set => RoundSummary.singleton.KeepRoundOnOne = value; - } + /// + /// Gets or sets the current extra targets count for SCPs. + /// + public static int ExtraTargets + { + get => RoundSummary.singleton.Network_extraTargets; + set => RoundSummary.singleton.Network_extraTargets = value; + } - /// - /// Gets or sets a value indicating whether the round is locked or not. - /// - public static bool IsLocked - { - get => RoundSummary.RoundLock; - set => RoundSummary.RoundLock = value; - } + /// + /// Gets the current amount of targets for SCPs. Use to add/remove any extra. + /// + public static int ScpTargetsAmount => ReferenceHub.AllHubs.Count(hub => hub.GetFaction() is Faction.FoundationStaff or Faction.FoundationEnemy) + ExtraTargets; - /// - /// Gets or sets a value indicating whether the lobby is locked or not. - /// - public static bool IsLobbyLocked - { - get => RoundStart.LobbyLock; - set => RoundStart.LobbyLock = value; - } + /// + /// Gets the amount of total deaths during the round. + /// + public static int TotalDeaths => RoundSummary.Kills; - /// - /// Gets or sets the current extra targets count for SCPs. - /// - public static int ExtraTargets - { - get => RoundSummary.singleton.Network_extraTargets; - set => RoundSummary.singleton.Network_extraTargets = value; - } + /// + /// Gets the amount of total kills by SCPs. + /// + public static int KilledBySCPs => RoundSummary.KilledBySCPs; - /// - /// Gets the current amount of targets for SCPs. Use to add/remove any extra. - /// - public static int ScpTargetsAmount => ReferenceHub.AllHubs.Count(hub => hub.GetFaction() is Faction.FoundationStaff or Faction.FoundationEnemy) + ExtraTargets; - - /// - /// Gets the amount of total deaths during the round. - /// - public static int TotalDeaths => RoundSummary.Kills; - - /// - /// Gets the amount of total kills by SCPs. - /// - public static int KilledBySCPs => RoundSummary.KilledBySCPs; - - /// - /// Gets the amount of escaped Class D. - /// - public static int EscapedClassD => RoundSummary.EscapedClassD; - - /// - /// Gets rhe amount of escaped Scientists. - /// - public static int EscapedScientists => RoundSummary.EscapedScientists; - - /// - /// Gets the amount of SCPs alive at the end of round. - /// - public static int SurvivingSCPs => RoundSummary.SurvivingSCPs; - - /// - /// Gets the amount of people that turned into zombies. - /// - public static int ChangedIntoZombies => RoundSummary.ChangedIntoZombies; - - /// - /// Gets the duration of the current round. - /// - public static TimeSpan Duration => RoundStart.RoundLength; - - /// - /// Start the round. - /// - public static void Start() => CharacterClassManager.ForceRoundStart(); - - /// - /// Restarts the round. - /// - /// Whether or not it fast restart is enabled. - /// Overrides stop next round action. - /// The restart action. - public static void Restart(bool fastRestart = false, bool overrideRestartAction = false, NextRoundAction restartAction = NextRoundAction.DoNothing) - { - if (overrideRestartAction) - StopNextRound = restartAction; + /// + /// Gets the amount of escaped Class D. + /// + public static int EscapedClassD => RoundSummary.EscapedClassD; - bool prevValue = CustomNetworkManager.EnableFastRestart; - CustomNetworkManager.EnableFastRestart = fastRestart; - RoundRestart.InitiateRoundRestart(); - CustomNetworkManager.EnableFastRestart = prevValue; - } + /// + /// Gets rhe amount of escaped Scientists. + /// + public static int EscapedScientists => RoundSummary.EscapedScientists; - /// - /// Restarts the round silently. - /// - public static void RestartSilently() => Restart(true, true, NextRoundAction.DoNothing); - - /// - /// Attempts to end the current round.

- ///
- /// Whether the round should be forced to end. - /// If the round was ended. - public static bool End(bool force = false) - { - if (force) - { - RoundSummary.singleton.ForceEnd(); - return true; - } + /// + /// Gets the amount of SCPs alive at the end of round. + /// + public static int SurvivingSCPs => RoundSummary.SurvivingSCPs; - if (!CanRoundEnd) - return false; + /// + /// Gets the amount of people that turned into zombies. + /// + public static int ChangedIntoZombies => RoundSummary.ChangedIntoZombies; + + /// + /// Gets the duration of the current round. + /// + public static TimeSpan Duration => RoundStart.RoundLength; + + /// + /// Start the round. + /// + public static void Start() => CharacterClassManager.ForceRoundStart(); + + /// + /// Restarts the round. + /// + /// Whether or not it fast restart is enabled. + /// Overrides stop next round action. + /// The restart action. + public static void Restart(bool fastRestart = false, bool overrideRestartAction = false, NextRoundAction restartAction = NextRoundAction.DoNothing) + { + if (overrideRestartAction) + StopNextRound = restartAction; + + bool prevValue = CustomNetworkManager.EnableFastRestart; + CustomNetworkManager.EnableFastRestart = fastRestart; + RoundRestart.InitiateRoundRestart(); + CustomNetworkManager.EnableFastRestart = prevValue; + } + /// + /// Restarts the round silently. + /// + public static void RestartSilently() => Restart(true, true, NextRoundAction.DoNothing); + + /// + /// Attempts to end the current round.

+ ///
+ /// Whether the round should be forced to end. + /// If the round was ended. + public static bool End(bool force = false) + { + if (force) + { RoundSummary.singleton.ForceEnd(); return true; } + + if (!CanRoundEnd) + return false; + + RoundSummary.singleton.ForceEnd(); + return true; } -} +} \ No newline at end of file diff --git a/LabApi/Features/Wrappers/Facility/Structures/ExperimentalWeaponLocker.cs b/LabApi/Features/Wrappers/Facility/Structures/ExperimentalWeaponLocker.cs index 34f07bda..bc4ba26d 100644 --- a/LabApi/Features/Wrappers/Facility/Structures/ExperimentalWeaponLocker.cs +++ b/LabApi/Features/Wrappers/Facility/Structures/ExperimentalWeaponLocker.cs @@ -45,14 +45,13 @@ internal override void OnRemove() ///
public new BaseExperimentalWeaponLocler Base { get; } - /// /// The experimental weapon's chamber. /// public LockerChamber Chamber => Chambers.First(); /// - /// Gets or sets whether or not the experimental weapon locker is open. + /// Gets or sets whether the experimental weapon locker is open. /// public bool IsOpen { @@ -61,7 +60,7 @@ public bool IsOpen } /// - /// Gets whether or not the experimental weapon locker can be interacted with by a . + /// Gets whether the experimental weapon locker can be interacted with by a . /// public bool CanInteract => Chamber.CanInteract; diff --git a/LabApi/Features/Wrappers/Facility/Structures/Generator.cs b/LabApi/Features/Wrappers/Facility/Structures/Generator.cs index 818ab0f8..bef896d1 100644 --- a/LabApi/Features/Wrappers/Facility/Structures/Generator.cs +++ b/LabApi/Features/Wrappers/Facility/Structures/Generator.cs @@ -1,5 +1,4 @@ -using Generators; -using Interactables.Interobjects.DoorUtils; +using Interactables.Interobjects.DoorUtils; using MapGeneration; using MapGeneration.Distributors; using System.Collections.Generic; @@ -33,21 +32,20 @@ public class Generator : Structure ///
/// The of the generator. internal Generator(Scp079Generator generator) - :base(generator) + : base(generator) { Dictionary.Add(generator, this); Base = generator; if (generator.Room == null) - { return; - } if (!GeneratorsByRoom.TryGetValue(generator.Room, out List list)) { list = new List(); GeneratorsByRoom.Add(generator.Room, list); } + list.Add(this); } @@ -72,6 +70,7 @@ internal override void OnRemove() GeneratorsByRoom.Remove(Base.Room); } } + Dictionary.Remove(Base); } @@ -123,7 +122,7 @@ public KeycardPermissions RequiredPermissions public bool ActivationReady => Base.ActivationReady; /// - /// Gets or sets whether or not the generator is opened. + /// Gets or sets whether the generator is opened. /// public bool IsOpen { @@ -132,7 +131,7 @@ public bool IsOpen } /// - /// Gets or sets whether or not the generator is unlocked. + /// Gets or sets whether the generator is unlocked. /// public bool IsUnlocked { @@ -182,15 +181,16 @@ public short RemainingTime /// /// Gets the generator wrapper from the , or creates a new one if it doesn't exist. /// - /// The of the generator. + /// The of the generator. /// The requested generator. - public static Generator Get(Scp079Generator scp079generator) => - Dictionary.TryGetValue(scp079generator, out Generator generator) ? generator : new Generator(scp079generator); + public static Generator Get(Scp079Generator scp079Generator) => + Dictionary.TryGetValue(scp079Generator, out Generator generator) ? generator : new Generator(scp079Generator); /// /// Gets the generator wrapper from the or returns if specified room does not have any. /// /// Target room. + /// Generators found. /// Whether the generator was found. - public static bool TryGetFromRoom(Room room, [NotNullWhen(true)] out List? generator) => GeneratorsByRoom.TryGetValue(room.Base, out generator); + public static bool TryGetFromRoom(Room room, [NotNullWhen(true)] out List? generators) => GeneratorsByRoom.TryGetValue(room.Base, out generators); } \ No newline at end of file diff --git a/LabApi/Features/Wrappers/Facility/Structures/LargeLocker.cs b/LabApi/Features/Wrappers/Facility/Structures/LargeLocker.cs index 4d4073d9..ecd5e3db 100644 --- a/LabApi/Features/Wrappers/Facility/Structures/LargeLocker.cs +++ b/LabApi/Features/Wrappers/Facility/Structures/LargeLocker.cs @@ -23,7 +23,7 @@ public class LargeLocker : Locker ///
/// The base object. internal LargeLocker(BaseLocker baseLocker) - :base(baseLocker) + : base(baseLocker) { Dictionary.Add(baseLocker, this); } @@ -68,9 +68,9 @@ internal override void OnRemove() public LockerChamber MiddleLeft => Chambers[5]; /// - /// Gets the small chamber that is at the middle middle. + /// Gets the small chamber that is at the center. /// - public LockerChamber MiddleMiddle => Chambers[6]; + public LockerChamber Center => Chambers[6]; /// /// Gets the small chamber that is at the middle right. diff --git a/LabApi/Features/Wrappers/Facility/Structures/Locker.cs b/LabApi/Features/Wrappers/Facility/Structures/Locker.cs index 3bc3521a..1b8c0839 100644 --- a/LabApi/Features/Wrappers/Facility/Structures/Locker.cs +++ b/LabApi/Features/Wrappers/Facility/Structures/Locker.cs @@ -27,7 +27,7 @@ public class Locker : Structure /// /// The base object. internal Locker(BaseLocker baseLocker) - :base(baseLocker) + : base(baseLocker) { Dictionary.Add(baseLocker, this); Base = baseLocker; @@ -42,7 +42,7 @@ internal override void OnRemove() base.OnRemove(); Dictionary.Remove(Base); - foreach(var chamber in Chambers) + foreach (LockerChamber chamber in Chambers) chamber.OnRemove(); } @@ -92,7 +92,7 @@ public int MaxChambersToFill } /// - /// Gets whether or not all the are . + /// Gets whether all the are . /// public bool IsEmpty => Chambers.All(x => x.IsEmpty); @@ -126,18 +126,12 @@ public void AddLockerLoot(ItemType type, int remainingUses, int probabilityPoint /// Removes an existing from the possible spawnable . ///
/// The instance to remove. - public void RemoveLockerLoot(LockerLoot loot) - { - Base.Loot = Base.Loot.Except([loot]).ToArray(); - } + public void RemoveLockerLoot(LockerLoot loot) => Base.Loot = Base.Loot.Except([loot]).ToArray(); /// /// Removes all instances from . /// - public void ClearLockerLoot() - { - Base.Loot = []; - } + public void ClearLockerLoot() => Base.Loot = []; /// /// Fill chambers randomly with items chosen from . @@ -152,7 +146,7 @@ public void FillChambers() chambers.RemoveAt(Random.Range(0, chambers.Count)); } - foreach (var chamber in chambers) + foreach (LockerChamber chamber in chambers) chamber.Fill(); ListPool.Shared.Return(chambers); @@ -166,7 +160,7 @@ public void FillChambers() /// public void FillAllChambers() { - foreach (var chamber in Chambers) + foreach (LockerChamber chamber in Chambers) chamber.Fill(); } @@ -175,7 +169,7 @@ public void FillAllChambers() /// public void ClearAllChambers() { - foreach (var chamber in Chambers) + foreach (LockerChamber chamber in Chambers) chamber.RemoveAllItems(); } @@ -184,7 +178,7 @@ public void ClearAllChambers() ///
public void OpenAllChambers() { - foreach (var chamber in Chambers) + foreach (LockerChamber chamber in Chambers) chamber.IsOpen = true; } @@ -193,7 +187,7 @@ public void OpenAllChambers() ///
public void CloseAllChambers() { - foreach (var chamber in Chambers) + foreach (LockerChamber chamber in Chambers) chamber.IsOpen = false; } } diff --git a/LabApi/Features/Wrappers/Facility/Structures/LockerChamber.cs b/LabApi/Features/Wrappers/Facility/Structures/LockerChamber.cs index fb6e9405..ddba1ba3 100644 --- a/LabApi/Features/Wrappers/Facility/Structures/LockerChamber.cs +++ b/LabApi/Features/Wrappers/Facility/Structures/LockerChamber.cs @@ -26,7 +26,7 @@ public class LockerChamber ///
/// The base object. /// The that has this chamber. - /// The Id of the chamber inside the locker. + /// The id of the chamber inside the locker. internal LockerChamber(BaseLockerChamber baseLockerChamber, Locker locker, byte id) { Dictionary.Add(baseLockerChamber, this); @@ -59,7 +59,7 @@ internal void OnRemove() public byte Id { get; } /// - /// Gets or sets whether or not the chamber door is open. + /// Gets or sets whether the chamber door is open. /// public bool IsOpen { @@ -72,12 +72,12 @@ public bool IsOpen } /// - /// Gets whether or not the chamber can be interacted by a . + /// Gets whether the chamber can be interacted by a . /// public bool CanInteract => Base.CanInteract; /// - /// Gets whether or not the chamber contains no items. + /// Gets whether the chamber contains no items. /// public bool IsEmpty => Base.Content.All(x => x == null); @@ -103,7 +103,7 @@ public float TargetCooldown } /// - /// Gets whether or not instances are spawned on the client only when the chamber is first opened. + /// Gets whether instances are spawned on the client only when the chamber is first opened. /// public bool SpawnOnFirstOpening => Base.SpawnOnFirstChamberOpening; @@ -125,7 +125,7 @@ public ItemType[] AcceptableItems public void Fill() { Locker.Base.FillChamber(Base); - foreach(ItemPickupBase pickupBase in Base.Content) + foreach (ItemPickupBase pickupBase in Base.Content) { if (!pickupBase.TryGetComponent(out Rigidbody rigidbody)) continue; @@ -221,10 +221,7 @@ public void Interact(Player player) /// /// Plays the Access Denied sound for this chamber. /// - public void PlayDeniedSound() - { - Locker.Base.RpcPlayDenied(Id); - } + public void PlayDeniedSound() => Locker.Base.RpcPlayDenied(Id); /// /// Gets the locker chamber wrapper from the or creates a new if it doesn't exist and the provided was not null. diff --git a/LabApi/Features/Wrappers/Facility/Structures/PedestalLocker.cs b/LabApi/Features/Wrappers/Facility/Structures/PedestalLocker.cs index 7bdc126e..9c4929ac 100644 --- a/LabApi/Features/Wrappers/Facility/Structures/PedestalLocker.cs +++ b/LabApi/Features/Wrappers/Facility/Structures/PedestalLocker.cs @@ -24,7 +24,7 @@ public class PedestalLocker : Locker /// /// The base object. internal PedestalLocker(PedestalScpLocker pedestalScpLocker) - :base(pedestalScpLocker) + : base(pedestalScpLocker) { Base = pedestalScpLocker; Dictionary.Add(pedestalScpLocker, this); @@ -50,7 +50,7 @@ internal override void OnRemove() public LockerChamber Chamber => Chambers.First(); /// - /// Gets or sets whether or not the pedestal is open. + /// Gets or sets whether the pedestal is open. /// public bool IsOpen { @@ -59,7 +59,7 @@ public bool IsOpen } /// - /// Gets whether or not the pedestal can be interacted with by a . + /// Gets whether the pedestal can be interacted with by a . /// public bool CanInteract => Chamber.CanInteract; diff --git a/LabApi/Features/Wrappers/Facility/Structures/RifleRackLocker.cs b/LabApi/Features/Wrappers/Facility/Structures/RifleRackLocker.cs index ccf7952a..10788235 100644 --- a/LabApi/Features/Wrappers/Facility/Structures/RifleRackLocker.cs +++ b/LabApi/Features/Wrappers/Facility/Structures/RifleRackLocker.cs @@ -39,7 +39,7 @@ internal override void OnRemove() } /// - /// Gets or sets whether or not the rifle rack is open. + /// Gets or sets whether the rifle rack is open. /// public bool IsOpen { @@ -48,7 +48,7 @@ public bool IsOpen } /// - /// Gets whether or not the rifle rack can be interacted with by a . + /// Gets whether the rifle rack can be interacted with by a . /// public bool CanInteract => MainChamber.CanInteract; diff --git a/LabApi/Features/Wrappers/Facility/Structures/StandardLocker.cs b/LabApi/Features/Wrappers/Facility/Structures/StandardLocker.cs index 6041fa0d..b8ada6fc 100644 --- a/LabApi/Features/Wrappers/Facility/Structures/StandardLocker.cs +++ b/LabApi/Features/Wrappers/Facility/Structures/StandardLocker.cs @@ -23,7 +23,7 @@ public class StandardLocker : Locker ///
/// The base object. internal StandardLocker(BaseLocker baseLocker) - :base(baseLocker) + : base(baseLocker) { Dictionary.Add(baseLocker, this); } diff --git a/LabApi/Features/Wrappers/Facility/Structures/Structure.cs b/LabApi/Features/Wrappers/Facility/Structures/Structure.cs index ebe86f83..d0003681 100644 --- a/LabApi/Features/Wrappers/Facility/Structures/Structure.cs +++ b/LabApi/Features/Wrappers/Facility/Structures/Structure.cs @@ -22,13 +22,7 @@ internal static void Initialize() SpawnableStructure.OnAdded += OnAdded; SpawnableStructure.OnRemoved += OnRemoved; - Register(x => - { - if (x.StructureType == StructureType.Workstation) - return new Workstation(x); - - return null!; - }); + Register(x => x.StructureType == StructureType.Workstation ? new Workstation(x) : null!); Register(x => new Generator(x)); Register(x => { @@ -194,7 +188,7 @@ protected static Structure CreateStructureWrapper(SpawnableStructure structure) if (!typeWrappers.TryGetValue(structure.GetType(), out Func handler)) Console.Logger.Error($"Failed to create structure wrapper. Missing constructor handler for type {structure.GetType()}"); - Structure wrapper = handler.Invoke(structure); + Structure? wrapper = handler?.Invoke(structure); if (wrapper == null) Console.Logger.Error($"Failed to create structure wrapper. A handler returned null for type {structure.GetType()}"); diff --git a/LabApi/Features/Wrappers/Facility/Structures/WallCabinet.cs b/LabApi/Features/Wrappers/Facility/Structures/WallCabinet.cs index d478dc77..c70f31a7 100644 --- a/LabApi/Features/Wrappers/Facility/Structures/WallCabinet.cs +++ b/LabApi/Features/Wrappers/Facility/Structures/WallCabinet.cs @@ -48,7 +48,7 @@ public bool IsOpen } /// - /// Gets or sets whether the or not the wall cabinet can be interacted with by a . + /// Gets or sets whether the wall cabinet can be interacted with by a . /// public bool CanInteract => MainChamber.CanInteract; diff --git a/LabApi/Features/Wrappers/Facility/Structures/Workstation.cs b/LabApi/Features/Wrappers/Facility/Structures/Workstation.cs index eed4363a..fa3d9306 100644 --- a/LabApi/Features/Wrappers/Facility/Structures/Workstation.cs +++ b/LabApi/Features/Wrappers/Facility/Structures/Workstation.cs @@ -68,21 +68,17 @@ public Player KnownUser } /// - /// Gets whether or not the specified is close enough to the workstation to keep it on. + /// Gets whether the specified is close enough to the workstation to keep it on. /// /// The to test. - /// Whether or not the player was close enough. + /// Whether the player was close enough. public bool IsInRange(Player player) - { - return BaseController.IsInRange(player.ReferenceHub); - } + => BaseController.IsInRange(player.ReferenceHub); /// /// Interact with the workstation. /// /// The that interacted. public void Interact(Player player) - { - BaseController.ServerInteract(player.ReferenceHub, BaseController.ActivateCollider.ColliderId); - } + => BaseController.ServerInteract(player.ReferenceHub, BaseController.ActivateCollider.ColliderId); } diff --git a/LabApi/Features/Wrappers/Facility/Warhead.cs b/LabApi/Features/Wrappers/Facility/Warhead.cs index 74357773..f080fd14 100644 --- a/LabApi/Features/Wrappers/Facility/Warhead.cs +++ b/LabApi/Features/Wrappers/Facility/Warhead.cs @@ -236,7 +236,7 @@ public static void Detonate() ///
public static void OpenBlastDoors() { - foreach (var door in BlastDoor.Instances) + foreach (BlastDoor door in BlastDoor.Instances) door.ServerSetTargetState(true); } @@ -245,17 +245,14 @@ public static void OpenBlastDoors() /// public static void CloseBlastDoors() { - foreach (var door in BlastDoor.Instances) + foreach (BlastDoor door in BlastDoor.Instances) door.ServerSetTargetState(false); } /// /// Plays the warhead detonation effect on all clients in the facility. /// - public static void Shake() - { - BaseController?.RpcShake(false); - } + public static void Shake() => BaseController?.RpcShake(false); /// /// Handles the creation of the warhead components. @@ -289,8 +286,9 @@ public readonly struct DetonationScenario /// /// Internal constructor to prevent external instantiation. /// - /// - /// + /// The . + /// The id of the scenario. + /// The . internal DetonationScenario(AlphaWarheadController.DetonationScenario detonationScenario, byte id, WarheadScenarioType type) { TimeToDetonate = detonationScenario.TimeToDetonate; diff --git a/LabApi/Features/Wrappers/Items/Usable/Scp1344Item.cs b/LabApi/Features/Wrappers/Items/Usable/Scp1344Item.cs index 6c7830d9..0ce28b83 100644 --- a/LabApi/Features/Wrappers/Items/Usable/Scp1344Item.cs +++ b/LabApi/Features/Wrappers/Items/Usable/Scp1344Item.cs @@ -2,59 +2,58 @@ using System.Diagnostics.CodeAnalysis; using BaseScp1344Item = InventorySystem.Items.Usables.Scp1344.Scp1344Item; -namespace LabApi.Features.Wrappers.Items.Usable +namespace LabApi.Features.Wrappers.Items.Usable; + +/// +/// The wrapper representing . +/// +public class Scp1344Item : UsableItem { /// - /// The wrapper representing . + /// Contains all the cached SCP-1344 items, accessible through their . + /// + public new static Dictionary Dictionary { get; } = []; + + /// + /// A reference to all instances of . + /// + public new static IReadOnlyCollection List => Dictionary.Values; + + /// + /// The base object. + /// + public new BaseScp1344Item Base { get; } + + /// + /// An internal constructor to prevent external instantiation. + /// + /// The base object. + internal Scp1344Item(BaseScp1344Item baseItem) : base(baseItem) + { + Dictionary.Add(baseItem, this); + Base = baseItem; + } + + /// + /// Gets the SCP-1576 item wrapper from the or creates a new one if it doesn't exist and the provided was not null. + /// + /// The of the item. + /// The requested item or null. + [return: NotNullIfNotNull(nameof(baseItem))] + public static Scp1344Item? Get(BaseScp1344Item? baseItem) + { + if (baseItem == null) + return null; + + return Dictionary.TryGetValue(baseItem, out Scp1344Item item) ? item : (Scp1344Item)CreateItemWrapper(baseItem); + } + + /// + /// An internal method to remove itself from the cache when the base object is destroyed. /// - public class Scp1344Item : UsableItem + internal override void OnRemove() { - /// - /// Contains all the cached SCP-1344 items, accessible through their . - /// - public new static Dictionary Dictionary { get; } = []; - - /// - /// A reference to all instances of . - /// - public new static IReadOnlyCollection List => Dictionary.Values; - - /// - /// The base object. - /// - public new BaseScp1344Item Base { get; } - - /// - /// An internal constructor to prevent external instantiation. - /// - /// The base object. - internal Scp1344Item(BaseScp1344Item baseItem) : base(baseItem) - { - Dictionary.Add(baseItem, this); - Base = baseItem; - } - - /// - /// Gets the SCP-1576 item wrapper from the or creates a new one if it doesn't exist and the provided was not null. - /// - /// The of the item. - /// The requested item or null. - [return: NotNullIfNotNull(nameof(baseItem))] - public static Scp1344Item? Get(BaseScp1344Item? baseItem) - { - if (baseItem == null) - return null; - - return Dictionary.TryGetValue(baseItem, out Scp1344Item item) ? item : (Scp1344Item)CreateItemWrapper(baseItem); - } - - /// - /// An internal method to remove itself from the cache when the base object is destroyed. - /// - internal override void OnRemove() - { - base.OnRemove(); - Dictionary.Remove(Base); - } + base.OnRemove(); + Dictionary.Remove(Base); } -} +} \ No newline at end of file diff --git a/LabApi/Features/Wrappers/Pickups/Pickup.cs b/LabApi/Features/Wrappers/Pickups/Pickup.cs index 97473011..8bfbba9f 100644 --- a/LabApi/Features/Wrappers/Pickups/Pickup.cs +++ b/LabApi/Features/Wrappers/Pickups/Pickup.cs @@ -187,7 +187,8 @@ public Quaternion Rotation /// Gets the pickup wrapper from the or creates a new one if it doesn't exist. /// /// The of the pickup. - /// The requested item . + /// The requested item + [return: NotNullIfNotNull("itemPickupBase")] public static Pickup? Get(ItemPickupBase itemPickupBase) { if (itemPickupBase == null) @@ -312,12 +313,12 @@ private static Pickup AddPickup(ItemPickupBase itemPickupBase) /// The being removed. private static void RemovePickup(ItemPickupBase itemPickupBase) { - if (Dictionary.TryGetValue(itemPickupBase, out Pickup pickup)) - { - pickup.UnsubscribeEvents(); - Dictionary.Remove(itemPickupBase); - if (itemPickupBase.Info.Serial != 0) - SerialCache.Remove(itemPickupBase.Info.Serial); - } + if (!Dictionary.TryGetValue(itemPickupBase, out Pickup pickup)) + return; + + pickup.UnsubscribeEvents(); + Dictionary.Remove(itemPickupBase); + if (itemPickupBase.Info.Serial != 0) + SerialCache.Remove(itemPickupBase.Info.Serial); } } diff --git a/LabApi/Features/Wrappers/Players/Player.cs b/LabApi/Features/Wrappers/Players/Player.cs index 51dc78b3..cdc9cb07 100644 --- a/LabApi/Features/Wrappers/Players/Player.cs +++ b/LabApi/Features/Wrappers/Players/Player.cs @@ -87,7 +87,7 @@ internal static void Initialize() } /// - /// A internal constructor to prevent external instantiation. + /// An internal constructor to prevent external instantiation. /// /// The reference hub of the player. internal Player(ReferenceHub referenceHub) @@ -230,7 +230,7 @@ public float MaxHealth /// /// Gets or sets the player's current artificial health.
- /// Setting the value will clear all of the current "processes" (each process is responsible for decaying AHP value separately. Eg 2 processes blue candy AHP, which doesn't decay and adrenaline proccess, where AHP does decay).
+ /// Setting the value will clear all the current "processes" (each process is responsible for decaying AHP value separately. Eg 2 processes blue candy AHP, which doesn't decay and adrenaline proccess, where AHP does decay).
/// Note: This value cannot be greater than . Set it to your desired value first if its over and then set this one. ///
public float ArtificialHealth @@ -373,7 +373,7 @@ public Player? CurrentlySpectating if (!ReferenceHub.TryGetHubNetID(sr.SyncedSpectatedNetId, out ReferenceHub hub)) return null; - return Player.Get(hub); + return Get(hub); } } @@ -398,7 +398,7 @@ public List CurrentSpectators /// /// Gets or sets the player's current item. /// - public Item CurrentItem + public Item? CurrentItem { get => Item.Get(Inventory.CurInstance); set @@ -445,7 +445,7 @@ public string GroupColor } /// - /// Gets or sets the player's group name. + /// Gets or sets what is displayed for the player's group. /// public string GroupName { @@ -663,17 +663,12 @@ public Vector3 Position { get { - if (ReferenceHub.roleManager.CurrentRole is not IFpcRole fpcRole) - { + if (RoleBase is not IFpcRole fpcRole) return Vector3.zero; - } return fpcRole.FpcModule.Position; } - set - { - ReferenceHub.TryOverridePosition(value); - } + set => ReferenceHub.TryOverridePosition(value); } /// @@ -694,17 +689,12 @@ public Vector2 LookRotation get { if (ReferenceHub.roleManager.CurrentRole is not IFpcRole fpcRole) - { return Vector2.zero; - } FpcMouseLook mouseLook = fpcRole.FpcModule.MouseLook; return new Vector2(mouseLook.CurrentVertical, mouseLook.CurrentHorizontal); } - set - { - ReferenceHub.TryOverrideRotation(value); - } + set => ReferenceHub.TryOverrideRotation(value); } /// @@ -1341,6 +1331,15 @@ public void EnableEffect(byte intensity = 1, float duration = 0f, bool addDur public bool TryGetEffect([NotNullWhen(true)] out T? effect) where T : StatusEffectBase => ReferenceHub.playerEffectsController.TryGetEffect(out effect) && effect != null; + /// + /// Tries to get a specific based on its name. + /// + /// The name of the effect to get. + /// The effect found. + /// Whether the was successfully found. + public bool TryGetEffect(string effectName, [NotNullWhen(true)] out StatusEffectBase? effect) + => ReferenceHub.playerEffectsController.TryGetEffect(effectName, out effect) && effect != null; + /// /// Gets a specific status effect. /// diff --git a/LabApi/Features/Wrappers/Players/Ragdoll.cs b/LabApi/Features/Wrappers/Players/Ragdoll.cs index a963ba5c..c69dc90b 100644 --- a/LabApi/Features/Wrappers/Players/Ragdoll.cs +++ b/LabApi/Features/Wrappers/Players/Ragdoll.cs @@ -153,10 +153,7 @@ public void Destroy() /// /// Forcefully freezes this ragdoll for all clients. /// - public void Freeze() - { - Base.ClientFreezeRpc(); - } + public void Freeze() => Base.ClientFreezeRpc(); /// /// Unfreezes this ragdoll by spawning a copy of it and destroying the original. Reference to the changes, but no other action is required if you are referencing this object.
diff --git a/LabApi/Features/Wrappers/Players/Server.cs b/LabApi/Features/Wrappers/Players/Server.cs index d767c596..bf29848b 100644 --- a/LabApi/Features/Wrappers/Players/Server.cs +++ b/LabApi/Features/Wrappers/Players/Server.cs @@ -33,7 +33,7 @@ internal static void Initialize() /// /// The Instance. /// - public static Player? Host { get; private set; } = null; + public static Player? Host { get; private set; } /// /// Gets the IP address of the server. @@ -76,7 +76,16 @@ public static int ReservedSlots /// /// Gets the Ticks Per Second of the server. /// - public static double TPS => Math.Round(1f / Time.smoothDeltaTime); + public static double Tps => Math.Round(1f / Time.smoothDeltaTime); + + /// + /// Gets the max Ticks Per Second of the server. + /// + public static short MaxTps + { + get => ServerStatic.ServerTickrate; + set => ServerStatic.ServerTickrate = value; + } /// /// Gets or sets the spawn protection duration for players. @@ -88,7 +97,7 @@ public static float SpawnProtectDuration } /// - /// Gets whether or not the server is in Idle Mode. + /// Gets whether the server is in Idle Mode. /// public static bool IdleModeActive => IdleMode.IdleModeActive; @@ -247,7 +256,7 @@ public static bool BanUserId(string userId, string reason, long duration, string /// The ban reason. /// The duration of the ban. /// The nickname of the banned player. - /// Whether or not the ban was successful. + /// Whether the ban was successful. public static bool BanUserId(string userId, Player issuer, string reason, long duration, string bannedPlayerNickname = "UnknownName") { if (string.IsNullOrEmpty(userId) || string.IsNullOrEmpty(reason) || issuer == null) @@ -271,7 +280,7 @@ public static bool BanUserId(string userId, Player issuer, string reason, long d /// The ban reason. /// The duration of the ban. /// The nickname of the banned player. - /// Whether or not the ban was successful. + /// Whether the ban was successful. public static bool BanIpAddress(string ipAddress, string reason, long duration, string bannedPlayerNickname = "UnknownName") => BanIpAddress(ipAddress, Host!, reason, duration, bannedPlayerNickname); @@ -283,7 +292,7 @@ public static bool BanIpAddress(string ipAddress, string reason, long duration, /// The ban reason. /// The duration of the ban. /// The nickname of the banned player. - /// Whether or not the ban was successful. + /// Whether the ban was successful. public static bool BanIpAddress(string ipAddress, Player issuer, string reason, long duration, string bannedPlayerNickname = "UnknownName") { if (string.IsNullOrEmpty(ipAddress) || string.IsNullOrEmpty(reason) || issuer == null) @@ -304,7 +313,7 @@ public static bool BanIpAddress(string ipAddress, Player issuer, string reason, /// Unbans a player from the server. /// /// The User ID of the player to unban. - /// Whether or not the unban was successful. + /// Whether the unban was successful. public static bool UnbanUserId(string userId) { if (string.IsNullOrEmpty(userId) || !IsPlayerBanned(userId)) @@ -318,7 +327,7 @@ public static bool UnbanUserId(string userId) /// Unbans a player from the server. /// /// The IP address of the player. - /// Whether or not the unban was successful. + /// Whether the unban was successful. public static bool UnbanIpAddress(string ipAddress) { if (string.IsNullOrEmpty(ipAddress) || !IsPlayerBanned(ipAddress)) @@ -329,10 +338,10 @@ public static bool UnbanIpAddress(string ipAddress) } /// - /// Checks whether or not a player is banned. + /// Checks whether a player is banned. /// /// The User ID or IP address of the player. - /// Whether or not the player is banned. + /// Whether the player is banned. public static bool IsPlayerBanned(string value) { if (string.IsNullOrEmpty(value)) @@ -490,10 +499,7 @@ private class CategoryLimitsSynchronizer : ILimit /// public sbyte this[ItemCategory category] { - get - { - return InventoryLimits.StandardCategoryLimits[category]; - } + get => InventoryLimits.StandardCategoryLimits[category]; set { if (!InventoryLimits.StandardCategoryLimits.ContainsKey(category)) diff --git a/LabApi/LabApi.csproj b/LabApi/LabApi.csproj index c7cb7164..b5bc73c3 100644 --- a/LabApi/LabApi.csproj +++ b/LabApi/LabApi.csproj @@ -39,5 +39,5 @@ - + \ No newline at end of file diff --git a/LabApi/Loader/CommandLoader.cs b/LabApi/Loader/CommandLoader.cs index 52ec9a57..e9bbe8b4 100644 --- a/LabApi/Loader/CommandLoader.cs +++ b/LabApi/Loader/CommandLoader.cs @@ -148,7 +148,7 @@ public static IEnumerable RegisterCommands(Type type, string logName = /// The registered command if the command was successfully registered. public static bool TryRegisterCommand(Type commandType, Type commandHandlerType, [NotNullWhen(true)] out ICommand? command, string logName) { - command = default; + command = null; if (CommandHandlers.ContainsKey(commandType)) { @@ -192,7 +192,7 @@ public static bool TryRegisterCommand(Type commandType, Type commandHandlerType, /// The to register. /// The to register the command to. /// The name of the plugin to log to use when logging errors. - /// Whether or not the command was successfully registered. + /// Whether the command was successfully registered. public static bool TryRegisterCommand(ICommand command, CommandHandler commandHandler, string logName) { try diff --git a/LabApi/Loader/ConfigurationLoader.cs b/LabApi/Loader/ConfigurationLoader.cs index 66f6004a..72e8ef2d 100644 --- a/LabApi/Loader/ConfigurationLoader.cs +++ b/LabApi/Loader/ConfigurationLoader.cs @@ -63,7 +63,7 @@ public static bool TrySaveConfig(this Plugin plugin, TConfig config, st public static bool TryReadConfig(this Plugin plugin, string fileName, [NotNullWhen(true)] out TConfig? config) where TConfig : class, new() { - config = default; + config = null; try { @@ -101,7 +101,7 @@ public static bool TryReadConfig(this Plugin plugin, string fileName, [ public static bool TryLoadConfig(this Plugin plugin, string fileName, [NotNullWhen(true)] out TConfig? config) where TConfig : class, new() { - config = default; + config = null; // We retrieve the path of the configuration file. string path = plugin.GetConfigPath(fileName); @@ -119,7 +119,7 @@ public static bool TryLoadConfig(this Plugin plugin, string fileName, [ // We try to read the configuration from its file. else if (plugin.TryReadConfig(fileName, out config)) { - // We save the configuration to update new properties and return whether or not it was successfully saved. + // We save the configuration to update new properties and return whether it was successfully saved. return plugin.TrySaveConfig(config, fileName); } @@ -145,7 +145,7 @@ public static void SaveConfig(this Plugin plugin, TConfig config, strin /// The type of the configuration to read. /// The read configuration of the specified if successful, otherwise . public static TConfig? ReadConfig(this Plugin plugin, string fileName) - where TConfig : class, new() => plugin.TryReadConfig(fileName, out TConfig? config) ? config : default; + where TConfig : class, new() => plugin.TryReadConfig(fileName, out TConfig? config) ? config : null; /// /// Reads the configuration of the specified and creates a default instance if it doesn't exist. @@ -155,7 +155,7 @@ public static void SaveConfig(this Plugin plugin, TConfig config, strin /// The type of the configuration to load. /// The loaded configuration of the specified if successful, otherwise . public static TConfig? LoadConfig(this Plugin plugin, string fileName) - where TConfig : class, new() => plugin.TryLoadConfig(fileName, out TConfig? config) ? config : default; + where TConfig : class, new() => plugin.TryLoadConfig(fileName, out TConfig? config) ? config : null; /// /// Tries to create a default instance of the specified configuration. @@ -167,7 +167,7 @@ public static void SaveConfig(this Plugin plugin, TConfig config, strin public static bool TryCreateDefaultConfig(this Plugin plugin, [NotNullWhen(true)] out TConfig? config) where TConfig : class, new() { - config = default; + config = null; try { diff --git a/LabApi/Loader/Features/Misc/AssemblyUtils.cs b/LabApi/Loader/Features/Misc/AssemblyUtils.cs index f306e89b..a4b9f5d9 100644 --- a/LabApi/Loader/Features/Misc/AssemblyUtils.cs +++ b/LabApi/Loader/Features/Misc/AssemblyUtils.cs @@ -18,12 +18,12 @@ public static class AssemblyUtils private const string LoggerPrefix = "[ASSEMBLY_LOADER]"; /// - /// Checks whether or not the specified has missing dependencies and gets the types if it is loaded. + /// Checks whether the specified has missing dependencies and gets the types if it is loaded. /// /// The assembly to check missing dependencies for. /// The path of the assembly to log an error message. /// The types of the assembly if it is loaded. - /// Whether or not the specified has missing dependencies. + /// Whether the specified has missing dependencies. public static bool HasMissingDependencies(Assembly assembly, string assemblyPath, [NotNullWhen(false)] out Type[]? types) { // We convert the missing dependencies to an array to avoid multiple iterations. @@ -53,7 +53,7 @@ public static bool HasMissingDependencies(Assembly assembly, string assemblyPath Logger.Error(exception.ToString()); - types = default; + types = null; return true; // True = missing dependencies. } } @@ -171,7 +171,7 @@ public static bool TryGetDataStream(Assembly target, string name, [NotNullWhen(t /// /// The to get the assembly from. /// The assembly of the loaded . - /// Whether or not the assembly was successfully retrieved. + /// Whether the assembly was successfully retrieved. public static bool TryGetLoadedAssembly(this Plugin plugin, out Assembly assembly) { // We try to get the assembly of the specified plugin inside the plugin loader. diff --git a/LabApi/Loader/Features/Plugins/Configuration/Properties.cs b/LabApi/Loader/Features/Plugins/Configuration/Properties.cs index 87c584da..5706fb11 100644 --- a/LabApi/Loader/Features/Plugins/Configuration/Properties.cs +++ b/LabApi/Loader/Features/Plugins/Configuration/Properties.cs @@ -14,7 +14,7 @@ public class Properties public static Properties CreateDefault() => new(); /// - /// Whether or not the is enabled. + /// Whether the is enabled. /// [Description("Whether or not the plugin is enabled.")] public bool IsEnabled { get; set; } = true; diff --git a/LabApi/Loader/PluginLoader.cs b/LabApi/Loader/PluginLoader.cs index a8e39199..cc9a223e 100644 --- a/LabApi/Loader/PluginLoader.cs +++ b/LabApi/Loader/PluginLoader.cs @@ -23,7 +23,7 @@ public static partial class PluginLoader private const string PdbFileExtension = ".pdb"; /// - /// Whether or not the has been initialized. + /// Whether the has been initialized. /// public static bool Initialized { get; private set; }