[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!;
SubscribeLocalEvent<HandsComponent, DisarmedEvent>(OnDisarmed, before: new[] {typeof(StunSystem), typeof(SharedStaminaSystem)});
- SubscribeLocalEvent<HandsComponent, PullStartedMessage>(HandlePullStarted);
- SubscribeLocalEvent<HandsComponent, PullStoppedMessage>(HandlePullStopped);
-
SubscribeLocalEvent<HandsComponent, BodyPartAddedEvent>(HandleBodyPartAdded);
SubscribeLocalEvent<HandsComponent, BodyPartRemovedEvent>(HandleBodyPartRemoved);
RemoveHand(uid, args.Slot);
}
- #region pulling
-
- private void HandlePullStarted(EntityUid uid, HandsComponent component, PullStartedMessage args)
- {
- if (args.PullerUid != uid)
- return;
-
- if (TryComp<PullerComponent>(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)
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;
using Robust.Shared.Physics.Systems;
using Robust.Shared.Player;
using Robust.Shared.Timing;
+using Robust.Shared.Utility;
namespace Content.Shared.Movement.Pulling.Systems;
[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()
{
SubscribeLocalEvent<PullerComponent, DropHandItemsEvent>(OnDropHandItems);
SubscribeLocalEvent<PullerComponent, StopPullingAlertEvent>(OnStopPullingAlert);
+ SubscribeLocalEvent<HandsComponent, PullStartedMessage>(HandlePullStarted);
+ SubscribeLocalEvent<HandsComponent, PullStoppedMessage>(HandlePullStopped);
+
SubscribeLocalEvent<PullableComponent, StrappedEvent>(OnBuckled);
SubscribeLocalEvent<PullableComponent, BuckledEvent>(OnGotBuckled);
.Register<PullingSystem>();
}
+ 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)