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

@@ -4,6 +4,7 @@ using Content.Server.Mind;
using Content.Shared.Mind;
using Content.Shared.Roles;
using Content.Shared.Roles.Jobs;
using Robust.Shared.Player;
namespace Content.Server.Roles.Jobs;
@@ -14,6 +15,7 @@ public sealed class JobSystem : SharedJobSystem
{
[Dependency] private readonly IChatManager _chat = default!;
[Dependency] private readonly MindSystem _mind = default!;
[Dependency] private readonly ISharedPlayerManager _player = default!;
[Dependency] private readonly RoleSystem _roles = default!;
public override void Initialize()
@@ -42,7 +44,7 @@ public sealed class JobSystem : SharedJobSystem
if (args.Silent)
return;
if (!_mind.TryGetSession(mindId, out var session))
if (!_player.TryGetSessionById(component.UserId, out var session))
return;
if (!MindTryGetJob(mindId, out var prototype))

View File

@@ -46,7 +46,7 @@ public sealed class RoleSystem : SharedRoleSystem
public void RoleUpdateMessage(MindComponent mind)
{
if (mind.Session is null)
if (!Player.TryGetSessionById(mind.UserId, out var session))
return;
if (!_proto.TryIndex(mind.RoleType, out var proto))
@@ -55,8 +55,6 @@ public sealed class RoleSystem : SharedRoleSystem
var roleText = Loc.GetString(proto.Name);
var color = proto.Color;
var session = mind.Session;
//TODO add audio? Would need to be optional so it does not play on role changes that already come with their own audio
// _audio.PlayGlobal(Sound, session);