Skip to content

Commit 83f40a7

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 2e55e4c commit 83f40a7

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
@@ -25,8 +25,7 @@ namespace Exiled.API.Features
2525

2626
using Respawning.NamingRules;
2727

28-
using CustomFirearmHandler = DamageHandlers.FirearmDamageHandler;
29-
using CustomHandlerBase = DamageHandlers.DamageHandlerBase;
28+
using CustomHandler = DamageHandlers.CustomDamageHandler;
3029

3130
/// <summary>
3231
/// A set of tools to use in-game C.A.S.S.I.E.
@@ -194,25 +193,51 @@ public static void ScpTermination(Player scp, DamageHandlerBase info)
194193
=> CassieScpTerminationAnnouncement.AnnounceScpTermination(scp.ReferenceHub, info);
195194

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

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

0 commit comments

Comments
 (0)