Can't break other people's drags on cuffed people (#8868)
* works on my machine * speedrun
This commit is contained in:
@@ -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)
|
||||
|
||||
17
Content.Shared/Pulling/Events/BeingPulledAttemptEvent.cs
Normal file
17
Content.Shared/Pulling/Events/BeingPulledAttemptEvent.cs
Normal 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; }
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user