From 9ab5d76ed121f1364a368dbc42accfd1b45d4fc5 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Thu, 2 Aug 2018 12:18:03 +0300 Subject: [PATCH] Fixed attachable items dropping on the ground when deattaching them (but still staying in the inventory of the character detaching them). Closes #559 --- .../Items/Components/Holdable/Holdable.cs | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Holdable.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Holdable.cs index f0a7b89d2..5a8e33867 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Holdable.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Holdable.cs @@ -438,7 +438,7 @@ namespace Barotrauma.Items.Components public void ClientRead(ServerNetObject type, NetBuffer msg, float sendingTime) { - bool isAttached = msg.ReadBoolean(); + bool shouldBeAttached = msg.ReadBoolean(); Vector2 simPosition = new Vector2(msg.ReadFloat(), msg.ReadFloat()); if (!attachable) @@ -447,7 +447,7 @@ namespace Barotrauma.Items.Components return; } - if (isAttached) + if (shouldBeAttached) { Drop(false, null); item.SetTransform(simPosition, 0.0f); @@ -455,16 +455,19 @@ namespace Barotrauma.Items.Components } else { - DropConnectedWires(null); - - if (body != null) + if (attached) { - item.body = body; - item.body.Enabled = true; - } - IsActive = false; + DropConnectedWires(null); - DeattachFromWall(); + if (body != null) + { + item.body = body; + item.body.Enabled = true; + } + IsActive = false; + + DeattachFromWall(); + } } } }