Merge pull request #560 from ursinewalrus/placeItemsWhereHandIs

Place items where hand is
This commit is contained in:
Joonas Rikkonen
2018-08-02 10:44:45 +03:00
committed by GitHub

View File

@@ -160,7 +160,24 @@ namespace Barotrauma.Items.Components
if (item.body != null)
{
item.body.ResetDynamics();
item.SetTransform(picker.SimPosition, 0.0f);
Limb heldHand;
Limb arm;
if (picker.Inventory.IsInLimbSlot(item, InvSlotType.LeftHand))
{
heldHand = picker.AnimController.GetLimb(LimbType.LeftHand);
arm = picker.AnimController.GetLimb(LimbType.LeftArm);
}
else
{
heldHand = picker.AnimController.GetLimb(LimbType.RightHand);
arm = picker.AnimController.GetLimb(LimbType.RightArm);
}
float xDif = (heldHand.SimPosition.X - arm.SimPosition.X) / 2f;
float yDif = (heldHand.SimPosition.Y - arm.SimPosition.Y) / 2.5f;
//hand simPosition is actually in the wrist so need to move the item out from it slightly
item.SetTransform(heldHand.SimPosition + new Vector2(xDif,yDif), 0.0f);
}
picker.DeselectItem(item);