No unbuckling while cuffed (#17719)

This commit is contained in:
Nemanja
2023-06-28 23:19:56 -04:00
committed by GitHub
parent e2823d8006
commit 5212fc5478
4 changed files with 35 additions and 14 deletions

View File

@@ -3,6 +3,7 @@ using Content.Shared.ActionBlocker;
using Content.Shared.Administration.Components;
using Content.Shared.Administration.Logs;
using Content.Shared.Alert;
using Content.Shared.Buckle.Components;
using Content.Shared.Cuffs.Components;
using Content.Shared.Database;
using Content.Shared.DoAfter;
@@ -66,6 +67,7 @@ namespace Content.Shared.Cuffs
SubscribeLocalEvent<CuffableComponent, IsEquippingAttemptEvent>(OnEquipAttempt);
SubscribeLocalEvent<CuffableComponent, IsUnequippingAttemptEvent>(OnUnequipAttempt);
SubscribeLocalEvent<CuffableComponent, BeingPulledAttemptEvent>(OnBeingPulledAttempt);
SubscribeLocalEvent<CuffableComponent, BuckleAttemptEvent>(OnBuckleAttemptEvent);
SubscribeLocalEvent<CuffableComponent, GetVerbsEvent<Verb>>(AddUncuffVerb);
SubscribeLocalEvent<CuffableComponent, UnCuffDoAfterEvent>(OnCuffableDoAfter);
SubscribeLocalEvent<CuffableComponent, PullStartedMessage>(OnPull);
@@ -79,7 +81,6 @@ namespace Content.Shared.Cuffs
SubscribeLocalEvent<HandcuffComponent, AfterInteractEvent>(OnCuffAfterInteract);
SubscribeLocalEvent<HandcuffComponent, MeleeHitEvent>(OnCuffMeleeHit);
SubscribeLocalEvent<HandcuffComponent, AddCuffDoAfterEvent>(OnAddCuffDoAfter);
}
private void OnUncuffAttempt(ref UncuffAttemptEvent args)
@@ -178,6 +179,23 @@ namespace Content.Shared.Cuffs
args.Cancel();
}
private void OnBuckleAttemptEvent(EntityUid uid, CuffableComponent component, ref BuckleAttemptEvent args)
{
// if someone else is doing it, let it pass.
if (args.UserEntity != uid)
return;
if (!TryComp<HandsComponent>(uid, out var hands) || component.CuffedHandCount != hands.Count)
return;
args.Cancelled = true;
var message = args.Buckling
? Loc.GetString("handcuff-component-cuff-interrupt-buckled-message")
: Loc.GetString("handcuff-component-cuff-interrupt-unbuckled-message");
if (_net.IsServer)
_popup.PopupEntity(message, uid, args.UserEntity);
}
private void OnPull(EntityUid uid, CuffableComponent component, PullMessage args)
{
if (!component.CanStillInteract)