better deconversion (#23315)

* 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>
This commit is contained in:
deltanedas
2024-01-14 03:20:35 +00:00
committed by GitHub
parent 6a7f1b2f1f
commit a558b112a1
6 changed files with 93 additions and 10 deletions

View File

@@ -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();
}
}

View File

@@ -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>

View File

@@ -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();
}
}

View 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 _))
{
if (!HasComp<HeadRevolutionaryComponent>(uid))
var rev = AllEntityQuery<RevolutionaryComponent, MindContainerComponent>();
while (rev.MoveNext(out var uid, out _, out var mc))
{
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;
}

View File

@@ -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
}

View 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