From dc9d748972edae7a463ae371f66cb71c80544199 Mon Sep 17 00:00:00 2001 From: XingYeFish <154997195+XingYeNotFish@users.noreply.github.com> Date: Tue, 12 Aug 2025 15:00:12 +0800 Subject: [PATCH 1/2] refactor: rewrite CustomScpTermination Refine and match corresponding DamageHandler --- EXILED/Exiled.API/Features/Cassie.cs | 55 +++++++++++++++++++--------- 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/EXILED/Exiled.API/Features/Cassie.cs b/EXILED/Exiled.API/Features/Cassie.cs index 0730f9a5a9..d7b654f815 100644 --- a/EXILED/Exiled.API/Features/Cassie.cs +++ b/EXILED/Exiled.API/Features/Cassie.cs @@ -21,8 +21,7 @@ namespace Exiled.API.Features using Respawning; - using CustomFirearmHandler = DamageHandlers.FirearmDamageHandler; - using CustomHandlerBase = DamageHandlers.DamageHandlerBase; + using CustomHandler = DamageHandlers.CustomDamageHandler; /// /// A set of tools to use in-game C.A.S.S.I.E. @@ -140,25 +139,47 @@ public static void ScpTermination(Player scp, DamageHandlerBase info) => NineTailedFoxAnnouncer.AnnounceScpTermination(scp.ReferenceHub, info); /// - /// Announces the termination of a custom SCP name. + /// Announces the termination of a custom SCP Number. /// - /// SCP Name. Note that for larger numbers, C.A.S.S.I.E will pronounce the place (eg. "457" -> "four hundred fifty seven"). Spaces can be used to prevent this behavior. + /// SCP Number. Note that for larger numbers, C.A.S.S.I.E will pronounce the place (eg. "457" -> "four hundred fifty seven"). Spaces can be used to prevent this behavior. /// Hit Information. - public static void CustomScpTermination(string scpName, CustomHandlerBase info) + public static void CustomScpTermination(string scpNumber, CustomHandler info) { - string result = scpName; - if (info.Is(out MicroHidDamageHandler _)) - result += " SUCCESSFULLY TERMINATED BY AUTOMATIC SECURITY SYSTEM"; - else if (info.Is(out WarheadDamageHandler _)) - result += " SUCCESSFULLY TERMINATED BY ALPHA WARHEAD"; - else if (info.Is(out UniversalDamageHandler _)) - result += " LOST IN DECONTAMINATION SEQUENCE"; - else if (info.BaseIs(out CustomFirearmHandler firearmDamageHandler) && firearmDamageHandler.Attacker is Player attacker) - result += " CONTAINEDSUCCESSFULLY " + ConvertTeam(attacker.Role.Team, attacker.UnitName); - - // result += "To be changed"; + if (info is null) + throw new System.ArgumentNullException(nameof(info)); + + string result = "SCP " + scpNumber; + if (info.Attacker is null) + { + if (info.Type is Enums.DamageType.Warhead) + result += " SUCCESSFULLY TERMINATED BY ALPHA WARHEAD"; + else if (info.Type is Enums.DamageType.Decontamination) + result += " LOST IN DECONTAMINATION SEQUENCE"; + else if (info.Type is Enums.DamageType.Tesla) + result += " SUCCESSFULLY TERMINATED BY AUTOMATIC SECURITY SYSTEM"; + else + result += " SUCCESSFULLY TERMINATED . TERMINATION CAUSE UNSPECIFIED"; + } else - result += " SUCCESSFULLY TERMINATED . TERMINATION CAUSE UNSPECIFIED"; + { + if (info.Attacker.Role.Team is Team.SCPs) + { + string attacker_name = string.Join(" ", info.Attacker.Role.Name.Remove(0, 4).ToCharArray()); + result += " TERMINATED BY SCP " + attacker_name; + } + else if (info.Attacker.Role.Team is Team.Flamingos) + { + result += " TERMINATED BY SCP 1 5 0 7"; + } + else if (info.Attacker.Role.Team is Team.OtherAlive || info.Attacker.Role.Team is Team.Dead) + { + result += " SUCCESSFULLY TERMINATED . TERMINATION CAUSE UNSPECIFIED"; + } + else + { + result += " CONTAINEDSUCCESSFULLY " + ConvertTeam(info.Attacker.Role.Team, info.Attacker.UnitName); + } + } float num = AlphaWarheadController.TimeUntilDetonation <= 0f ? 3.5f : 1f; GlitchyMessage(result, UnityEngine.Random.Range(0.1f, 0.14f) * num, UnityEngine.Random.Range(0.07f, 0.08f) * num); From 5739e6f94e4ab4f48e12fa9c9560f6d263df2544 Mon Sep 17 00:00:00 2001 From: XingYeFish <154997195+XingYeNotFish@users.noreply.github.com> Date: Tue, 12 Aug 2025 21:17:37 +0800 Subject: [PATCH 2/2] use switch --- EXILED/Exiled.API/Features/Cassie.cs | 37 ++++++++++------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/EXILED/Exiled.API/Features/Cassie.cs b/EXILED/Exiled.API/Features/Cassie.cs index d7b654f815..88707e4365 100644 --- a/EXILED/Exiled.API/Features/Cassie.cs +++ b/EXILED/Exiled.API/Features/Cassie.cs @@ -151,34 +151,23 @@ public static void CustomScpTermination(string scpNumber, CustomHandler info) string result = "SCP " + scpNumber; if (info.Attacker is null) { - if (info.Type is Enums.DamageType.Warhead) - result += " SUCCESSFULLY TERMINATED BY ALPHA WARHEAD"; - else if (info.Type is Enums.DamageType.Decontamination) - result += " LOST IN DECONTAMINATION SEQUENCE"; - else if (info.Type is Enums.DamageType.Tesla) - result += " SUCCESSFULLY TERMINATED BY AUTOMATIC SECURITY SYSTEM"; - else - result += " SUCCESSFULLY TERMINATED . TERMINATION CAUSE UNSPECIFIED"; + result += info.Type switch + { + Enums.DamageType.Warhead => " SUCCESSFULLY TERMINATED BY ALPHA WARHEAD", + Enums.DamageType.Decontamination => " LOST IN DECONTAMINATION SEQUENCE", + Enums.DamageType.Tesla => " SUCCESSFULLY TERMINATED BY AUTOMATIC SECURITY SYSTEM", + _ => " SUCCESSFULLY TERMINATED . TERMINATION CAUSE UNSPECIFIED", + }; } else { - if (info.Attacker.Role.Team is Team.SCPs) - { - string attacker_name = string.Join(" ", info.Attacker.Role.Name.Remove(0, 4).ToCharArray()); - result += " TERMINATED BY SCP " + attacker_name; - } - else if (info.Attacker.Role.Team is Team.Flamingos) - { - result += " TERMINATED BY SCP 1 5 0 7"; - } - else if (info.Attacker.Role.Team is Team.OtherAlive || info.Attacker.Role.Team is Team.Dead) - { - result += " SUCCESSFULLY TERMINATED . TERMINATION CAUSE UNSPECIFIED"; - } - else + result += info.Attacker.Role.Team switch { - result += " CONTAINEDSUCCESSFULLY " + ConvertTeam(info.Attacker.Role.Team, info.Attacker.UnitName); - } + Team.SCPs => " TERMINATED BY SCP " + string.Join(" ", info.Attacker.Role.Name.Remove(0, 4).ToCharArray()), + Team.Flamingos => " TERMINATED BY SCP 1 5 0 7", + Team.OtherAlive or Team.Dead => " SUCCESSFULLY TERMINATED . TERMINATION CAUSE UNSPECIFIED", + _ => " CONTAINEDSUCCESSFULLY " + ConvertTeam(info.Attacker.Role.Team, info.Attacker.UnitName), + }; } float num = AlphaWarheadController.TimeUntilDetonation <= 0f ? 3.5f : 1f;