Fixed attachable items dropping on the ground when deattaching them (but still staying in the inventory of the character detaching them). Closes #559

This commit is contained in:
Joonas Rikkonen
2018-08-02 12:18:03 +03:00
parent 1379460ad9
commit 9ab5d76ed1

View File

@@ -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();
}
}
}
}