diff --git a/Content.Server/Hands/Systems/HandsSystem.cs b/Content.Server/Hands/Systems/HandsSystem.cs index ad8bf72674..357046be56 100644 --- a/Content.Server/Hands/Systems/HandsSystem.cs +++ b/Content.Server/Hands/Systems/HandsSystem.cs @@ -33,7 +33,6 @@ namespace Content.Server.Hands.Systems [Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly StackSystem _stackSystem = default!; - [Dependency] private readonly VirtualItemSystem _virtualItemSystem = default!; [Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!; [Dependency] private readonly SharedTransformSystem _transformSystem = default!; [Dependency] private readonly PullingSystem _pullingSystem = default!; @@ -54,9 +53,6 @@ namespace Content.Server.Hands.Systems SubscribeLocalEvent(OnDisarmed, before: new[] {typeof(StunSystem), typeof(SharedStaminaSystem)}); - SubscribeLocalEvent(HandlePullStarted); - SubscribeLocalEvent(HandlePullStopped); - SubscribeLocalEvent(HandleBodyPartAdded); SubscribeLocalEvent(HandleBodyPartRemoved); @@ -142,45 +138,6 @@ namespace Content.Server.Hands.Systems RemoveHand(uid, args.Slot); } - #region pulling - - private void HandlePullStarted(EntityUid uid, HandsComponent component, PullStartedMessage args) - { - if (args.PullerUid != uid) - return; - - if (TryComp(args.PullerUid, out var pullerComp) && !pullerComp.NeedsHands) - return; - - if (!_virtualItemSystem.TrySpawnVirtualItemInHand(args.PulledUid, uid)) - { - DebugTools.Assert("Unable to find available hand when starting pulling??"); - } - } - - private void HandlePullStopped(EntityUid uid, HandsComponent component, PullStoppedMessage args) - { - if (args.PullerUid != uid) - return; - - // Try find hand that is doing this pull. - // and clear it. - foreach (var hand in component.Hands.Values) - { - if (hand.HeldEntity == null - || !TryComp(hand.HeldEntity, out VirtualItemComponent? virtualItem) - || virtualItem.BlockingEntity != args.PulledUid) - { - continue; - } - - TryDrop(args.PullerUid, hand, handsComp: component); - break; - } - } - - #endregion - #region interactions private bool HandleThrowItem(ICommonSession? playerSession, EntityCoordinates coordinates, EntityUid entity) diff --git a/Content.Shared/Movement/Pulling/Systems/PullingSystem.cs b/Content.Shared/Movement/Pulling/Systems/PullingSystem.cs index 369225df2d..bc505ee989 100644 --- a/Content.Shared/Movement/Pulling/Systems/PullingSystem.cs +++ b/Content.Shared/Movement/Pulling/Systems/PullingSystem.cs @@ -5,10 +5,12 @@ using Content.Shared.Buckle.Components; using Content.Shared.Cuffs.Components; using Content.Shared.Database; using Content.Shared.Hands; +using Content.Shared.Hands.Components; using Content.Shared.Hands.EntitySystems; using Content.Shared.IdentityManagement; using Content.Shared.Input; using Content.Shared.Interaction; +using Content.Shared.Inventory.VirtualItem; using Content.Shared.Item; using Content.Shared.Mobs; using Content.Shared.Mobs.Systems; @@ -28,6 +30,7 @@ using Robust.Shared.Physics.Events; using Robust.Shared.Physics.Systems; using Robust.Shared.Player; using Robust.Shared.Timing; +using Robust.Shared.Utility; namespace Content.Shared.Movement.Pulling.Systems; @@ -48,6 +51,7 @@ public sealed class PullingSystem : EntitySystem [Dependency] private readonly SharedPhysicsSystem _physics = default!; [Dependency] private readonly HeldSpeedModifierSystem _clothingMoveSpeed = default!; [Dependency] private readonly SharedPopupSystem _popup = default!; + [Dependency] private readonly SharedVirtualItemSystem _virtual = default!; public override void Initialize() { @@ -73,6 +77,9 @@ public sealed class PullingSystem : EntitySystem SubscribeLocalEvent(OnDropHandItems); SubscribeLocalEvent(OnStopPullingAlert); + SubscribeLocalEvent(HandlePullStarted); + SubscribeLocalEvent(HandlePullStopped); + SubscribeLocalEvent(OnBuckled); SubscribeLocalEvent(OnGotBuckled); @@ -81,6 +88,41 @@ public sealed class PullingSystem : EntitySystem .Register(); } + private void HandlePullStarted(EntityUid uid, HandsComponent component, PullStartedMessage args) + { + if (args.PullerUid != uid) + return; + + if (TryComp(args.PullerUid, out PullerComponent? pullerComp) && !pullerComp.NeedsHands) + return; + + if (!_virtual.TrySpawnVirtualItemInHand(args.PulledUid, uid)) + { + DebugTools.Assert("Unable to find available hand when starting pulling??"); + } + } + + private void HandlePullStopped(EntityUid uid, HandsComponent component, PullStoppedMessage args) + { + if (args.PullerUid != uid) + return; + + // Try find hand that is doing this pull. + // and clear it. + foreach (var hand in component.Hands.Values) + { + if (hand.HeldEntity == null + || !TryComp(hand.HeldEntity, out VirtualItemComponent? virtualItem) + || virtualItem.BlockingEntity != args.PulledUid) + { + continue; + } + + _handsSystem.TryDrop(args.PullerUid, hand, handsComp: component); + break; + } + } + private void OnStateChanged(EntityUid uid, PullerComponent component, ref UpdateMobStateEvent args) { if (component.Pulling == null)