diff --git a/Barotrauma/BarotraumaShared/Content/Items/Tools/tools.xml b/Barotrauma/BarotraumaShared/Content/Items/Tools/tools.xml index 0d6c81251..c59cedf22 100644 --- a/Barotrauma/BarotraumaShared/Content/Items/Tools/tools.xml +++ b/Barotrauma/BarotraumaShared/Content/Items/Tools/tools.xml @@ -218,8 +218,7 @@ @@ -231,12 +230,11 @@ - + - diff --git a/Barotrauma/BarotraumaShared/Source/Characters/Animation/HumanoidAnimController.cs b/Barotrauma/BarotraumaShared/Source/Characters/Animation/HumanoidAnimController.cs index f6962526c..9dbaf2193 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/Animation/HumanoidAnimController.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/Animation/HumanoidAnimController.cs @@ -1011,8 +1011,6 @@ namespace Barotrauma public override void HoldItem(float deltaTime, Item item, Vector2[] handlePos, Vector2 holdPos, Vector2 aimPos, bool aim, float holdAngle) { - Holdable holdable = item.GetComponent(); - if (character.IsUnconscious || character.Stun > 0.0f) aim = false; //calculate the handle positions @@ -1030,7 +1028,6 @@ namespace Barotrauma bool usingController = character.SelectedConstruction != null && character.SelectedConstruction.GetComponent() != null; - float itemAngle; if (Anim != Animation.Climbing && !usingController && character.Stun <= 0.0f && aim && itemPos != Vector2.Zero) { @@ -1042,6 +1039,7 @@ namespace Barotrauma itemAngle = (torso.body.Rotation + holdAngle * Dir); + Holdable holdable = item.GetComponent(); if (holdable.ControlPose) { head.body.SmoothRotate(itemAngle); diff --git a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Holdable.cs b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Holdable.cs index 73d99dedc..4c67bfcdf 100644 --- a/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Holdable.cs +++ b/Barotrauma/BarotraumaShared/Source/Items/Components/Holdable/Holdable.cs @@ -184,8 +184,8 @@ namespace Barotrauma.Items.Components item.SetTransform(rightHand.SimPosition, 0.0f); } - bool alreadySelected = character.HasSelectedItem(item); - if (picker.TrySelectItem(item)) + bool alreadySelected = character.HasEquippedItem(item); + if (picker.TrySelectItem(item) || picker.HasEquippedItem(item)) { item.body.Enabled = true; IsActive = true; @@ -308,7 +308,7 @@ namespace Barotrauma.Items.Components public override void Update(float deltaTime, Camera cam) { if (item.body == null || !item.body.Enabled) return; - if (picker == null || !picker.HasSelectedItem(item)) + if (picker == null || !picker.HasEquippedItem(item)) { IsActive = false; return; @@ -320,7 +320,37 @@ namespace Barotrauma.Items.Components item.Submarine = picker.Submarine; - picker.AnimController.HoldItem(deltaTime, item, handlePos, holdPos, aimPos, picker.IsKeyDown(InputType.Aim), holdAngle); + if (picker.HasSelectedItem(item)) + { + picker.AnimController.HoldItem(deltaTime, item, handlePos, holdPos, aimPos, picker.IsKeyDown(InputType.Aim), holdAngle); + } + else + { + Limb equipLimb = null; + if (picker.Inventory.IsInLimbSlot(item, InvSlotType.Face) || picker.Inventory.IsInLimbSlot(item, InvSlotType.Head)) + { + equipLimb = picker.AnimController.GetLimb(LimbType.Head); + } + else if (picker.Inventory.IsInLimbSlot(item, InvSlotType.Torso)) + { + equipLimb = picker.AnimController.GetLimb(LimbType.Torso); + } + else if (picker.Inventory.IsInLimbSlot(item, InvSlotType.Legs)) + { + equipLimb = picker.AnimController.GetLimb(LimbType.Waist); + } + + if (equipLimb != null) + { + float itemAngle = (equipLimb.Rotation + holdAngle * picker.AnimController.Dir); + + Matrix itemTransfrom = Matrix.CreateRotationZ(equipLimb.Rotation); + Vector2 transformedHandlePos = Vector2.Transform(handlePos[0], itemTransfrom); + + item.body.ResetDynamics(); + item.SetTransform(equipLimb.SimPosition - transformedHandlePos, itemAngle); + } + } } protected void Flip(Item item)