Skip to content

Commit 7f35729

Browse files
refactor: CustomScpTermination (#629)
* refactor: CustomScpTermination * for new cassie update * fix: Remove breaking change --------- Co-authored-by: Yamato <66829532+louis1706@users.noreply.github.com>
1 parent 03d563c commit 7f35729

1 file changed

Lines changed: 42 additions & 17 deletions

File tree

EXILED/Exiled.API/Features/Cassie.cs

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ namespace Exiled.API.Features
2121
using Respawning;
2222
using Respawning.NamingRules;
2323

24-
using CustomFirearmHandler = DamageHandlers.FirearmDamageHandler;
25-
using CustomHandlerBase = DamageHandlers.DamageHandlerBase;
24+
using CustomHandler = DamageHandlers.CustomDamageHandler;
2625

2726
/// <summary>
2827
/// A set of tools to use in-game C.A.S.S.I.E.
@@ -188,25 +187,51 @@ public static void ScpTermination(Player scp, DamageHandlerBase info)
188187
=> CassieScpTerminationAnnouncement.AnnounceScpTermination(scp.ReferenceHub, info);
189188

190189
/// <summary>
191-
/// Announces the termination of a custom SCP name.
190+
/// Announces the termination of a custom SCP Number.
192191
/// </summary>
193-
/// <param name="scpName">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.</param>
192+
/// <param name="scpNumber">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.</param>
194193
/// <param name="info">Hit Information.</param>
195-
public static void CustomScpTermination(string scpName, CustomHandlerBase info)
194+
[Obsolete("Use this instead CustomScpTermination(string, CustomHandler)")]
195+
public static void CustomScpTermination(string scpNumber, DamageHandlers.DamageHandlerBase info)
196196
{
197-
string result = scpName;
198-
if (info.Is(out MicroHidDamageHandler _))
199-
result += " SUCCESSFULLY TERMINATED BY AUTOMATIC SECURITY SYSTEM";
200-
else if (info.Is(out WarheadDamageHandler _))
201-
result += " SUCCESSFULLY TERMINATED BY ALPHA WARHEAD";
202-
else if (info.Is(out UniversalDamageHandler _))
203-
result += " LOST IN DECONTAMINATION SEQUENCE";
204-
else if (info.BaseIs(out CustomFirearmHandler firearmDamageHandler) && firearmDamageHandler.Attacker is Player attacker)
205-
result += " CONTAINEDSUCCESSFULLY " + ConvertTeam(attacker.Role.Team, attacker.UnitName);
206-
207-
// result += "To be changed";
197+
if (scpNumber.StartsWith("SCP", StringComparison.InvariantCultureIgnoreCase))
198+
scpNumber = scpNumber.Remove(0, 3);
199+
200+
if (info is CustomHandler customHandler)
201+
CustomScpTermination(scpNumber, customHandler);
202+
}
203+
204+
/// <summary>
205+
/// Announces the termination of a custom SCP Number.
206+
/// </summary>
207+
/// <param name="scpNumber">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.</param>
208+
/// <param name="info">Hit Information.</param>
209+
public static void CustomScpTermination(string scpNumber, CustomHandler info)
210+
{
211+
if (info is null)
212+
throw new System.ArgumentNullException(nameof(info));
213+
214+
string result = "SCP " + scpNumber;
215+
if (info.Attacker is null)
216+
{
217+
result += info.Type switch
218+
{
219+
Enums.DamageType.Warhead => " SUCCESSFULLY TERMINATED BY ALPHA WARHEAD",
220+
Enums.DamageType.Decontamination => " LOST IN DECONTAMINATION SEQUENCE",
221+
Enums.DamageType.Tesla => " SUCCESSFULLY TERMINATED BY AUTOMATIC SECURITY SYSTEM",
222+
_ => " SUCCESSFULLY TERMINATED . TERMINATION CAUSE UNSPECIFIED",
223+
};
224+
}
208225
else
209-
result += " SUCCESSFULLY TERMINATED . TERMINATION CAUSE UNSPECIFIED";
226+
{
227+
result += info.Attacker.Role.Team switch
228+
{
229+
Team.SCPs => " TERMINATED BY SCP " + string.Join(" ", info.Attacker.Role.Name.Remove(0, 4).ToCharArray()),
230+
Team.Flamingos => " TERMINATED BY SCP 1 5 0 7",
231+
Team.OtherAlive or Team.Dead => " SUCCESSFULLY TERMINATED . TERMINATION CAUSE UNSPECIFIED",
232+
_ => " CONTAINEDSUCCESSFULLY " + ConvertTeam(info.Attacker.Role.Team, info.Attacker.UnitName),
233+
};
234+
}
210235

211236
float num = AlphaWarheadController.TimeUntilDetonation <= 0f ? 3.5f : 1f;
212237
GlitchyMessage(result, UnityEngine.Random.Range(0.1f, 0.14f) * num, UnityEngine.Random.Range(0.07f, 0.08f) * num);

0 commit comments

Comments
 (0)