diff --git a/Content.Shared/Cuffs/SharedCuffableSystem.cs b/Content.Shared/Cuffs/SharedCuffableSystem.cs index b9f287f1ce..3bf6066f33 100644 --- a/Content.Shared/Cuffs/SharedCuffableSystem.cs +++ b/Content.Shared/Cuffs/SharedCuffableSystem.cs @@ -58,7 +58,7 @@ namespace Content.Shared.Cuffs { base.Initialize(); - SubscribeLocalEvent(OnHandCountChanged); + SubscribeLocalEvent(OnHandCountChanged); SubscribeLocalEvent(OnUncuffAttempt); SubscribeLocalEvent(OnCuffsRemovedFromContainer); @@ -380,33 +380,24 @@ namespace Content.Shared.Cuffs /// /// Check the current amount of hands the owner has, and if there's less hands than active cuffs we remove some cuffs. /// - private void OnHandCountChanged(HandCountChangedEvent message) + private void OnHandCountChanged(Entity ent, ref HandCountChangedEvent message) { - var owner = message.Sender; - - if (!TryComp(owner, out CuffableComponent? cuffable) || - !cuffable.Initialized) - { - return; - } - var dirty = false; - var handCount = CompOrNull(owner)?.Count ?? 0; + var handCount = CompOrNull(ent.Owner)?.Count ?? 0; - while (cuffable.CuffedHandCount > handCount && cuffable.CuffedHandCount > 0) + while (ent.Comp.CuffedHandCount > handCount && ent.Comp.CuffedHandCount > 0) { dirty = true; - var container = cuffable.Container; - var entity = container.ContainedEntities[^1]; + var handcuffContainer = ent.Comp.Container; + var handcuffEntity = handcuffContainer.ContainedEntities[^1]; - _container.Remove(entity, container); - _transform.SetWorldPosition(entity, _transform.GetWorldPosition(owner)); + _transform.PlaceNextTo(handcuffEntity, ent.Owner); } if (dirty) { - UpdateCuffState(owner, cuffable); + UpdateCuffState(ent.Owner, ent.Comp); } }