From d8559ad63cb3758a54bb5c66f76aa00ca15af5a8 Mon Sep 17 00:00:00 2001 From: ursinewalrus Date: Tue, 31 Jul 2018 18:50:38 -0500 Subject: [PATCH 1/3] attaches item to wall where hand is, not at center of body --- .../Source/Items/Components/Holdable/Holdable.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Holdable.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Holdable.cs index f37c5e456..726c94ebc 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Holdable.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Holdable.cs @@ -160,7 +160,18 @@ namespace Barotrauma.Items.Components if (item.body != null) { item.body.ResetDynamics(); - item.SetTransform(picker.SimPosition, 0.0f); + Limb heldHand; + if (picker.Inventory.IsInLimbSlot(item, InvSlotType.LeftHand)) + { + heldHand = picker.AnimController.GetLimb(LimbType.LeftHand); + + } + else + { + heldHand = picker.AnimController.GetLimb(LimbType.RightHand); + } + + item.SetTransform(heldHand.SimPosition, 0.0f); } picker.DeselectItem(item); From bec2cd53232d595c18eefd9e9c9d11ceb94aac08 Mon Sep 17 00:00:00 2001 From: ursinewalrus Date: Tue, 31 Jul 2018 19:46:55 -0500 Subject: [PATCH 2/3] more accurate placement --- .../Source/Items/Components/Holdable/Holdable.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Holdable.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Holdable.cs index 726c94ebc..3159deed5 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Holdable.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Holdable.cs @@ -161,17 +161,24 @@ namespace Barotrauma.Items.Components { item.body.ResetDynamics(); 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; - item.SetTransform(heldHand.SimPosition, 0.0f); + + //DebugConsole.NewMessage("hand rot at " + heldHand.SimPosition + " and simpos at " + arm, Color.Green); + item.SetTransform(heldHand.SimPosition + new Vector2(xDif,yDif), 0.0f); } picker.DeselectItem(item); From 8c8d3e300f3e84ff8c549dba23b282ec9f1213d9 Mon Sep 17 00:00:00 2001 From: Josh Kerxhalli-Kleinfield Date: Wed, 1 Aug 2018 19:07:35 -0500 Subject: [PATCH 3/3] Comment update --- .../Source/Items/Components/Holdable/Holdable.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Holdable.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Holdable.cs index 3159deed5..5aa102b36 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Holdable.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Holdable.cs @@ -173,11 +173,10 @@ namespace Barotrauma.Items.Components 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; - - - //DebugConsole.NewMessage("hand rot at " + heldHand.SimPosition + " and simpos at " + arm, Color.Green); + //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); }