]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
better deconversion (#23315)
authordeltanedas <39013340+deltanedas@users.noreply.github.com>
Sun, 14 Jan 2024 03:20:35 +0000 (03:20 +0000)
committerGitHub <noreply@github.com>
Sun, 14 Jan 2024 03:20:35 +0000 (14:20 +1100)
* add deconverted window

* show deconverted window when deconverting + remove the role

* webedit ops

* antagonist -> revolutionary

* evil

* oh

* eui ops

---------

Co-authored-by: deltanedas <@deltanedas:kde.org>
Content.Client/Revolutionary/UI/DeconvertedEui.cs [new file with mode: 0644]
Content.Client/Revolutionary/UI/DeconvertedMenu.xaml [new file with mode: 0644]
Content.Client/Revolutionary/UI/DeconvertedMenu.xaml.cs [new file with mode: 0644]
Content.Server/GameTicking/Rules/RevolutionaryRuleSystem.cs
Content.Server/Revolutionary/DeconvertedEui.cs [new file with mode: 0644]
Resources/Locale/en-US/game-ticking/game-presets/preset-revolutionary.ftl

diff --git a/Content.Client/Revolutionary/UI/DeconvertedEui.cs b/Content.Client/Revolutionary/UI/DeconvertedEui.cs
new file mode 100644 (file)
index 0000000..33495f8
--- /dev/null
@@ -0,0 +1,25 @@
+using Content.Client.Eui;
+
+namespace Content.Client.Revolutionary.UI;
+
+public sealed class DeconvertedEui : BaseEui
+{
+    private readonly DeconvertedMenu _menu;
+
+    public DeconvertedEui()
+    {
+        _menu = new DeconvertedMenu();
+    }
+
+    public override void Opened()
+    {
+        _menu.OpenCentered();
+    }
+
+    public override void Closed()
+    {
+        base.Closed();
+
+        _menu.Close();
+    }
+}
diff --git a/Content.Client/Revolutionary/UI/DeconvertedMenu.xaml b/Content.Client/Revolutionary/UI/DeconvertedMenu.xaml
new file mode 100644 (file)
index 0000000..14b31c1
--- /dev/null
@@ -0,0 +1,10 @@
+<controls:FancyWindow xmlns="https://spacestation14.io"
+                      xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
+                      Title="{Loc 'rev-deconverted-title'}">
+    <BoxContainer Orientation="Vertical" Margin="5">
+        <Label Text="{Loc 'rev-deconverted-text'}"/>
+        <BoxContainer Orientation="Horizontal" Align="Center">
+            <Button Name="ConfirmButton" Text="{Loc 'rev-deconverted-confirm'}"/>
+        </BoxContainer>
+    </BoxContainer>
+</controls:FancyWindow>
diff --git a/Content.Client/Revolutionary/UI/DeconvertedMenu.xaml.cs b/Content.Client/Revolutionary/UI/DeconvertedMenu.xaml.cs
new file mode 100644 (file)
index 0000000..ed32473
--- /dev/null
@@ -0,0 +1,16 @@
+using Content.Client.UserInterface.Controls;
+using Robust.Client.AutoGenerated;
+using Robust.Client.UserInterface.XAML;
+
+namespace Content.Client.Revolutionary.UI;
+
+[GenerateTypedNameReferences]
+public sealed partial class DeconvertedMenu : FancyWindow
+{
+    public DeconvertedMenu()
+    {
+        RobustXamlLoader.Load(this);
+
+        ConfirmButton.OnPressed += _ => Close();
+    }
+}
index d8d3177267f922249f0bac03047093f8247fdba7..869bd128fd12f4fe72ab904a12f2912ee5cca166 100644 (file)
@@ -2,12 +2,14 @@ using System.Linq;
 using Content.Server.Administration.Logs;
 using Content.Server.Antag;
 using Content.Server.Chat.Managers;
+using Content.Server.EUI;
 using Content.Server.Flash;
 using Content.Server.GameTicking.Rules.Components;
 using Content.Server.Mind;
 using Content.Server.NPC.Components;
 using Content.Server.NPC.Systems;
 using Content.Server.Popups;
+using Content.Server.Revolutionary;
 using Content.Server.Revolutionary.Components;
 using Content.Server.Roles;
 using Content.Server.RoundEnd;
@@ -16,6 +18,7 @@ using Content.Shared.Database;
 using Content.Shared.Humanoid;
 using Content.Shared.IdentityManagement;
 using Content.Shared.Mind;
+using Content.Shared.Mind.Components;
 using Content.Shared.Mindshield.Components;
 using Content.Shared.Mobs;
 using Content.Shared.Mobs.Components;
@@ -39,6 +42,7 @@ public sealed class RevolutionaryRuleSystem : GameRuleSystem<RevolutionaryRuleCo
     [Dependency] private readonly IChatManager _chatManager = default!;
     [Dependency] private readonly IGameTiming _timing = default!;
     [Dependency] private readonly AntagSelectionSystem _antagSelection = default!;
+    [Dependency] private readonly EuiManager _euiMan = default!;
     [Dependency] private readonly MindSystem _mind = default!;
     [Dependency] private readonly MobStateSystem _mobState = default!;
     [Dependency] private readonly NpcFactionSystem _npcFaction = default!;
@@ -305,17 +309,28 @@ public sealed class RevolutionaryRuleSystem : GameRuleSystem<RevolutionaryRuleCo
         // If no Head Revs are alive all normal Revs will lose their Rev status and rejoin Nanotrasen
         if (_antagSelection.IsGroupDead(headRevList, false))
         {
-            var rev = AllEntityQuery<RevolutionaryComponent>();
-            while (rev.MoveNext(out var uid, out _))
+            var rev = AllEntityQuery<RevolutionaryComponent, MindContainerComponent>();
+            while (rev.MoveNext(out var uid, out _, out var mc))
             {
-                if (!HasComp<HeadRevolutionaryComponent>(uid))
-                {
-                    _npcFaction.RemoveFaction(uid, RevolutionaryNpcFaction);
-                    _stun.TryParalyze(uid, stunTime, true);
-                    RemCompDeferred<RevolutionaryComponent>(uid);
-                    _popup.PopupEntity(Loc.GetString("rev-break-control", ("name", Identity.Entity(uid, EntityManager))), uid);
-                    _adminLogManager.Add(LogType.Mind, LogImpact.Medium, $"{ToPrettyString(uid)} was deconverted due to all Head Revolutionaries dying.");
-                }
+                if (HasComp<HeadRevolutionaryComponent>(uid))
+                    continue;
+
+                _npcFaction.RemoveFaction(uid, RevolutionaryNpcFaction);
+                _stun.TryParalyze(uid, stunTime, true);
+                RemCompDeferred<RevolutionaryComponent>(uid);
+                _popup.PopupEntity(Loc.GetString("rev-break-control", ("name", Identity.Entity(uid, EntityManager))), uid);
+                _adminLogManager.Add(LogType.Mind, LogImpact.Medium, $"{ToPrettyString(uid)} was deconverted due to all Head Revolutionaries dying.");
+
+                if (!_mind.TryGetMind(uid, out var mindId, out var mind, mc))
+                    continue;
+
+                // remove their antag role
+                _role.MindTryRemoveRole<RevolutionaryRoleComponent>(mindId);
+
+                // make it very obvious to the rev they've been deconverted since
+                // they may not see the popup due to antag and/or new player tunnel vision
+                if (_mind.TryGetSession(mindId, out var session))
+                    _euiMan.OpenEui(new DeconvertedEui(), session);
             }
             return true;
         }
diff --git a/Content.Server/Revolutionary/DeconvertedEui.cs b/Content.Server/Revolutionary/DeconvertedEui.cs
new file mode 100644 (file)
index 0000000..5dfed2f
--- /dev/null
@@ -0,0 +1,8 @@
+using Content.Server.EUI;
+
+namespace Content.Server.Revolutionary;
+
+public sealed class DeconvertedEui : BaseEui
+{
+    // serverside it does nothing since its just to inform the player
+}
index 4ace8f96d2c2861dde6e4b209a000a4f29c1cb4c..5fb1d40b3d3788032b313386dc2828d78388ca25 100644 (file)
@@ -64,3 +64,12 @@ rev-headrev-name = [color=#5e9cff]{$name}[/color] converted {$count} {$count ->
     [one] person
     *[other] people
 }
+
+## Deconverted window
+
+rev-deconverted-title = Deconverted!
+rev-deconverted-text =
+    As the last headrev has died, the revolution is over.
+
+    You are no longer a revolutionary, so be nice.
+rev-deconverted-confirm = Confirm