remove Session from MindComponent (#34753)

* yummy

* fix tests
This commit is contained in:
Milon
2025-04-19 00:23:01 +02:00
committed by GitHub
parent ba6d8f5376
commit 3fc9bcbbbe
25 changed files with 149 additions and 134 deletions

View File

@@ -28,6 +28,7 @@ using Content.Shared.Zombies;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
using Content.Shared.Cuffs.Components;
using Robust.Shared.Player;
namespace Content.Server.GameTicking.Rules;
@@ -36,19 +37,20 @@ namespace Content.Server.GameTicking.Rules;
/// </summary>
public sealed class RevolutionaryRuleSystem : GameRuleSystem<RevolutionaryRuleComponent>
{
[Dependency] private readonly IAdminLogManager _adminLogManager = default!;
[Dependency] private readonly AntagSelectionSystem _antag = default!;
[Dependency] private readonly EmergencyShuttleSystem _emergencyShuttle = default!;
[Dependency] private readonly EuiManager _euiMan = default!;
[Dependency] private readonly IAdminLogManager _adminLogManager = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly ISharedPlayerManager _player = default!;
[Dependency] private readonly MindSystem _mind = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly NpcFactionSystem _npcFaction = default!;
[Dependency] private readonly PopupSystem _popup = default!;
[Dependency] private readonly RoleSystem _role = default!;
[Dependency] private readonly SharedStunSystem _stun = default!;
[Dependency] private readonly RoundEndSystem _roundEnd = default!;
[Dependency] private readonly SharedStunSystem _stun = default!;
[Dependency] private readonly StationSystem _stationSystem = default!;
[Dependency] private readonly IGameTiming _timing = default!;
//Used in OnPostFlash, no reference to the rule component is available
public readonly ProtoId<NpcFactionPrototype> RevolutionaryNpcFaction = "Revolutionary";
@@ -165,8 +167,8 @@ public sealed class RevolutionaryRuleSystem : GameRuleSystem<RevolutionaryRuleCo
_role.MindAddRole(mindId, "MindRoleRevolutionary");
}
if (mind?.Session != null)
_antag.SendBriefing(mind.Session, Loc.GetString("rev-role-greeting"), Color.Red, revComp.RevStartSound);
if (mind is { UserId: not null } && _player.TryGetSessionById(mind.UserId, out var session))
_antag.SendBriefing(session, Loc.GetString("rev-role-greeting"), Color.Red, revComp.RevStartSound);
}
//TODO: Enemies of the revolution
@@ -228,7 +230,7 @@ public sealed class RevolutionaryRuleSystem : GameRuleSystem<RevolutionaryRuleCo
_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 _, mc))
if (!_mind.TryGetMind(uid, out var mindId, out var mind, mc))
continue;
// remove their antag role
@@ -236,7 +238,7 @@ public sealed class RevolutionaryRuleSystem : GameRuleSystem<RevolutionaryRuleCo
// 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))
if (_player.TryGetSessionById(mind.UserId, out var session))
_euiMan.OpenEui(new DeconvertedEui(), session);
}
return true;