Fix followers leaking (#20643)

This commit is contained in:
metalgearsloth
2023-10-02 01:25:06 +11:00
committed by GitHub
parent 1eb2b905c4
commit e5c85ee662

View File

@@ -33,6 +33,8 @@ public sealed class FollowerSystem : EntitySystem
SubscribeLocalEvent<GetVerbsEvent<AlternativeVerb>>(OnGetAlternativeVerbs);
SubscribeLocalEvent<FollowerComponent, MoveInputEvent>(OnFollowerMove);
SubscribeLocalEvent<FollowerComponent, PullStartedMessage>(OnPullStarted);
SubscribeLocalEvent<FollowerComponent, EntityTerminatingEvent>(OnFollowerTerminating);
SubscribeLocalEvent<FollowerComponent, GotEquippedHandEvent>(OnGotEquippedHand);
SubscribeLocalEvent<FollowedComponent, EntityTerminatingEvent>(OnFollowedTerminating);
SubscribeLocalEvent<BeforeSaveEvent>(OnBeforeSave);
@@ -107,6 +109,11 @@ public sealed class FollowerSystem : EntitySystem
StopFollowingEntity(uid, component.Following, deparent:false);
}
private void OnFollowerTerminating(EntityUid uid, FollowerComponent component, ref EntityTerminatingEvent args)
{
StopFollowingEntity(uid, component.Following, deparent: false);
}
// Since we parent our observer to the followed entity, we need to detach
// before they get deleted so that we don't get recursively deleted too.
private void OnFollowedTerminating(EntityUid uid, FollowedComponent component, ref EntityTerminatingEvent args)
@@ -186,7 +193,7 @@ public sealed class FollowerSystem : EntitySystem
RaiseLocalEvent(uid, uidEv, true);
RaiseLocalEvent(target, targetEv, false);
Dirty(followed);
Dirty(target, followed);
RaiseLocalEvent(uid, uidEv);
RaiseLocalEvent(target, targetEv);