From 974bd6dfb0fad4ea0c90c288ddb4fc0132a2b077 Mon Sep 17 00:00:00 2001 From: Jay Date: Tue, 12 Nov 2024 23:35:53 +0000 Subject: [PATCH 01/12] feat: add IsScp to RoleExtensions --- EXILED/Exiled.API/Extensions/RoleExtensions.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/EXILED/Exiled.API/Extensions/RoleExtensions.cs b/EXILED/Exiled.API/Extensions/RoleExtensions.cs index c674af1bf8..9f278d8119 100644 --- a/EXILED/Exiled.API/Extensions/RoleExtensions.cs +++ b/EXILED/Exiled.API/Extensions/RoleExtensions.cs @@ -52,7 +52,7 @@ public static class RoleExtensions Team.FoundationForces or Team.Scientists => Side.Mtf, Team.ChaosInsurgency or Team.ClassD => Side.ChaosInsurgency, Team.OtherAlive => Side.Tutorial, - _ => Side.None, + _ => Side.None }; /// @@ -68,7 +68,7 @@ public static class RoleExtensions RoleTypeId.Scp049 or RoleTypeId.Scp939 or RoleTypeId.Scp0492 or RoleTypeId.Scp079 or RoleTypeId.Scp096 or RoleTypeId.Scp106 or RoleTypeId.Scp173 or RoleTypeId.Scp3114 => Team.SCPs, RoleTypeId.FacilityGuard or RoleTypeId.NtfCaptain or RoleTypeId.NtfPrivate or RoleTypeId.NtfSergeant or RoleTypeId.NtfSpecialist => Team.FoundationForces, RoleTypeId.Tutorial => Team.OtherAlive, - _ => Team.Dead, + _ => Team.Dead }; /// @@ -113,7 +113,7 @@ public static bool TryGetRoleBase(this RoleTypeId roleType, out T roleBase) Team.ClassD or Team.ChaosInsurgency => LeadingTeam.ChaosInsurgency, Team.FoundationForces or Team.Scientists => LeadingTeam.FacilityForces, Team.SCPs => LeadingTeam.Anomalies, - _ => LeadingTeam.Draw, + _ => LeadingTeam.Draw }; /// @@ -168,5 +168,12 @@ public static Dictionary GetStartingAmmo(this RoleTypeId roleT return info.Ammo.ToDictionary(kvp => kvp.Key.GetAmmoType(), kvp => kvp.Value); } + + /// + /// Checks if the role is an SCP role. + /// + /// The . + /// A boolean which is true when the role is an SCP role. + public static bool IsScp(this RoleTypeId roleType) => roleType.GetTeam() == Team.SCPs; } } \ No newline at end of file From 80b4094822e34a55d41aa57769ece161f639fb75 Mon Sep 17 00:00:00 2001 From: Jay Date: Wed, 13 Nov 2024 08:27:20 +0000 Subject: [PATCH 02/12] Discard changes to EXILED/EXILED.props --- EXILED/EXILED.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED/EXILED.props b/EXILED/EXILED.props index 62d6e57cd7..b4aecc1f33 100644 --- a/EXILED/EXILED.props +++ b/EXILED/EXILED.props @@ -15,7 +15,7 @@ - 8.14.1 + 8.14.0 false From a8703901030065005e2f61a85baabeca9e050fc6 Mon Sep 17 00:00:00 2001 From: Jay Date: Thu, 14 Nov 2024 08:08:56 +0000 Subject: [PATCH 03/12] style: move IsScp next to IsFpcRole --- EXILED/Exiled.API/Extensions/RoleExtensions.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/EXILED/Exiled.API/Extensions/RoleExtensions.cs b/EXILED/Exiled.API/Extensions/RoleExtensions.cs index 9f278d8119..4e48b69572 100644 --- a/EXILED/Exiled.API/Extensions/RoleExtensions.cs +++ b/EXILED/Exiled.API/Extensions/RoleExtensions.cs @@ -123,6 +123,13 @@ public static bool TryGetRoleBase(this RoleTypeId roleType, out T roleBase) /// Returns whether is an or not. public static bool IsFpcRole(this RoleTypeId roleType) => roleType.GetRoleBase() is IFpcRole; + /// + /// Checks if the role is an SCP role. + /// + /// The . + /// A boolean which is true when the role is an SCP role. + public static bool IsScp(this RoleTypeId roleType) => roleType.GetTeam() == Team.SCPs; + /// /// Gets a random spawn point of a . /// @@ -168,12 +175,5 @@ public static Dictionary GetStartingAmmo(this RoleTypeId roleT return info.Ammo.ToDictionary(kvp => kvp.Key.GetAmmoType(), kvp => kvp.Value); } - - /// - /// Checks if the role is an SCP role. - /// - /// The . - /// A boolean which is true when the role is an SCP role. - public static bool IsScp(this RoleTypeId roleType) => roleType.GetTeam() == Team.SCPs; } } \ No newline at end of file From 8c9ad97321aeec9970aacd59ba5e05d7ed945b83 Mon Sep 17 00:00:00 2001 From: Jay Date: Thu, 14 Nov 2024 08:38:32 +0000 Subject: [PATCH 04/12] feat: add more Is checks --- .../Exiled.API/Extensions/RoleExtensions.cs | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/EXILED/Exiled.API/Extensions/RoleExtensions.cs b/EXILED/Exiled.API/Extensions/RoleExtensions.cs index 4e48b69572..1e9ec838c8 100644 --- a/EXILED/Exiled.API/Extensions/RoleExtensions.cs +++ b/EXILED/Exiled.API/Extensions/RoleExtensions.cs @@ -130,6 +130,48 @@ public static bool TryGetRoleBase(this RoleTypeId roleType, out T roleBase) /// A boolean which is true when the role is an SCP role. public static bool IsScp(this RoleTypeId roleType) => roleType.GetTeam() == Team.SCPs; + /// + /// Checks if the role is a human role. + /// + /// The . + /// A boolean which is true when the role is a human role. + public static bool IsHuman(this RoleTypeId roleType) => roleType.GetTeam() != Team.Dead; + + /// + /// Checks if the role is a dead role. + /// + /// The . + /// A boolean which is true when the role is a dead role. + public static bool IsDead(this RoleTypeId roleType) => roleType.GetTeam() == Team.Dead; + + /// + /// Checks if the role is an NTF role. + /// + /// The . + /// A boolean which is true when the role is an NTF role. + public static bool IsNtf(this RoleTypeId roleType) => roleType.GetTeam() == Team.FoundationForces; + + /// + /// Checks if the role is a Chaos role. + /// + /// The . + /// A boolean which is true when the role is an Chaos role. + public static bool IsChaos(this RoleTypeId roleType) => roleType.GetTeam() == Team.ChaosInsurgency; + + /// + /// Checks if the role is a military role (Chaos Insurgency or NTF). + /// + /// The . + /// A boolean which is true when the role is a military role. + public static bool IsMilitary(this RoleTypeId roleType) => roleType.IsNtf() || roleType.IsChaos(); + + /// + /// Checks if the role is a civilian role (Scientists and Class-D). + /// + /// The . + /// A boolean which is true when the role is a civilian role. + public static bool IsCivilian(this RoleTypeId roleType) => roleType == RoleTypeId.ClassD || roleType == RoleTypeId.Scientist; + /// /// Gets a random spawn point of a . /// From 2d852065a7935ce016e0e0c0b983763faf5dc93b Mon Sep 17 00:00:00 2001 From: Jay Date: Thu, 14 Nov 2024 08:46:55 +0000 Subject: [PATCH 05/12] style: add back trailing commas --- EXILED/Exiled.API/Extensions/RoleExtensions.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/EXILED/Exiled.API/Extensions/RoleExtensions.cs b/EXILED/Exiled.API/Extensions/RoleExtensions.cs index 1e9ec838c8..94a1487761 100644 --- a/EXILED/Exiled.API/Extensions/RoleExtensions.cs +++ b/EXILED/Exiled.API/Extensions/RoleExtensions.cs @@ -52,7 +52,7 @@ public static class RoleExtensions Team.FoundationForces or Team.Scientists => Side.Mtf, Team.ChaosInsurgency or Team.ClassD => Side.ChaosInsurgency, Team.OtherAlive => Side.Tutorial, - _ => Side.None + _ => Side.None, }; /// @@ -68,7 +68,7 @@ public static class RoleExtensions RoleTypeId.Scp049 or RoleTypeId.Scp939 or RoleTypeId.Scp0492 or RoleTypeId.Scp079 or RoleTypeId.Scp096 or RoleTypeId.Scp106 or RoleTypeId.Scp173 or RoleTypeId.Scp3114 => Team.SCPs, RoleTypeId.FacilityGuard or RoleTypeId.NtfCaptain or RoleTypeId.NtfPrivate or RoleTypeId.NtfSergeant or RoleTypeId.NtfSpecialist => Team.FoundationForces, RoleTypeId.Tutorial => Team.OtherAlive, - _ => Team.Dead + _ => Team.Dead, }; /// @@ -113,7 +113,7 @@ public static bool TryGetRoleBase(this RoleTypeId roleType, out T roleBase) Team.ClassD or Team.ChaosInsurgency => LeadingTeam.ChaosInsurgency, Team.FoundationForces or Team.Scientists => LeadingTeam.FacilityForces, Team.SCPs => LeadingTeam.Anomalies, - _ => LeadingTeam.Draw + _ => LeadingTeam.Draw, }; /// From e3cd71efe6ba6090962735104387858a5f866d99 Mon Sep 17 00:00:00 2001 From: Jay Date: Thu, 14 Nov 2024 08:54:34 +0000 Subject: [PATCH 06/12] feat: update player to use RoleExtensions --- EXILED/Exiled.API/Features/Player.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/EXILED/Exiled.API/Features/Player.cs b/EXILED/Exiled.API/Features/Player.cs index c6cd275146..f39a5acd50 100644 --- a/EXILED/Exiled.API/Features/Player.cs +++ b/EXILED/Exiled.API/Features/Player.cs @@ -687,24 +687,24 @@ public ScpSpawnPreferences.SpawnPreferences ScpPreferences /// Equivalent to checking the player's . /// // TODO: Change logic for FacilityGuard in next major update - public bool IsNTF => Role?.Team is Team.FoundationForces; + public bool IsNTF => Role?.Type.IsNtf() ?? false; /// /// Gets a value indicating whether or not the player's is any Chaos rank. /// Equivalent to checking the player's . /// - public bool IsCHI => Role?.Team is Team.ChaosInsurgency; + public bool IsCHI => Role?.Type.IsChaos() ?? false; /// /// Gets a value indicating whether or not the player's is any SCP. /// Equivalent to checking the player's . /// - public bool IsScp => Role?.Team is Team.SCPs; + public bool IsScp => Role?.Type.IsScp() ?? false; /// /// Gets a value indicating whether or not the player's is any human rank. /// - public bool IsHuman => Role is not null && Role.Is(out HumanRole _); + public bool IsHuman => RoleExtensions.IsHuman(Role?.Type ?? RoleTypeId.None); /// /// Gets a value indicating whether or not the player's is equal to . From dd71f42f0ad6a77075cede6293b82338d91c033a Mon Sep 17 00:00:00 2001 From: Jay Date: Thu, 14 Nov 2024 09:05:46 +0000 Subject: [PATCH 07/12] fix: IsHuman --- EXILED/Exiled.API/Extensions/RoleExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED/Exiled.API/Extensions/RoleExtensions.cs b/EXILED/Exiled.API/Extensions/RoleExtensions.cs index 94a1487761..aab203ee04 100644 --- a/EXILED/Exiled.API/Extensions/RoleExtensions.cs +++ b/EXILED/Exiled.API/Extensions/RoleExtensions.cs @@ -135,7 +135,7 @@ public static bool TryGetRoleBase(this RoleTypeId roleType, out T roleBase) /// /// The . /// A boolean which is true when the role is a human role. - public static bool IsHuman(this RoleTypeId roleType) => roleType.GetTeam() != Team.Dead; + public static bool IsHuman(this RoleTypeId roleType) => !roleType.IsDead() && !roleType.IsScp(); /// /// Checks if the role is a dead role. From 44feae92acc268f22973ed39ef6dedb9d453aa4e Mon Sep 17 00:00:00 2001 From: Jay Date: Thu, 14 Nov 2024 09:09:54 +0000 Subject: [PATCH 08/12] fix: Player.IsHuman --- EXILED/Exiled.API/Features/Player.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED/Exiled.API/Features/Player.cs b/EXILED/Exiled.API/Features/Player.cs index f39a5acd50..17bf6cdd69 100644 --- a/EXILED/Exiled.API/Features/Player.cs +++ b/EXILED/Exiled.API/Features/Player.cs @@ -704,7 +704,7 @@ public ScpSpawnPreferences.SpawnPreferences ScpPreferences /// /// Gets a value indicating whether or not the player's is any human rank. /// - public bool IsHuman => RoleExtensions.IsHuman(Role?.Type ?? RoleTypeId.None); + public bool IsHuman => Role is not null && RoleExtensions.IsHuman(Role.Type); /// /// Gets a value indicating whether or not the player's is equal to . From 735d01b2af1f81e4f7d47df774879e5c55d21cad Mon Sep 17 00:00:00 2001 From: Jay Date: Mon, 18 Nov 2024 09:51:47 +0000 Subject: [PATCH 09/12] feat: facility guard are not NTF --- EXILED/Exiled.API/Extensions/RoleExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EXILED/Exiled.API/Extensions/RoleExtensions.cs b/EXILED/Exiled.API/Extensions/RoleExtensions.cs index aab203ee04..4910d43b1f 100644 --- a/EXILED/Exiled.API/Extensions/RoleExtensions.cs +++ b/EXILED/Exiled.API/Extensions/RoleExtensions.cs @@ -149,7 +149,7 @@ public static bool TryGetRoleBase(this RoleTypeId roleType, out T roleBase) /// /// The . /// A boolean which is true when the role is an NTF role. - public static bool IsNtf(this RoleTypeId roleType) => roleType.GetTeam() == Team.FoundationForces; + public static bool IsNtf(this RoleTypeId roleType) => roleType.GetTeam() == Team.FoundationForces && roleType != RoleTypeId.FacilityGuard; /// /// Checks if the role is a Chaos role. From 71f24984b1e7315f5fcd3546eeaba3addf7ef622 Mon Sep 17 00:00:00 2001 From: Jay Date: Mon, 18 Nov 2024 10:49:37 +0000 Subject: [PATCH 10/12] docs: IsNtf and IsMilitary don't include fac guards --- EXILED/Exiled.API/Extensions/RoleExtensions.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/EXILED/Exiled.API/Extensions/RoleExtensions.cs b/EXILED/Exiled.API/Extensions/RoleExtensions.cs index 4910d43b1f..0593aee576 100644 --- a/EXILED/Exiled.API/Extensions/RoleExtensions.cs +++ b/EXILED/Exiled.API/Extensions/RoleExtensions.cs @@ -148,21 +148,21 @@ public static bool TryGetRoleBase(this RoleTypeId roleType, out T roleBase) /// Checks if the role is an NTF role. /// /// The . - /// A boolean which is true when the role is an NTF role. + /// A boolean which is true when the role is an NTF role. Does not include Facility Guards. public static bool IsNtf(this RoleTypeId roleType) => roleType.GetTeam() == Team.FoundationForces && roleType != RoleTypeId.FacilityGuard; /// /// Checks if the role is a Chaos role. /// /// The . - /// A boolean which is true when the role is an Chaos role. + /// A boolean which is true when the role is a Chaos role. public static bool IsChaos(this RoleTypeId roleType) => roleType.GetTeam() == Team.ChaosInsurgency; /// /// Checks if the role is a military role (Chaos Insurgency or NTF). /// /// The . - /// A boolean which is true when the role is a military role. + /// A boolean which is true when the role is a military role. Does not include Facility Guards. public static bool IsMilitary(this RoleTypeId roleType) => roleType.IsNtf() || roleType.IsChaos(); /// From c03ccc13e79eaad33ca2ae2a2ec28c54d292fc47 Mon Sep 17 00:00:00 2001 From: Jay Date: Tue, 19 Nov 2024 08:09:06 +0000 Subject: [PATCH 11/12] feat: revert back useless changes --- EXILED/Exiled.API/Features/Player.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/EXILED/Exiled.API/Features/Player.cs b/EXILED/Exiled.API/Features/Player.cs index 17bf6cdd69..9cc1758f1f 100644 --- a/EXILED/Exiled.API/Features/Player.cs +++ b/EXILED/Exiled.API/Features/Player.cs @@ -687,13 +687,13 @@ public ScpSpawnPreferences.SpawnPreferences ScpPreferences /// Equivalent to checking the player's . /// // TODO: Change logic for FacilityGuard in next major update - public bool IsNTF => Role?.Type.IsNtf() ?? false; + public bool IsNTF => Role?.Team is Team.FoundationForces; /// /// Gets a value indicating whether or not the player's is any Chaos rank. /// Equivalent to checking the player's . /// - public bool IsCHI => Role?.Type.IsChaos() ?? false; + public bool IsCHI => Role?.Team is Team.ChaosInsurgency; /// /// Gets a value indicating whether or not the player's is any SCP. @@ -704,7 +704,7 @@ public ScpSpawnPreferences.SpawnPreferences ScpPreferences /// /// Gets a value indicating whether or not the player's is any human rank. /// - public bool IsHuman => Role is not null && RoleExtensions.IsHuman(Role.Type); + public bool IsHuman => Role is not null && Role.Is(out HumanRole _); /// /// Gets a value indicating whether or not the player's is equal to . From bcdfb3b396c028b071145ff36af364e8b30df23d Mon Sep 17 00:00:00 2001 From: Jay Date: Tue, 19 Nov 2024 08:09:24 +0000 Subject: [PATCH 12/12] feat: remove IsHuman to avoid conflicts --- EXILED/Exiled.API/Extensions/RoleExtensions.cs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/EXILED/Exiled.API/Extensions/RoleExtensions.cs b/EXILED/Exiled.API/Extensions/RoleExtensions.cs index 0593aee576..f9e86fa1a0 100644 --- a/EXILED/Exiled.API/Extensions/RoleExtensions.cs +++ b/EXILED/Exiled.API/Extensions/RoleExtensions.cs @@ -130,13 +130,6 @@ public static bool TryGetRoleBase(this RoleTypeId roleType, out T roleBase) /// A boolean which is true when the role is an SCP role. public static bool IsScp(this RoleTypeId roleType) => roleType.GetTeam() == Team.SCPs; - /// - /// Checks if the role is a human role. - /// - /// The . - /// A boolean which is true when the role is a human role. - public static bool IsHuman(this RoleTypeId roleType) => !roleType.IsDead() && !roleType.IsScp(); - /// /// Checks if the role is a dead role. ///