Unstable v0.1100.0.4 (November 11th 2020)

This commit is contained in:
Joonas Rikkonen
2020-11-06 20:12:15 +02:00
parent 6b36bf809d
commit b772654326
297 changed files with 12502 additions and 4277 deletions
@@ -407,8 +407,8 @@ namespace Barotrauma
{
if (CurrentSwimParams == null) { return; }
movement = TargetMovement;
if (movement.LengthSquared() > 0.00001f)
bool isMoving = movement.LengthSquared() > 0.00001f;
if (isMoving)
{
float t = 0.5f;
if (CurrentSwimParams.RotateTowardsMovement && VectorExtensions.Angle(VectorExtensions.Forward(Collider.Rotation + MathHelper.PiOver2), movement) > MathHelper.PiOver2)
@@ -425,7 +425,7 @@ namespace Barotrauma
mainLimb.PullJointEnabled = true;
//mainLimb.PullJointWorldAnchorB = Collider.SimPosition;
if (movement.LengthSquared() < 0.00001f)
if (!isMoving)
{
WalkPos = MathHelper.SmoothStep(WalkPos, MathHelper.PiOver2, deltaTime * 5);
mainLimb.PullJointWorldAnchorB = Collider.SimPosition;
@@ -625,7 +625,8 @@ namespace Barotrauma
if (limb.IsSevered) { continue; }
if (Math.Abs(limb.Params.ConstantTorque) > 0)
{
limb.body.SmoothRotate(MainLimb.Rotation + MathHelper.ToRadians(limb.Params.ConstantAngle) * Dir, limb.Mass * limb.Params.ConstantTorque, wrapAngle: true);
float movementFactor = Math.Max(character.AnimController.Collider.LinearVelocity.Length() * 0.5f, 1);
limb.body.SmoothRotate(MainLimb.Rotation + MathHelper.ToRadians(limb.Params.ConstantAngle) * Dir, limb.Mass * limb.Params.ConstantTorque * movementFactor, wrapAngle: true);
}
if (limb.Params.BlinkFrequency > 0)
{
@@ -703,7 +704,7 @@ namespace Barotrauma
if (head != null)
{
bool headFacingBackwards = false;
if (HeadAngle.HasValue)
if (HeadAngle.HasValue && head != mainLimb)
{
SmoothRotateWithoutWrapping(head, movementAngle + HeadAngle.Value * Dir, mainLimb, HeadTorque);
if (Math.Sign(head.SimPosition.X - mainLimb.SimPosition.X) != Math.Sign(Dir))
@@ -853,11 +854,35 @@ namespace Barotrauma
float noise = (PerlinNoise.GetPerlin(WalkPos * 0.002f, WalkPos * 0.003f) - 0.5f) * 5.0f;
float animStrength = (1.0f - deathAnimTimer / deathAnimDuration);
Limb head = GetLimb(LimbType.Head);
if (head != null && head.IsSevered) { return; }
Limb baseLimb = GetLimb(LimbType.Head);
//if head is the main limb, it technically can't be severed - the rest of the limbs are considered severed if the head gets cut off
if (baseLimb == MainLimb)
{
int connectedToHeadCount = GetConnectedLimbs(baseLimb).Count;
//if there's nothing connected to the head, don't make it wiggle by itself
if (connectedToHeadCount == 1) { baseLimb = null; }
Limb torso = GetLimb(LimbType.Torso, excludeSevered: false);
if (torso != null)
{
//if there are more limbs connected to the torso than to the head, make the torso wiggle instead
int connectedToTorsoCount = GetConnectedLimbs(torso).Count;
if (connectedToTorsoCount > connectedToHeadCount)
{
baseLimb = torso;
}
}
}
else if (baseLimb == null)
{
baseLimb = GetLimb(LimbType.Torso, excludeSevered: true);
if (baseLimb == null) { return; }
}
var connectedToBaseLimb = GetConnectedLimbs(baseLimb);
Limb tail = GetLimb(LimbType.Tail);
if (head != null && !head.IsSevered) head.body.ApplyTorque((float)(Math.Sqrt(head.Mass) * Dir * (Math.Sin(WalkPos) + noise)) * 30.0f * animStrength);
if (tail != null && !tail.IsSevered) tail.body.ApplyTorque((float)(Math.Sqrt(tail.Mass) * -Dir * (Math.Sin(WalkPos) + noise)) * 30.0f * animStrength);
if (baseLimb != null) { baseLimb.body.ApplyTorque((float)(Math.Sqrt(baseLimb.Mass) * Dir * (Math.Sin(WalkPos) + noise)) * 30.0f * animStrength); }
if (tail != null && connectedToBaseLimb.Contains(tail)) { tail.body.ApplyTorque((float)(Math.Sqrt(tail.Mass) * -Dir * (Math.Sin(WalkPos) + noise)) * 30.0f * animStrength); }
WalkPos += deltaTime * 10.0f * animStrength;
@@ -865,7 +890,7 @@ namespace Barotrauma
foreach (Limb limb in Limbs)
{
if (limb.IsSevered) { continue; }
if (!connectedToBaseLimb.Contains(limb)) { continue; }
#if CLIENT
if (limb.LightSource != null)
{
@@ -1974,9 +1974,6 @@ namespace Barotrauma
public override void UpdateUseItem(bool allowMovement, Vector2 handWorldPos)
{
var leftHand = GetLimb(LimbType.LeftHand);
var rightHand = GetLimb(LimbType.RightHand);
useItemTimer = 0.5f;
Anim = Animation.UsingConstruction;
@@ -1999,13 +1996,21 @@ namespace Barotrauma
handSimPos -= character.Submarine.SimPosition;
}
leftHand.Disabled = true;
leftHand.PullJointEnabled = true;
leftHand.PullJointWorldAnchorB = handSimPos;
var leftHand = GetLimb(LimbType.LeftHand);
if (leftHand != null)
{
leftHand.Disabled = true;
leftHand.PullJointEnabled = true;
leftHand.PullJointWorldAnchorB = handSimPos;
}
rightHand.Disabled = true;
rightHand.PullJointEnabled = true;
rightHand.PullJointWorldAnchorB = handSimPos;
var rightHand = GetLimb(LimbType.RightHand);
if (rightHand != null)
{
rightHand.Disabled = true;
rightHand.PullJointEnabled = true;
rightHand.PullJointWorldAnchorB = handSimPos;
}
}
public override void Flip()
@@ -227,7 +227,7 @@ namespace Barotrauma
}
}
bool IsValid(Limb limb) => limb != null && !limb.IsSevered && !limb.ignoreCollisions;
bool IsValid(Limb limb) => limb != null && !limb.IsSevered && !limb.IgnoreCollisions && !limb.Hidden;
return mainLimb;
}
}
@@ -782,6 +782,14 @@ namespace Barotrauma
partial void SeverLimbJointProjSpecific(LimbJoint limbJoint, bool playSound);
protected List<Limb> GetConnectedLimbs(Limb limb)
{
connectedLimbs.Clear();
checkedJoints.Clear();
GetConnectedLimbs(connectedLimbs, checkedJoints, limb);
return connectedLimbs;
}
private void GetConnectedLimbs(List<Limb> connectedLimbs, List<LimbJoint> checkedJoints, Limb limb)
{
connectedLimbs.Add(limb);
@@ -1052,7 +1060,7 @@ namespace Barotrauma
foreach (Limb limb in Limbs)
{
if (limb.ignoreCollisions || limb.IsSevered) { continue; }
if (limb.IgnoreCollisions || limb.IsSevered) { continue; }
try
{
@@ -1626,7 +1634,8 @@ namespace Barotrauma
protected void CheckDistFromCollider()
{
float allowedDist = Math.Max(Math.Max(Collider.radius, Collider.width), Collider.height) * 2.0f;
float allowedDist = Math.Max(Math.Max(Collider.radius, Collider.width), Collider.height) * 2.0f;
allowedDist = Math.Max(allowedDist, 1.0f);
float resetDist = allowedDist * 5.0f;
Vector2 diff = Collider.SimPosition - MainLimb.SimPosition;