v0.13.0.11

This commit is contained in:
Joonas Rikkonen
2021-04-22 17:33:08 +03:00
parent 0697d7fc64
commit 8bb31f2893
391 changed files with 17271 additions and 5949 deletions
@@ -423,23 +423,25 @@ namespace Barotrauma
if (CurrentSwimParams == null) { return; }
movement = TargetMovement;
bool isMoving = movement.LengthSquared() > 0.00001f;
var mainLimb = MainLimb;
if (isMoving)
{
float t = 0.5f;
if (CurrentSwimParams.RotateTowardsMovement && VectorExtensions.Angle(VectorExtensions.Forward(Collider.Rotation + MathHelper.PiOver2), movement) > MathHelper.PiOver2)
if (!SimplePhysicsEnabled && CurrentSwimParams.RotateTowardsMovement)
{
// Reduce the linear movement speed when not facing the movement direction
t /= 5;
Vector2 forward = VectorExtensions.Forward(Collider.Rotation + MathHelper.PiOver2);
float dot = Vector2.Dot(forward, Vector2.Normalize(movement));
if (dot < 0)
{
// Reduce the linear movement speed when not facing the movement direction
t = MathHelper.Clamp((1 + dot) / 10, 0.01f, 0.1f);
}
}
Collider.LinearVelocity = Vector2.Lerp(Collider.LinearVelocity, movement, t);
}
//limbs are disabled when simple physics is enabled, no need to move them
if (SimplePhysicsEnabled) { return; }
var mainLimb = MainLimb;
mainLimb.PullJointEnabled = true;
//mainLimb.PullJointWorldAnchorB = Collider.SimPosition;
if (!isMoving)
{
WalkPos = MathHelper.SmoothStep(WalkPos, MathHelper.PiOver2, deltaTime * 5);
@@ -645,7 +647,7 @@ namespace Barotrauma
}
if (limb.Params.BlinkFrequency > 0)
{
limb.Blink(deltaTime, MainLimb.Rotation);
limb.UpdateBlink(deltaTime, MainLimb.Rotation);
}
}
@@ -787,7 +789,7 @@ namespace Barotrauma
}
if (limb.Params.BlinkFrequency > 0)
{
limb.Blink(deltaTime, MainLimb.Rotation);
limb.UpdateBlink(deltaTime, MainLimb.Rotation);
}
switch (limb.type)
{
@@ -281,7 +281,7 @@ namespace Barotrauma
}
}
public const float MAX_SPEED = 15;
public const float MAX_SPEED = 20;
public Vector2 TargetMovement
{
@@ -472,7 +472,7 @@ namespace Barotrauma
if (joint == null) { continue; }
float angle = (joint.LowerLimit + joint.UpperLimit) / 2.0f;
joint.LimbB?.body?.SetTransform(
(joint.WorldAnchorA - MathUtils.RotatePointAroundTarget(joint.LocalAnchorB, Vector2.Zero, MathHelper.ToDegrees(joint.BodyA.Rotation + angle), true)),
(joint.WorldAnchorA - MathUtils.RotatePointAroundTarget(joint.LocalAnchorB, Vector2.Zero, joint.BodyA.Rotation + angle, true)),
joint.BodyA.Rotation + angle);
}
}
@@ -636,9 +636,12 @@ namespace Barotrauma
//always collides with bodies other than structures
if (!(f2.Body.UserData is Structure structure))
{
lock (impactQueue)
if (!f2.IsSensor)
{
impactQueue.Enqueue(new Impact(f1, f2, contact, velocity));
lock (impactQueue)
{
impactQueue.Enqueue(new Impact(f1, f2, contact, velocity));
}
}
return true;
}
@@ -1120,6 +1123,32 @@ namespace Barotrauma
splashSoundTimer -= deltaTime;
if (character.Submarine == null && Level.Loaded != null)
{
if (Collider.SimPosition.Y > Level.Loaded.TopBarrier.Position.Y)
{
Collider.LinearVelocity = new Vector2(Collider.LinearVelocity.X, Math.Min(Collider.LinearVelocity.Y, -1));
}
else if (Collider.SimPosition.Y < Level.Loaded.BottomBarrier.Position.Y)
{
Collider.LinearVelocity = new Vector2(Collider.LinearVelocity.X,
MathHelper.Clamp(Collider.LinearVelocity.Y, Level.Loaded.BottomBarrier.Position.Y - Collider.SimPosition.Y, 10.0f));
}
foreach (Limb limb in Limbs)
{
if (limb.SimPosition.Y > Level.Loaded.TopBarrier.Position.Y)
{
limb.body.LinearVelocity = new Vector2(limb.LinearVelocity.X, Math.Min(limb.LinearVelocity.Y, -1));
}
else if (limb.SimPosition.Y < Level.Loaded.BottomBarrier.Position.Y)
{
limb.body.LinearVelocity = new Vector2(
limb.LinearVelocity.X,
MathHelper.Clamp(limb.LinearVelocity.Y, Level.Loaded.BottomBarrier.Position.Y - limb.SimPosition.Y, 10.0f));
}
}
}
if (forceStanding)
{
inWater = false;