2023-05-02 20:10:19 -04:00
|
|
|
using Content.Server.EUI;
|
|
|
|
|
using Content.Shared.Eui;
|
|
|
|
|
using Content.Shared.Ghost;
|
2023-08-30 21:46:11 -07:00
|
|
|
using Content.Shared.Mind;
|
2025-04-19 00:23:01 +02:00
|
|
|
using Robust.Shared.Network;
|
|
|
|
|
using Robust.Shared.Player;
|
2023-05-02 20:10:19 -04:00
|
|
|
|
|
|
|
|
namespace Content.Server.Ghost;
|
|
|
|
|
|
|
|
|
|
public sealed class ReturnToBodyEui : BaseEui
|
|
|
|
|
{
|
2023-08-30 21:46:11 -07:00
|
|
|
private readonly SharedMindSystem _mindSystem;
|
2025-04-19 00:23:01 +02:00
|
|
|
private readonly ISharedPlayerManager _player;
|
|
|
|
|
private readonly NetUserId? _userId;
|
2023-06-18 11:33:19 -07:00
|
|
|
|
2025-04-19 00:23:01 +02:00
|
|
|
public ReturnToBodyEui(MindComponent mind, SharedMindSystem mindSystem, ISharedPlayerManager player)
|
2023-05-02 20:10:19 -04:00
|
|
|
{
|
2023-07-27 21:13:17 +02:00
|
|
|
_mindSystem = mindSystem;
|
2025-04-19 00:23:01 +02:00
|
|
|
_player = player;
|
|
|
|
|
_userId = mind.UserId;
|
2023-05-02 20:10:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void HandleMessage(EuiMessageBase msg)
|
|
|
|
|
{
|
|
|
|
|
base.HandleMessage(msg);
|
|
|
|
|
|
|
|
|
|
if (msg is not ReturnToBodyMessage choice ||
|
|
|
|
|
!choice.Accepted)
|
|
|
|
|
{
|
|
|
|
|
Close();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-19 00:23:01 +02:00
|
|
|
if (_userId is { } userId && _player.TryGetSessionById(userId, out var session))
|
|
|
|
|
_mindSystem.UnVisit(session);
|
2023-08-28 16:53:24 -07:00
|
|
|
|
2023-05-02 20:10:19 -04:00
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
}
|