diff --git a/Content.Server/Commands/Chat/SuicideCommand.cs b/Content.Server/Commands/Chat/SuicideCommand.cs index 5b72a9188c..f8e930cc3e 100644 --- a/Content.Server/Commands/Chat/SuicideCommand.cs +++ b/Content.Server/Commands/Chat/SuicideCommand.cs @@ -69,7 +69,7 @@ namespace Content.Server.Commands.Chat return; var chat = IoCManager.Resolve(); - var owner = player.ContentData()?.Mind?.OwnedMob.Owner; + var owner = player.ContentData()?.Mind?.OwnedComponent.Owner; if (owner == null) { diff --git a/Content.Server/Commands/Mobs/MindInfoCommand.cs b/Content.Server/Commands/Mobs/MindInfoCommand.cs index 4363164d91..06c3d40e45 100644 --- a/Content.Server/Commands/Mobs/MindInfoCommand.cs +++ b/Content.Server/Commands/Mobs/MindInfoCommand.cs @@ -31,7 +31,7 @@ namespace Content.Server.Commands.Mobs var mind = data.ContentData().Mind; var builder = new StringBuilder(); - builder.AppendFormat("player: {0}, mob: {1}\nroles: ", mind.UserId, mind.OwnedMob?.Owner?.Uid); + builder.AppendFormat("player: {0}, mob: {1}\nroles: ", mind.UserId, mind.OwnedComponent?.Owner?.Uid); foreach (var role in mind.AllRoles) { builder.AppendFormat("{0} ", role.Name); diff --git a/Content.Server/GameTicking/GameTicker.cs b/Content.Server/GameTicking/GameTicker.cs index 3d656da95d..f782c5ae06 100644 --- a/Content.Server/GameTicking/GameTicker.cs +++ b/Content.Server/GameTicking/GameTicker.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Diagnostics.CodeAnalysis; @@ -409,7 +409,10 @@ namespace Content.Server.GameTicking public void Respawn(IPlayerSession targetPlayer) { + targetPlayer.AttachedEntity.TryGetComponent(out var ghost); targetPlayer.ContentData()?.WipeMind(); + if (ghost?.Deleted == false) + ghost.Owner.Delete(); if (LobbyEnabled) _playerJoinLobby(targetPlayer); diff --git a/Content.Server/Mobs/Mind.cs b/Content.Server/Mobs/Mind.cs index 1c157fee65..4cdcdd5128 100644 --- a/Content.Server/Mobs/Mind.cs +++ b/Content.Server/Mobs/Mind.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using Content.Server.GameObjects.Components.Mobs; @@ -62,14 +62,14 @@ namespace Content.Server.Mobs /// Can be null. /// [ViewVariables] - public MindComponent OwnedMob { get; private set; } + public MindComponent OwnedComponent { get; private set; } /// /// The entity currently owned by this mind. /// Can be null. /// [ViewVariables] - public IEntity OwnedEntity => OwnedMob?.Owner; + public IEntity OwnedEntity => OwnedComponent?.Owner; /// /// An enumerable over all the roles this mind has. @@ -121,7 +121,7 @@ namespace Content.Server.Mobs role.Greet(); var message = new RoleAddedMessage(role); - OwnedEntity?.SendMessage(OwnedMob, message); + OwnedEntity?.SendMessage(OwnedComponent, message); return role; } @@ -143,7 +143,7 @@ namespace Content.Server.Mobs _roles.Remove(role); var message = new RoleRemovedMessage(role); - OwnedEntity?.SendMessage(OwnedMob, message); + OwnedEntity?.SendMessage(OwnedComponent, message); } public bool HasRole() where T : Role @@ -220,12 +220,13 @@ namespace Content.Server.Mobs } } - OwnedMob?.InternalEjectMind(); - OwnedMob = component; - OwnedMob?.InternalAssignMind(this); + OwnedComponent?.InternalEjectMind(); + + OwnedComponent = component; + OwnedComponent?.InternalAssignMind(this); // Player is CURRENTLY connected. - if (Session != null && OwnedMob != null && !alreadyAttached) + if (Session != null && !alreadyAttached) { Session.AttachToEntity(entity); } @@ -233,6 +234,11 @@ namespace Content.Server.Mobs VisitingEntity = null; } + public void RemoveOwningPlayer() + { + UserId = null; + } + public void ChangeOwningPlayer(NetUserId? newOwner) { var playerMgr = IoCManager.Resolve(); diff --git a/Content.Server/Players/PlayerData.cs b/Content.Server/Players/PlayerData.cs index e2d24582a2..5161ced028 100644 --- a/Content.Server/Players/PlayerData.cs +++ b/Content.Server/Players/PlayerData.cs @@ -1,4 +1,4 @@ -#nullable enable +#nullable enable using Content.Server.Mobs; using Robust.Server.Player; using Robust.Shared.Network; @@ -33,7 +33,8 @@ namespace Content.Server.Players public void WipeMind() { - Mind?.ChangeOwningPlayer(null); + Mind?.TransferTo(null); + Mind?.RemoveOwningPlayer(); Mind = null; }