Fix ghost following bug (#19035)

This commit is contained in:
Leon Friedrich
2023-08-13 13:21:42 +12:00
committed by GitHub
parent 175660c800
commit 7fd9d4fa4f

View File

@@ -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);
}
/// <summary>