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

@@ -53,7 +53,7 @@ namespace Content.Server.Ghost
[Dependency] private readonly MindSystem _minds = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly ISharedPlayerManager _player = default!;
[Dependency] private readonly TransformSystem _transformSystem = default!;
[Dependency] private readonly VisibilitySystem _visibilitySystem = default!;
[Dependency] private readonly MetaDataSystem _metaData = default!;
@@ -364,7 +364,7 @@ namespace Content.Server.Ghost
private IEnumerable<GhostWarp> GetPlayerWarps(EntityUid except)
{
foreach (var player in _playerManager.Sessions)
foreach (var player in _player.Sessions)
{
if (player.AttachedEntity is not {Valid: true} attached)
continue;
@@ -484,8 +484,8 @@ namespace Content.Server.Ghost
// However, that should rarely happen.
if (!string.IsNullOrWhiteSpace(mind.Comp.CharacterName))
_metaData.SetEntityName(ghost, mind.Comp.CharacterName);
else if (!string.IsNullOrWhiteSpace(mind.Comp.Session?.Name))
_metaData.SetEntityName(ghost, mind.Comp.Session.Name);
else if (mind.Comp.UserId is { } userId && _player.TryGetSessionById(userId, out var session))
_metaData.SetEntityName(ghost, session.Name);
if (mind.Comp.TimeOfDeath.HasValue)
{
@@ -530,9 +530,9 @@ namespace Content.Server.Ghost
if (mind.PreventGhosting && !forced)
{
if (mind.Session != null) // Logging is suppressed to prevent spam from ghost attempts caused by movement attempts
if (_player.TryGetSessionById(mind.UserId, out var session)) // Logging is suppressed to prevent spam from ghost attempts caused by movement attempts
{
_chatManager.DispatchServerMessage(mind.Session, Loc.GetString("comp-mind-ghosting-prevented"),
_chatManager.DispatchServerMessage(session, Loc.GetString("comp-mind-ghosting-prevented"),
true);
}