From ca5e11e859648cef9264b8b50477e39eab928149 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Wed, 10 Apr 2019 13:24:53 +0300 Subject: [PATCH] (476b2ba9b) Don't allow deattaching items when another component of the item is selected (e.g. wiring interface), interrupt picking if the item is removed or moved to an inventory --- .../Source/Items/Components/Holdable/Pickable.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Pickable.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Pickable.cs index dcf0c00a0..69aa69502 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Pickable.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Pickable.cs @@ -122,7 +122,14 @@ namespace Barotrauma.Items.Components pickTimer = 0.0f; while (pickTimer < requiredTime && Screen.Selected != GameMain.SubEditorScreen) { - if (picker.IsKeyDown(InputType.Aim) || !picker.CanInteractWith(item)) + //cancel if the item is currently selected + //attempting to pick does not select the item, so if it is selected at this point, another ItemComponent + //must have been selected and we should not keep deattaching (happens when for example interacting with + //an electrical component while holding both a screwdriver and a wrench). + if (picker.SelectedConstruction == item || + picker.IsKeyDown(InputType.Aim) || + !picker.CanInteractWith(item) || + item.Removed || item.ParentInventory != null) { StopPicking(picker); yield return CoroutineStatus.Success; @@ -135,9 +142,8 @@ namespace Barotrauma.Items.Components pickTimer / requiredTime, Color.Red, Color.Green); #endif - - picker.AnimController.UpdateUseItem(true, item.WorldPosition + new Vector2(0.0f, 100.0f) * ((pickTimer / 10.0f) % 0.1f)); + picker.AnimController.UpdateUseItem(true, item.WorldPosition + new Vector2(0.0f, 100.0f) * ((pickTimer / 10.0f) % 0.1f)); pickTimer += CoroutineManager.DeltaTime; yield return CoroutineStatus.Running;