diff --git a/Content.Shared/Follower/FollowerSystem.cs b/Content.Shared/Follower/FollowerSystem.cs index ab194f5bb6..98e4d69ab8 100644 --- a/Content.Shared/Follower/FollowerSystem.cs +++ b/Content.Shared/Follower/FollowerSystem.cs @@ -10,6 +10,7 @@ using Content.Shared.Verbs; using Robust.Shared.Containers; using Robust.Shared.Map; using Robust.Shared.Map.Events; +using Robust.Shared.Network; using Robust.Shared.Utility; using Robust.Shared.Physics; using Robust.Shared.Physics.Systems; @@ -23,6 +24,7 @@ public sealed class FollowerSystem : EntitySystem [Dependency] private readonly SharedContainerSystem _containerSystem = default!; [Dependency] private readonly SharedJointSystem _jointSystem = default!; [Dependency] private readonly SharedPhysicsSystem _physicsSystem = default!; + [Dependency] private readonly INetManager _netMan = default!; public override void Initialize() { @@ -188,15 +190,21 @@ public sealed class FollowerSystem : EntitySystem RaiseLocalEvent(uid, uidEv); RaiseLocalEvent(target, targetEv); - if (!Deleted(uid) && deparent) + if (!deparent || !TryComp(uid, out TransformComponent? xform)) + return; + + _transform.AttachToGridOrMap(uid, xform); + if (xform.MapUid != null) + return; + + if (_netMan.IsClient) { - var xform = Transform(uid); - _transform.AttachToGridOrMap(uid, xform); - if (xform.MapUid == null) - { - QueueDel(uid); - } + _transform.DetachParentToNull(uid, xform); + return; } + + Log.Warning($"A follower has been detached to null-space and will be deleted. Follower: {ToPrettyString(uid)}. Followed: {ToPrettyString(target)}"); + QueueDel(uid); } ///