diff --git a/Content.Shared/Pulling/Systems/SharedPullingSystem.cs b/Content.Shared/Pulling/Systems/SharedPullingSystem.cs index 6f372bec82..83e7abe9a2 100644 --- a/Content.Shared/Pulling/Systems/SharedPullingSystem.cs +++ b/Content.Shared/Pulling/Systems/SharedPullingSystem.cs @@ -10,6 +10,7 @@ using JetBrains.Annotations; using Robust.Shared.Containers; using Robust.Shared.Input.Binding; using Robust.Shared.Map; +using Robust.Shared.Physics; using Robust.Shared.Players; namespace Content.Shared.Pulling @@ -41,6 +42,7 @@ namespace Content.Shared.Pulling SubscribeLocalEvent(OnPullStarted); SubscribeLocalEvent(OnPullStopped); SubscribeLocalEvent(HandleContainerInsert); + SubscribeLocalEvent(OnJointRemoved); SubscribeLocalEvent(PullableHandlePullStarted); SubscribeLocalEvent(PullableHandlePullStopped); @@ -52,6 +54,28 @@ namespace Content.Shared.Pulling .Register(); } + private void OnJointRemoved(EntityUid uid, SharedPullableComponent component, JointRemovedEvent args) + { + if (component.Puller != args.OtherBody.Owner) + return; + + // Do we have some other join with our Puller? + // or alternatively: + // TODO track the relevant joint. + + if (TryComp(uid, out JointComponent? joints)) + { + foreach (var jt in joints.GetJoints) + { + if (jt.BodyAUid == component.Puller || jt.BodyBUid == component.Puller) + return; + } + } + + // No more joints with puller -> force stop pull. + _pullSm.ForceDisconnectPullable(component); + } + private void AddPullVerbs(EntityUid uid, SharedPullableComponent component, GetVerbsEvent args) { if (!args.CanAccess || !args.CanInteract)