From b73d188e67f7591a6b5985c836dad2370fd252e9 Mon Sep 17 00:00:00 2001 From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Sat, 22 Oct 2022 18:54:28 +1300 Subject: [PATCH] Fix misc cuffing issues (#12127) --- Content.Client/Hands/Systems/HandsSystem.cs | 5 ++-- .../Systems/Hands/HandsUIController.cs | 23 ++++++++++++++++--- .../Cuffs/Components/CuffableComponent.cs | 2 +- Content.Server/DoAfter/DoAfterEventArgs.cs | 4 +++- 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/Content.Client/Hands/Systems/HandsSystem.cs b/Content.Client/Hands/Systems/HandsSystem.cs index 4d1dfeb732..174f932202 100644 --- a/Content.Client/Hands/Systems/HandsSystem.cs +++ b/Content.Client/Hands/Systems/HandsSystem.cs @@ -285,6 +285,8 @@ namespace Content.Client.Hands.Systems if (!Resolve(uid, ref handComp, ref sprite, false)) return; + OnPlayerItemAdded?.Invoke(hand.Name, held); + if (!handComp.ShowInHands) return; @@ -361,8 +363,7 @@ namespace Content.Client.Hands.Systems private void HandlePlayerAttached(EntityUid uid, HandsComponent component, PlayerAttachedEvent args) { - if (_playerManager.LocalPlayer?.ControlledEntity == uid) - OnPlayerHandsAdded?.Invoke(component); + OnPlayerHandsAdded?.Invoke(component); } private void HandlePlayerDetached(EntityUid uid, HandsComponent component, PlayerDetachedEvent args) diff --git a/Content.Client/UserInterface/Systems/Hands/HandsUIController.cs b/Content.Client/UserInterface/Systems/Hands/HandsUIController.cs index 7633c28a17..9ee4bc4b18 100644 --- a/Content.Client/UserInterface/Systems/Hands/HandsUIController.cs +++ b/Content.Client/UserInterface/Systems/Hands/HandsUIController.cs @@ -108,7 +108,17 @@ public sealed class HandsUIController : UIController, IOnStateEntered(hand.HeldEntity); + + if (_entities.TryGetComponent(hand.HeldEntity, out HandVirtualItemComponent? virt)) + { + handButton.SpriteView.Sprite = _entities.GetComponentOrNull(virt.BlockingEntity); + handButton.Blocked = true; + } + else + { + handButton.SpriteView.Sprite = _entities.GetComponentOrNull(hand.HeldEntity); + handButton.Blocked = false; + } } var activeHand = handsComp.ActiveHand; @@ -149,9 +159,16 @@ public sealed class HandsUIController : UIController, IOnStateEntered(virt.BlockingEntity); + hand.Blocked = true; + } + else + { + hand.SpriteView.Sprite = _entities.GetComponentOrNull(entity); + hand.Blocked = false; } if (_playerHandsComponent?.ActiveHand?.Name == name) diff --git a/Content.Server/Cuffs/Components/CuffableComponent.cs b/Content.Server/Cuffs/Components/CuffableComponent.cs index cfa2ebf2a7..9fdbdda562 100644 --- a/Content.Server/Cuffs/Components/CuffableComponent.cs +++ b/Content.Server/Cuffs/Components/CuffableComponent.cs @@ -235,7 +235,7 @@ namespace Content.Server.Cuffs.Components } var uncuffTime = isOwner ? cuff.BreakoutTime : cuff.UncuffTime; - var doAfterEventArgs = new DoAfterEventArgs(user, uncuffTime) + var doAfterEventArgs = new DoAfterEventArgs(user, uncuffTime, target: Owner) { BreakOnUserMove = true, BreakOnTargetMove = true, diff --git a/Content.Server/DoAfter/DoAfterEventArgs.cs b/Content.Server/DoAfter/DoAfterEventArgs.cs index 2d527ea3ab..ad41407af3 100644 --- a/Content.Server/DoAfter/DoAfterEventArgs.cs +++ b/Content.Server/DoAfter/DoAfterEventArgs.cs @@ -1,5 +1,6 @@ -using System.Threading; +using System.Threading; using Content.Shared.FixedPoint; +using Robust.Shared.Utility; namespace Content.Server.DoAfter { @@ -125,6 +126,7 @@ namespace Content.Server.DoAfter if (Target == null) { + DebugTools.Assert(!BreakOnTargetMove); BreakOnTargetMove = false; } }