Unstable 0.1500.6.0 (1984 edition)
This commit is contained in:
@@ -357,8 +357,11 @@ namespace Barotrauma
|
||||
float itemAngle;
|
||||
Holdable holdable = item.GetComponent<Holdable>();
|
||||
float torsoRotation = torso.Rotation;
|
||||
bool equippedInRightHand = character.Inventory?.GetItemInLimbSlot(InvSlotType.RightHand) == item && rightHand != null && !rightHand.IsSevered;
|
||||
bool equippedInLefthand = character.Inventory?.GetItemInLimbSlot(InvSlotType.LeftHand) == item && leftHand != null && !leftHand.IsSevered;
|
||||
|
||||
Item rightHandItem = character.Inventory?.GetItemInLimbSlot(InvSlotType.RightHand);
|
||||
bool equippedInRightHand = rightHandItem == item && rightHand != null && !rightHand.IsSevered;
|
||||
Item leftHandItem = character.Inventory?.GetItemInLimbSlot(InvSlotType.LeftHand);
|
||||
bool equippedInLefthand = leftHandItem == item && leftHand != null && !leftHand.IsSevered;
|
||||
if (aim && !isClimbing && !usingController && character.Stun <= 0.0f && itemPos != Vector2.Zero && !character.IsIncapacitated)
|
||||
{
|
||||
Vector2 mousePos = ConvertUnits.ToSimUnits(character.SmoothedCursorPosition);
|
||||
@@ -366,17 +369,23 @@ namespace Barotrauma
|
||||
holdAngle = MathUtils.VectorToAngle(new Vector2(diff.X, diff.Y * Dir)) - torsoRotation * Dir;
|
||||
holdAngle += GetAimWobble(rightHand, leftHand, item);
|
||||
itemAngle = torsoRotation + holdAngle * Dir;
|
||||
|
||||
if (holdable.ControlPose)
|
||||
{
|
||||
var head = GetLimb(LimbType.Head);
|
||||
if (head != null)
|
||||
//if holding two items that should control the characters' pose, let the item in the right hand do it
|
||||
bool anotherItemControlsPose = equippedInLefthand && rightHandItem != item && (rightHandItem?.GetComponent<Holdable>()?.ControlPose ?? false);
|
||||
if (!anotherItemControlsPose)
|
||||
{
|
||||
head.body.SmoothRotate(itemAngle, force: 30 * head.Mass);
|
||||
}
|
||||
if (TargetMovement == Vector2.Zero && inWater)
|
||||
{
|
||||
torso.body.AngularVelocity -= torso.body.AngularVelocity * 0.1f;
|
||||
torso.body.ApplyForce(torso.body.LinearVelocity * -0.5f);
|
||||
var head = GetLimb(LimbType.Head);
|
||||
if (head != null)
|
||||
{
|
||||
head.body.SmoothRotate(itemAngle, force: 30 * head.Mass);
|
||||
}
|
||||
if (TargetMovement == Vector2.Zero && inWater)
|
||||
{
|
||||
torso.body.AngularVelocity -= torso.body.AngularVelocity * 0.1f;
|
||||
torso.body.ApplyForce(torso.body.LinearVelocity * -0.5f);
|
||||
}
|
||||
}
|
||||
aiming = true;
|
||||
}
|
||||
@@ -506,7 +515,11 @@ namespace Barotrauma
|
||||
DebugConsole.AddWarning($"Aim position for the item {item.Name} may be incorrect (further than the length of the character's arm)");
|
||||
}
|
||||
#endif
|
||||
HandIK(i == 0 ? rightHand : leftHand, transformedHoldPos + transformedHandlePos[i], CurrentAnimationParams.ArmIKStrength, CurrentAnimationParams.HandIKStrength);
|
||||
HandIK(
|
||||
i == 0 ? rightHand : leftHand, transformedHoldPos + transformedHandlePos[i],
|
||||
CurrentAnimationParams.ArmIKStrength,
|
||||
CurrentAnimationParams.HandIKStrength,
|
||||
maxAngularVelocity: 15.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -531,7 +544,7 @@ namespace Barotrauma
|
||||
return (lowFreqNoise * 1.0f + highFreqNoise * 0.1f) * wobbleStrength;
|
||||
}
|
||||
|
||||
public void HandIK(Limb hand, Vector2 pos, float armTorque = 1.0f, float handTorque = 1.0f)
|
||||
public void HandIK(Limb hand, Vector2 pos, float armTorque = 1.0f, float handTorque = 1.0f, float maxAngularVelocity = float.PositiveInfinity)
|
||||
{
|
||||
Vector2 shoulderPos;
|
||||
|
||||
@@ -572,11 +585,20 @@ namespace Barotrauma
|
||||
armAngle -= MathHelper.TwoPi;
|
||||
}
|
||||
|
||||
arm?.body.SmoothRotate(armAngle - upperArmAngle, 100.0f * armTorque * arm.Mass, wrapAngle: false);
|
||||
if (arm?.body != null && Math.Abs(arm.body.AngularVelocity) < maxAngularVelocity)
|
||||
{
|
||||
arm.body.SmoothRotate(armAngle - upperArmAngle, 100.0f * armTorque * arm.Mass, wrapAngle: false);
|
||||
}
|
||||
float forearmAngle = armAngle + lowerArmAngle;
|
||||
forearm?.body.SmoothRotate(forearmAngle, 100.0f * handTorque * forearm.Mass, wrapAngle: false);
|
||||
float handAngle = forearm != null ? forearmAngle : armAngle;
|
||||
hand?.body.SmoothRotate(handAngle, 10.0f * handTorque * hand.Mass, wrapAngle: false);
|
||||
if (forearm?.body != null && Math.Abs(forearm.body.AngularVelocity) < maxAngularVelocity)
|
||||
{
|
||||
forearm.body.SmoothRotate(forearmAngle, 100.0f * handTorque * forearm.Mass, wrapAngle: false);
|
||||
}
|
||||
if (hand?.body != null && Math.Abs(hand.body.AngularVelocity) < maxAngularVelocity)
|
||||
{
|
||||
float handAngle = forearm != null ? forearmAngle : armAngle;
|
||||
hand.body.SmoothRotate(handAngle, 10.0f * handTorque * hand.Mass, wrapAngle: false);
|
||||
}
|
||||
}
|
||||
|
||||
public void ApplyPose(Vector2 leftHandPos, Vector2 rightHandPos, Vector2 leftFootPos, Vector2 rightFootPos, float footMoveForce = 10)
|
||||
@@ -672,7 +694,7 @@ namespace Barotrauma
|
||||
|
||||
forearmLength += Vector2.Distance(
|
||||
rightHand.PullJointLocalAnchorA,
|
||||
rightElbow.LimbA.type == LimbType.RightHand ? rightElbow.LocalAnchorA : rightElbow.LocalAnchorB);
|
||||
rightWrist.LimbA.type == LimbType.RightHand ? rightWrist.LocalAnchorA : rightWrist.LocalAnchorB);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -815,7 +815,7 @@ namespace Barotrauma
|
||||
{
|
||||
limb.body.SmoothRotate(MainLimb.Rotation + MathHelper.ToRadians(limb.Params.ConstantAngle) * Dir, limb.Mass * limb.Params.ConstantTorque, wrapAngle: true);
|
||||
}
|
||||
if (limb.Params.BlinkFrequency > 0)
|
||||
if (limb.Params.BlinkFrequency > 0 && !limb.Params.OnlyBlinkInWater)
|
||||
{
|
||||
limb.UpdateBlink(deltaTime, MainLimb.Rotation);
|
||||
}
|
||||
|
||||
+4
-4
@@ -170,7 +170,7 @@ namespace Barotrauma
|
||||
{
|
||||
get
|
||||
{
|
||||
float shoulderHeight = Collider.height / 2.0f - 0.1f;
|
||||
float shoulderHeight = Collider.height / 2.0f;
|
||||
if (inWater)
|
||||
{
|
||||
shoulderHeight += 0.4f;
|
||||
@@ -987,7 +987,7 @@ namespace Barotrauma
|
||||
return;
|
||||
}
|
||||
|
||||
handPos += head.LinearVelocity * 0.1f;
|
||||
handPos += head.LinearVelocity.ClampLength(1.0f) * 0.1f;
|
||||
|
||||
// Not sure why the params has to be flipped, but it works.
|
||||
var handMoveAmount = CurrentSwimParams.HandMoveAmount.Flip();
|
||||
@@ -1002,7 +1002,7 @@ namespace Barotrauma
|
||||
Vector2 rightHandPos = new Vector2(-handPosX, -handPosY) + handMoveOffset;
|
||||
rightHandPos.X = (Dir == 1.0f) ? Math.Max(0.3f, rightHandPos.X) : Math.Min(-0.3f, rightHandPos.X);
|
||||
rightHandPos = Vector2.Transform(rightHandPos, rotationMatrix);
|
||||
float speedMultiplier = character.SpeedMultiplier * (1 - Character.GetRightHandPenalty());
|
||||
float speedMultiplier = Math.Min(character.SpeedMultiplier * (1 - Character.GetRightHandPenalty()), 1.0f);
|
||||
// Limb hand, Vector2 pos, float force = 1.0f
|
||||
HandIK(rightHand, handPos + rightHandPos, CurrentSwimParams.ArmMoveStrength * speedMultiplier, CurrentSwimParams.HandMoveStrength * speedMultiplier);
|
||||
}
|
||||
@@ -1012,7 +1012,7 @@ namespace Barotrauma
|
||||
Vector2 leftHandPos = new Vector2(handPosX, handPosY) + handMoveOffset;
|
||||
leftHandPos.X = (Dir == 1.0f) ? Math.Max(0.3f, leftHandPos.X) : Math.Min(-0.3f, leftHandPos.X);
|
||||
leftHandPos = Vector2.Transform(leftHandPos, rotationMatrix);
|
||||
float speedMultiplier = character.SpeedMultiplier * (1 - Character.GetLeftHandPenalty());
|
||||
float speedMultiplier = Math.Min(character.SpeedMultiplier * (1 - Character.GetLeftHandPenalty()), 1.0f);
|
||||
HandIK(leftHand, handPos + leftHandPos, CurrentSwimParams.ArmMoveStrength * speedMultiplier, CurrentSwimParams.HandMoveStrength * speedMultiplier);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1212,24 +1212,24 @@ namespace Barotrauma
|
||||
//the room where the ragdoll is in is used as the "guess", meaning that it's checked first
|
||||
Hull limbHull = currentHull == null ? null : Hull.FindHull(limb.WorldPosition, currentHull);
|
||||
|
||||
bool prevInWater = limb.inWater;
|
||||
limb.inWater = false;
|
||||
bool prevInWater = limb.InWater;
|
||||
limb.InWater = false;
|
||||
|
||||
if (forceStanding)
|
||||
{
|
||||
limb.inWater = false;
|
||||
limb.InWater = false;
|
||||
}
|
||||
else if (limbHull == null)
|
||||
{
|
||||
//limb isn't in any room -> it's in the water
|
||||
limb.inWater = true;
|
||||
limb.InWater = true;
|
||||
if (limb.type == LimbType.Head) headInWater = true;
|
||||
}
|
||||
else if (limbHull.WaterVolume > 0.0f && Submarine.RectContains(limbHull.Rect, limb.Position))
|
||||
{
|
||||
if (limb.Position.Y < limbHull.Surface)
|
||||
{
|
||||
limb.inWater = true;
|
||||
limb.InWater = true;
|
||||
surfaceY = limbHull.Surface;
|
||||
if (limb.type == LimbType.Head)
|
||||
{
|
||||
@@ -1237,7 +1237,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
//the limb has gone through the surface of the water
|
||||
if (Math.Abs(limb.LinearVelocity.Y) > 5.0f && limb.inWater != prevInWater)
|
||||
if (Math.Abs(limb.LinearVelocity.Y) > 5.0f && limb.InWater != prevInWater)
|
||||
{
|
||||
Splash(limb, limbHull);
|
||||
|
||||
@@ -1435,7 +1435,7 @@ namespace Barotrauma
|
||||
flowForce *= 1 - Math.Clamp(character.GetStatValue(StatTypes.FlowResistance), 0f, 1f);
|
||||
|
||||
float flowForceMagnitude = flowForce.Length();
|
||||
float limbMultipier = limbs.Count(l => l.inWater) / (float)limbs.Length;
|
||||
float limbMultipier = limbs.Count(l => l.InWater) / (float)limbs.Length;
|
||||
//if the force strong enough, stun the character to let it get thrown around by the water
|
||||
if ((flowForceMagnitude * limbMultipier) - flowStunTolerance > StunForceThreshold)
|
||||
{
|
||||
@@ -1472,7 +1472,7 @@ namespace Barotrauma
|
||||
Collider.ApplyForce(flowForce, maxVelocity: NetConfig.MaxPhysicsBodyVelocity);
|
||||
foreach (Limb limb in limbs)
|
||||
{
|
||||
if (!limb.inWater) { continue; }
|
||||
if (!limb.InWater) { continue; }
|
||||
limb.body.ApplyForce(flowForce, maxVelocity: NetConfig.MaxPhysicsBodyVelocity);
|
||||
}
|
||||
}
|
||||
@@ -1840,9 +1840,23 @@ namespace Barotrauma
|
||||
|
||||
public void ReleaseStuckLimbs()
|
||||
{
|
||||
Limbs.ForEach(l => l.Release());
|
||||
// Commented out, because stuck limbs is not a feature that we currently use, as it would require that we sync all the limbs, which we don't do.
|
||||
//Limbs.ForEach(l => l.Release());
|
||||
}
|
||||
|
||||
public void HideAndDisable(LimbType limbType, float duration = 0, bool ignoreCollisions = true)
|
||||
{
|
||||
foreach (var limb in Limbs)
|
||||
{
|
||||
if (limb.type == limbType)
|
||||
{
|
||||
limb.HideAndDisable(duration, ignoreCollisions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RestoreTemporarilyDisabled() => Limbs.ForEach(l => l.ReEnable());
|
||||
|
||||
public void Remove()
|
||||
{
|
||||
if (Limbs != null)
|
||||
|
||||
Reference in New Issue
Block a user