diff --git a/Content.Shared/GameObjects/EntitySystems/SharedPullingSystem.cs b/Content.Shared/GameObjects/EntitySystems/SharedPullingSystem.cs index f7212935ce..00b1180aed 100644 --- a/Content.Shared/GameObjects/EntitySystems/SharedPullingSystem.cs +++ b/Content.Shared/GameObjects/EntitySystems/SharedPullingSystem.cs @@ -1,14 +1,16 @@ -#nullable enable +#nullable enable using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using Content.Shared.GameObjects.Components.Pulling; using Content.Shared.Input; using Content.Shared.Physics.Pull; using JetBrains.Annotations; +using Robust.Shared.Containers; using Robust.Shared.GameObjects; using Robust.Shared.Input.Binding; using Robust.Shared.Map; using Robust.Shared.Physics; +using Robust.Shared.Physics.Dynamics.Joints; using Robust.Shared.Players; namespace Content.Shared.GameObjects.EntitySystems @@ -29,6 +31,7 @@ namespace Content.Shared.GameObjects.EntitySystems SubscribeLocalEvent(OnPullStarted); SubscribeLocalEvent(OnPullStopped); SubscribeLocalEvent(PullerMoved); + SubscribeLocalEvent(HandleContainerInsert); CommandBinds.Builder .Bind(ContentKeyFunctions.MovePulledObject, new PointerInputCmdHandler(HandleMovePulledObject)) @@ -67,6 +70,27 @@ namespace Content.Shared.GameObjects.EntitySystems physics.WakeBody(); } + // TODO: When Joint networking is less shitcodey fix this to use a dedicated joints message. + private void HandleContainerInsert(EntInsertedIntoContainerMessage message) + { + if (message.Entity.TryGetComponent(out SharedPullableComponent? pullable)) + { + pullable.TryStopPull(); + } + + if (message.Entity.TryGetComponent(out SharedPullerComponent? puller)) + { + if (puller.Pulling == null) return; + + if (!puller.Pulling.TryGetComponent(out SharedPullableComponent? pulling)) + { + return; + } + + pulling.TryStopPull(); + } + } + private bool HandleMovePulledObject(ICommonSession? session, EntityCoordinates coords, EntityUid uid) { var player = session?.AttachedEntity;