From fcf4b403d6b7a8a9a72c072d5c2965c64ef6c01e Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Sat, 13 Mar 2021 14:24:06 +1100 Subject: [PATCH] Break pulling on container insertion (#3602) * Break pulling on container insertion * Paul's review Co-authored-by: Metal Gear Sloth --- .../EntitySystems/SharedPullingSystem.cs | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) 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;