Predict pulling hands blocking (#37504)
Think I forgor to add this one when I split the 1 morbillion PRs out.
This commit is contained in:
@@ -33,7 +33,6 @@ namespace Content.Server.Hands.Systems
|
|||||||
[Dependency] private readonly IGameTiming _timing = default!;
|
[Dependency] private readonly IGameTiming _timing = default!;
|
||||||
[Dependency] private readonly IRobustRandom _random = default!;
|
[Dependency] private readonly IRobustRandom _random = default!;
|
||||||
[Dependency] private readonly StackSystem _stackSystem = default!;
|
[Dependency] private readonly StackSystem _stackSystem = default!;
|
||||||
[Dependency] private readonly VirtualItemSystem _virtualItemSystem = default!;
|
|
||||||
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
|
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
|
||||||
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
|
[Dependency] private readonly SharedTransformSystem _transformSystem = default!;
|
||||||
[Dependency] private readonly PullingSystem _pullingSystem = default!;
|
[Dependency] private readonly PullingSystem _pullingSystem = default!;
|
||||||
@@ -54,9 +53,6 @@ namespace Content.Server.Hands.Systems
|
|||||||
|
|
||||||
SubscribeLocalEvent<HandsComponent, DisarmedEvent>(OnDisarmed, before: new[] {typeof(StunSystem), typeof(SharedStaminaSystem)});
|
SubscribeLocalEvent<HandsComponent, DisarmedEvent>(OnDisarmed, before: new[] {typeof(StunSystem), typeof(SharedStaminaSystem)});
|
||||||
|
|
||||||
SubscribeLocalEvent<HandsComponent, PullStartedMessage>(HandlePullStarted);
|
|
||||||
SubscribeLocalEvent<HandsComponent, PullStoppedMessage>(HandlePullStopped);
|
|
||||||
|
|
||||||
SubscribeLocalEvent<HandsComponent, BodyPartAddedEvent>(HandleBodyPartAdded);
|
SubscribeLocalEvent<HandsComponent, BodyPartAddedEvent>(HandleBodyPartAdded);
|
||||||
SubscribeLocalEvent<HandsComponent, BodyPartRemovedEvent>(HandleBodyPartRemoved);
|
SubscribeLocalEvent<HandsComponent, BodyPartRemovedEvent>(HandleBodyPartRemoved);
|
||||||
|
|
||||||
@@ -142,45 +138,6 @@ namespace Content.Server.Hands.Systems
|
|||||||
RemoveHand(uid, args.Slot);
|
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
|
#region interactions
|
||||||
|
|
||||||
private bool HandleThrowItem(ICommonSession? playerSession, EntityCoordinates coordinates, EntityUid entity)
|
private bool HandleThrowItem(ICommonSession? playerSession, EntityCoordinates coordinates, EntityUid entity)
|
||||||
|
|||||||
@@ -5,10 +5,12 @@ using Content.Shared.Buckle.Components;
|
|||||||
using Content.Shared.Cuffs.Components;
|
using Content.Shared.Cuffs.Components;
|
||||||
using Content.Shared.Database;
|
using Content.Shared.Database;
|
||||||
using Content.Shared.Hands;
|
using Content.Shared.Hands;
|
||||||
|
using Content.Shared.Hands.Components;
|
||||||
using Content.Shared.Hands.EntitySystems;
|
using Content.Shared.Hands.EntitySystems;
|
||||||
using Content.Shared.IdentityManagement;
|
using Content.Shared.IdentityManagement;
|
||||||
using Content.Shared.Input;
|
using Content.Shared.Input;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
|
using Content.Shared.Inventory.VirtualItem;
|
||||||
using Content.Shared.Item;
|
using Content.Shared.Item;
|
||||||
using Content.Shared.Mobs;
|
using Content.Shared.Mobs;
|
||||||
using Content.Shared.Mobs.Systems;
|
using Content.Shared.Mobs.Systems;
|
||||||
@@ -28,6 +30,7 @@ using Robust.Shared.Physics.Events;
|
|||||||
using Robust.Shared.Physics.Systems;
|
using Robust.Shared.Physics.Systems;
|
||||||
using Robust.Shared.Player;
|
using Robust.Shared.Player;
|
||||||
using Robust.Shared.Timing;
|
using Robust.Shared.Timing;
|
||||||
|
using Robust.Shared.Utility;
|
||||||
|
|
||||||
namespace Content.Shared.Movement.Pulling.Systems;
|
namespace Content.Shared.Movement.Pulling.Systems;
|
||||||
|
|
||||||
@@ -48,6 +51,7 @@ public sealed class PullingSystem : EntitySystem
|
|||||||
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
|
||||||
[Dependency] private readonly HeldSpeedModifierSystem _clothingMoveSpeed = default!;
|
[Dependency] private readonly HeldSpeedModifierSystem _clothingMoveSpeed = default!;
|
||||||
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
[Dependency] private readonly SharedPopupSystem _popup = default!;
|
||||||
|
[Dependency] private readonly SharedVirtualItemSystem _virtual = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -73,6 +77,9 @@ public sealed class PullingSystem : EntitySystem
|
|||||||
SubscribeLocalEvent<PullerComponent, DropHandItemsEvent>(OnDropHandItems);
|
SubscribeLocalEvent<PullerComponent, DropHandItemsEvent>(OnDropHandItems);
|
||||||
SubscribeLocalEvent<PullerComponent, StopPullingAlertEvent>(OnStopPullingAlert);
|
SubscribeLocalEvent<PullerComponent, StopPullingAlertEvent>(OnStopPullingAlert);
|
||||||
|
|
||||||
|
SubscribeLocalEvent<HandsComponent, PullStartedMessage>(HandlePullStarted);
|
||||||
|
SubscribeLocalEvent<HandsComponent, PullStoppedMessage>(HandlePullStopped);
|
||||||
|
|
||||||
SubscribeLocalEvent<PullableComponent, StrappedEvent>(OnBuckled);
|
SubscribeLocalEvent<PullableComponent, StrappedEvent>(OnBuckled);
|
||||||
SubscribeLocalEvent<PullableComponent, BuckledEvent>(OnGotBuckled);
|
SubscribeLocalEvent<PullableComponent, BuckledEvent>(OnGotBuckled);
|
||||||
|
|
||||||
@@ -81,6 +88,41 @@ public sealed class PullingSystem : EntitySystem
|
|||||||
.Register<PullingSystem>();
|
.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)
|
private void OnStateChanged(EntityUid uid, PullerComponent component, ref UpdateMobStateEvent args)
|
||||||
{
|
{
|
||||||
if (component.Pulling == null)
|
if (component.Pulling == null)
|
||||||
|
|||||||
Reference in New Issue
Block a user