Can't break other people's drags on cuffed people (#8868)

* works on my machine

* speedrun
This commit is contained in:
Rane
2022-06-15 21:10:03 -04:00
committed by GitHub
parent d5630e683d
commit e5bad81ac4
3 changed files with 31 additions and 1 deletions

View File

@@ -7,6 +7,7 @@ using Content.Shared.Item;
using Content.Shared.Movement;
using Content.Shared.Physics.Pull;
using Content.Shared.Pulling.Components;
using Content.Shared.Pulling.Events;
namespace Content.Shared.Cuffs
{
@@ -25,10 +26,20 @@ namespace Content.Shared.Cuffs
SubscribeLocalEvent<SharedCuffableComponent, IsUnequippingAttemptEvent>(OnUnequipAttempt);
SubscribeLocalEvent<SharedCuffableComponent, DropAttemptEvent>(OnDropAttempt);
SubscribeLocalEvent<SharedCuffableComponent, PickupAttemptEvent>(OnPickupAttempt);
SubscribeLocalEvent<SharedCuffableComponent, BeingPulledAttemptEvent>(OnBeingPulledAttempt);
SubscribeLocalEvent<SharedCuffableComponent, PullStartedMessage>(OnPull);
SubscribeLocalEvent<SharedCuffableComponent, PullStoppedMessage>(OnPull);
}
private void OnBeingPulledAttempt(EntityUid uid, SharedCuffableComponent component, BeingPulledAttemptEvent args)
{
if (!TryComp<SharedPullableComponent>(uid, out var pullable))
return;
if (pullable.Puller != null && !component.CanStillInteract) // If we are being pulled already and cuffed, we can't get pulled again.
args.Cancel();
}
private void OnPull(EntityUid uid, SharedCuffableComponent component, PullMessage args)
{
if (!component.CanStillInteract)

View File

@@ -0,0 +1,17 @@
namespace Content.Shared.Pulling.Events
{
/// <summary>
/// Directed event raised on the pulled to see if it can be pulled.
/// </summary>
public sealed class BeingPulledAttemptEvent : CancellableEntityEventArgs
{
public BeingPulledAttemptEvent(EntityUid puller, EntityUid pulled)
{
Puller = puller;
Pulled = pulled;
}
public EntityUid Puller { get; }
public EntityUid Pulled { get; }
}
}

View File

@@ -55,9 +55,11 @@ namespace Content.Shared.Pulling
}
}
var getPulled = new BeingPulledAttemptEvent(puller, pulled);
RaiseLocalEvent(pulled, getPulled);
var startPull = new StartPullAttemptEvent(puller, pulled);
RaiseLocalEvent(puller, startPull);
return !startPull.Cancelled;
return (!startPull.Cancelled && !getPulled.Cancelled);
}
public bool TogglePull(EntityUid puller, SharedPullableComponent pullable)