Partial buckling refactor (#29031)
* partial buckling refactor * git mv test * change test namespace * git mv test * Update test namespace * Add pulling test * Network BuckleTime * Add two more tests * smelly
This commit is contained in:
@@ -71,6 +71,7 @@ namespace Content.Shared.Cuffs
|
||||
SubscribeLocalEvent<CuffableComponent, IsUnequippingAttemptEvent>(OnUnequipAttempt);
|
||||
SubscribeLocalEvent<CuffableComponent, BeingPulledAttemptEvent>(OnBeingPulledAttempt);
|
||||
SubscribeLocalEvent<CuffableComponent, BuckleAttemptEvent>(OnBuckleAttemptEvent);
|
||||
SubscribeLocalEvent<CuffableComponent, UnbuckleAttemptEvent>(OnUnbuckleAttemptEvent);
|
||||
SubscribeLocalEvent<CuffableComponent, GetVerbsEvent<Verb>>(AddUncuffVerb);
|
||||
SubscribeLocalEvent<CuffableComponent, UnCuffDoAfterEvent>(OnCuffableDoAfter);
|
||||
SubscribeLocalEvent<CuffableComponent, PullStartedMessage>(OnPull);
|
||||
@@ -195,21 +196,33 @@ namespace Content.Shared.Cuffs
|
||||
args.Cancel();
|
||||
}
|
||||
|
||||
private void OnBuckleAttemptEvent(EntityUid uid, CuffableComponent component, ref BuckleAttemptEvent args)
|
||||
private void OnBuckleAttempt(Entity<CuffableComponent> ent, EntityUid? user, ref bool cancelled, bool buckling, bool popup)
|
||||
{
|
||||
// if someone else is doing it, let it pass.
|
||||
if (args.UserEntity != uid)
|
||||
if (cancelled || user != ent.Owner)
|
||||
return;
|
||||
|
||||
if (!TryComp<HandsComponent>(uid, out var hands) || component.CuffedHandCount != hands.Count)
|
||||
if (!TryComp<HandsComponent>(ent, out var hands) || ent.Comp.CuffedHandCount != hands.Count)
|
||||
return;
|
||||
|
||||
args.Cancelled = true;
|
||||
var message = args.Buckling
|
||||
cancelled = true;
|
||||
if (!popup)
|
||||
return;
|
||||
|
||||
var message = buckling
|
||||
? Loc.GetString("handcuff-component-cuff-interrupt-buckled-message")
|
||||
: Loc.GetString("handcuff-component-cuff-interrupt-unbuckled-message");
|
||||
|
||||
_popup.PopupClient(message, uid, args.UserEntity);
|
||||
_popup.PopupClient(message, ent, user);
|
||||
}
|
||||
|
||||
private void OnBuckleAttemptEvent(Entity<CuffableComponent> ent, ref BuckleAttemptEvent args)
|
||||
{
|
||||
OnBuckleAttempt(ent, args.User, ref args.Cancelled, true, args.Popup);
|
||||
}
|
||||
|
||||
private void OnUnbuckleAttemptEvent(Entity<CuffableComponent> ent, ref UnbuckleAttemptEvent args)
|
||||
{
|
||||
OnBuckleAttempt(ent, args.User, ref args.Cancelled, false, args.Popup);
|
||||
}
|
||||
|
||||
private void OnPull(EntityUid uid, CuffableComponent component, PullMessage args)
|
||||
|
||||
Reference in New Issue
Block a user