]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
List antags in custody in round end screen (#21566)
authorthemias <89101928+themias@users.noreply.github.com>
Mon, 13 Nov 2023 10:04:33 +0000 (05:04 -0500)
committerGitHub <noreply@github.com>
Mon, 13 Nov 2023 10:04:33 +0000 (03:04 -0700)
* List antags in custody in round end screen

* Only show the message for traitors

Content.Server/Objectives/ObjectivesSystem.cs
Resources/Locale/en-US/objectives/round-end.ftl

index 3f7e92963a83be0f5e6da933b8945fd8dfc65ee5..511558216d5a2c7577fd0844751b315744a46dd0 100644 (file)
@@ -1,7 +1,10 @@
-using Content.Server.GameTicking;
+using Content.Server.GameTicking;
 using Content.Server.GameTicking.Rules.Components;
 using Content.Server.Mind;
+using Content.Server.Shuttles.Systems;
+using Content.Shared.Cuffs.Components;
 using Content.Shared.Mind;
+using Content.Shared.Mobs.Systems;
 using Content.Shared.Objectives.Components;
 using Content.Shared.Objectives.Systems;
 using Content.Shared.Random;
@@ -18,6 +21,7 @@ public sealed class ObjectivesSystem : SharedObjectivesSystem
     [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
     [Dependency] private readonly IRobustRandom _random = default!;
     [Dependency] private readonly MindSystem _mind = default!;
+    [Dependency] private readonly EmergencyShuttleSystem _emergencyShuttle = default!;
 
     public override void Initialize()
     {
@@ -71,12 +75,18 @@ public sealed class ObjectivesSystem : SharedObjectivesSystem
         {
             // first get the total number of players that were in these game rules combined
             var total = 0;
+            var totalInCustody = 0;
             foreach (var (_, minds) in summary)
             {
                 total += minds.Count;
+                totalInCustody += minds.Where(m => IsInCustody(m)).Count();
             }
 
             var result = Loc.GetString("objectives-round-end-result", ("count", total), ("agent", agent));
+            if (agent == Loc.GetString("traitor-round-end-agent-name"))
+            {
+                result += "\n" + Loc.GetString("objectives-round-end-result-in-custody", ("count", total), ("custody", totalInCustody), ("agent", agent));
+            }
             // next add all the players with its own prepended text
             foreach (var (prepend, minds) in summary)
             {
@@ -123,14 +133,16 @@ public sealed class ObjectivesSystem : SharedObjectivesSystem
 
             result += "\n";
 
+            var custody = IsInCustody(mindId, mind) ? Loc.GetString("objectives-in-custody") + " " : "";
+
             var objectives = mind.AllObjectives.ToArray();
             if (objectives.Length == 0)
             {
-                result += Loc.GetString("objectives-no-objectives", ("title", title), ("agent", agent));
+                result += Loc.GetString("objectives-no-objectives", ("custody", custody), ("title", title), ("agent", agent));
                 continue;
             }
 
-            result += Loc.GetString("objectives-with-objectives", ("title", title), ("agent", agent));
+            result += Loc.GetString("objectives-with-objectives", ("custody", custody), ("title", title), ("agent", agent));
 
             foreach (var objectiveGroup in objectives.GroupBy(o => Comp<ObjectiveComponent>(o).Issuer))
             {
@@ -197,6 +209,27 @@ public sealed class ObjectivesSystem : SharedObjectivesSystem
 
         return null;
     }
+
+    /// <summary>
+    /// Returns whether a target is considered 'in custody' (cuffed on the shuttle).
+    /// </summary>
+    private bool IsInCustody(EntityUid mindId, MindComponent? mind = null)
+    {
+        if (!Resolve(mindId, ref mind))
+            return false;
+
+        // Ghosting will not save you
+        bool originalEntityInCustody = false;
+        EntityUid? originalEntity = GetEntity(mind.OriginalOwnedEntity);
+        if (originalEntity.HasValue && originalEntity != mind.OwnedEntity)
+        {
+            originalEntityInCustody = TryComp<CuffableComponent>(originalEntity, out var origCuffed) && origCuffed.CuffedHandCount > 0
+                   && _emergencyShuttle.IsTargetEscaping(originalEntity.Value);
+        }
+
+        return originalEntityInCustody || (TryComp<CuffableComponent>(mind.OwnedEntity, out var cuffed) && cuffed.CuffedHandCount > 0
+               && _emergencyShuttle.IsTargetEscaping(mind.OwnedEntity.Value));
+    }
 }
 
 /// <summary>
index 4c0e5884ca31506ba2fc02c150a8f31be8ce82dc..129d809823eb693690d01ec6c059dee548071f3e 100644 (file)
@@ -3,12 +3,16 @@ objectives-round-end-result = {$count ->
     *[other] There were {$count} {MAKEPLURAL($agent)}.
 }
 
+objectives-round-end-result-in-custody = {$custody} out of {$count} {MAKEPLURAL($agent)} were in custody.
+
 objectives-player-user-named = [color=White]{$name}[/color] ([color=gray]{$user}[/color])
 objectives-player-user = [color=gray]{$user}[/color]
 objectives-player-named = [color=White]{$name}[/color]
 
-objectives-no-objectives = {$title} was a {$agent}.
-objectives-with-objectives = {$title} was a {$agent} who had the following objectives:
+objectives-no-objectives = [bold][color=red]{$custody}[/color]{$title} was a {$agent}.
+objectives-with-objectives = [bold][color=red]{$custody}[/color]{$title} was a {$agent} who had the following objectives:
 
 objectives-objective-success = {$objective} | [color={$markupColor}]Success![/color]
 objectives-objective-fail = {$objective} | [color={$markupColor}]Failure![/color] ({$progress}%)
+
+objectives-in-custody = | IN CUSTODY |
\ No newline at end of file