Unstable 1.1.14.0
This commit is contained in:
@@ -286,17 +286,32 @@ namespace Barotrauma
|
||||
|
||||
public void UpdateUseItem(bool allowMovement, Vector2 handWorldPos)
|
||||
{
|
||||
useItemTimer = 0.5f;
|
||||
useItemTimer = 0.05f;
|
||||
StartUsingItem();
|
||||
|
||||
if (!allowMovement)
|
||||
{
|
||||
TargetMovement = Vector2.Zero;
|
||||
TargetDir = handWorldPos.X > character.WorldPosition.X ? Direction.Right : Direction.Left;
|
||||
float sqrDist = Vector2.DistanceSquared(character.WorldPosition, handWorldPos);
|
||||
if (sqrDist > MathUtils.Pow(ConvertUnits.ToDisplayUnits(upperArmLength + forearmLength), 2))
|
||||
if (InWater)
|
||||
{
|
||||
TargetMovement = Vector2.Normalize(handWorldPos - character.WorldPosition) * GetCurrentSpeed(false) * Math.Max(character.SpeedMultiplier, 1);
|
||||
float sqrDist = Vector2.DistanceSquared(character.WorldPosition, handWorldPos);
|
||||
if (sqrDist > MathUtils.Pow(ConvertUnits.ToDisplayUnits(upperArmLength + forearmLength), 2))
|
||||
{
|
||||
TargetMovement = GetTargetMovement(Vector2.Normalize(handWorldPos - character.WorldPosition));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
float distX = Math.Abs(handWorldPos.X - character.WorldPosition.X);
|
||||
if (distX > ConvertUnits.ToDisplayUnits(upperArmLength + forearmLength))
|
||||
{
|
||||
TargetMovement = GetTargetMovement(Vector2.UnitX * Math.Sign(handWorldPos.X - character.WorldPosition.X));
|
||||
}
|
||||
}
|
||||
Vector2 GetTargetMovement(Vector2 dir)
|
||||
{
|
||||
return dir * GetCurrentSpeed(false) * Math.Max(character.SpeedMultiplier, 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,6 +323,15 @@ namespace Barotrauma
|
||||
handSimPos -= character.Submarine.SimPosition;
|
||||
}
|
||||
|
||||
Vector2 refPos = rightShoulder?.WorldAnchorA ?? leftShoulder?.WorldAnchorA ?? MainLimb.SimPosition;
|
||||
Vector2 diff = handSimPos - refPos;
|
||||
float dist = diff.Length();
|
||||
float maxDist = ArmLength * 0.9f;
|
||||
if (dist > maxDist)
|
||||
{
|
||||
handSimPos = refPos + diff / dist * maxDist;
|
||||
}
|
||||
|
||||
var leftHand = GetLimb(LimbType.LeftHand);
|
||||
if (leftHand != null)
|
||||
{
|
||||
@@ -323,6 +347,16 @@ namespace Barotrauma
|
||||
rightHand.PullJointEnabled = true;
|
||||
rightHand.PullJointWorldAnchorB = handSimPos;
|
||||
}
|
||||
|
||||
//make the character crouch if using an item some distance below them (= on the floor)
|
||||
if (!inWater &&
|
||||
character.WorldPosition.Y - handWorldPos.Y > ConvertUnits.ToDisplayUnits(CurrentGroundedParams.TorsoPosition) / 4 &&
|
||||
this is HumanoidAnimController humanoidAnimController)
|
||||
{
|
||||
humanoidAnimController.Crouching = true;
|
||||
humanoidAnimController.ForceSelectAnimationType = AnimationType.Crouch;
|
||||
character.SetInput(InputType.Crouch, hit: false, held: true);
|
||||
}
|
||||
}
|
||||
|
||||
public void Grab(Vector2 rightHandPos, Vector2 leftHandPos)
|
||||
@@ -352,13 +386,8 @@ namespace Barotrauma
|
||||
|
||||
//calculate the handle positions
|
||||
Matrix itemTransfrom = Matrix.CreateRotationZ(item.body.Rotation);
|
||||
float horizontalOffset = ConvertUnits.ToSimUnits((item.Sprite.size.X / 2 - item.Sprite.Origin.X) * item.Scale);
|
||||
|
||||
//handlePos[0] = ConvertUnits.ToSimUnits(new Vector2(-45,25) * 0.5f);
|
||||
//handlePos[1] = ConvertUnits.ToSimUnits(new Vector2(-65,30) * 0.5f);
|
||||
|
||||
transformedHandlePos[0] = Vector2.Transform(new Vector2(handlePos[0].X + horizontalOffset, handlePos[0].Y), itemTransfrom);
|
||||
transformedHandlePos[1] = Vector2.Transform(new Vector2(handlePos[1].X + horizontalOffset, handlePos[1].Y), itemTransfrom);
|
||||
transformedHandlePos[0] = Vector2.Transform(handlePos[0], itemTransfrom);
|
||||
transformedHandlePos[1] = Vector2.Transform(handlePos[1], itemTransfrom);
|
||||
|
||||
Limb torso = GetLimb(LimbType.Torso) ?? MainLimb;
|
||||
Limb leftHand = GetLimb(LimbType.LeftHand);
|
||||
@@ -385,7 +414,9 @@ namespace Barotrauma
|
||||
if (aim && !isClimbing && !usingController && character.Stun <= 0.0f && itemPos != Vector2.Zero && !character.IsIncapacitated)
|
||||
{
|
||||
Vector2 mousePos = ConvertUnits.ToSimUnits(character.SmoothedCursorPosition);
|
||||
Vector2 diff = holdable.Aimable ? (mousePos - AimSourceSimPos) * Dir : Vector2.UnitX;
|
||||
Vector2 diff = holdable.Aimable ?
|
||||
(mousePos - AimSourceSimPos) * Dir :
|
||||
MathUtils.RotatePoint(Vector2.UnitX, torsoRotation);
|
||||
holdAngle = MathUtils.VectorToAngle(new Vector2(diff.X, diff.Y * Dir)) - torsoRotation * Dir;
|
||||
holdAngle += GetAimWobble(rightHand, leftHand, item);
|
||||
itemAngle = torsoRotation + holdAngle * Dir;
|
||||
@@ -480,6 +511,16 @@ namespace Barotrauma
|
||||
return;
|
||||
}
|
||||
|
||||
float targetAngle = MathUtils.WrapAngleTwoPi(itemAngle + itemAngleRelativeToHoldAngle * Dir);
|
||||
float currentRotation = MathUtils.WrapAngleTwoPi(item.body.Rotation);
|
||||
float itemRotation = MathHelper.SmoothStep(currentRotation, targetAngle, deltaTime * 25);
|
||||
if (previousDirection != dir || Math.Abs(targetAngle - currentRotation) > MathHelper.Pi)
|
||||
{
|
||||
itemRotation = targetAngle;
|
||||
}
|
||||
item.SetTransform(currItemPos, itemRotation, setPrevTransform: false);
|
||||
previousDirection = dir;
|
||||
|
||||
if (holdable.Pusher != null)
|
||||
{
|
||||
if (character.Stun > 0.0f || character.IsIncapacitated)
|
||||
@@ -497,24 +538,11 @@ namespace Barotrauma
|
||||
else
|
||||
{
|
||||
holdable.Pusher.TargetPosition = currItemPos;
|
||||
holdable.Pusher.TargetRotation = holdAngle * Dir;
|
||||
|
||||
holdable.Pusher.TargetRotation = itemRotation;
|
||||
holdable.Pusher.MoveToTargetPosition(true);
|
||||
|
||||
currItemPos = holdable.Pusher.SimPosition;
|
||||
itemAngle = holdable.Pusher.Rotation;
|
||||
}
|
||||
}
|
||||
}
|
||||
float targetAngle = MathUtils.WrapAngleTwoPi(itemAngle + itemAngleRelativeToHoldAngle * Dir);
|
||||
float currentRotation = MathUtils.WrapAngleTwoPi(item.body.Rotation);
|
||||
float itemRotation = MathHelper.SmoothStep(currentRotation, targetAngle, deltaTime * 25);
|
||||
if (previousDirection != dir || Math.Abs(targetAngle - currentRotation) > MathHelper.Pi)
|
||||
{
|
||||
itemRotation = targetAngle;
|
||||
}
|
||||
item.SetTransform(currItemPos, itemRotation, setPrevTransform: false);
|
||||
previousDirection = dir;
|
||||
|
||||
if (!isClimbing && !character.IsIncapacitated && itemPos != Vector2.Zero && (aim || !holdable.UseHandRotationForHoldAngle))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user