Release v0.15.12.0

This commit is contained in:
Joonas Rikkonen
2021-10-27 18:50:57 +03:00
parent bf95e82d80
commit 234fb6bc06
450 changed files with 26042 additions and 10457 deletions
@@ -641,18 +641,9 @@ namespace Barotrauma
NetConfig.MaxPhysicsBodyAngularVelocity);
}
public void ApplyForce(Vector2 force)
public void ApplyForce(Vector2 force, float maxVelocity = NetConfig.MaxPhysicsBodyVelocity)
{
if (!IsValidValue(force, "force", -1e10f, 1e10f)) return;
FarseerBody.ApplyForce(force);
}
/// <summary>
/// Apply a force to the body without increasing it's velocity above a specific limit.
/// </summary>
public void ApplyForce(Vector2 force, float maxVelocity)
{
if (!IsValidValue(maxVelocity, "max velocity")) return;
if (!IsValidValue(maxVelocity, "max velocity")) { return; }
Vector2 velocityAddition = force / Mass * (float)Timing.Step;
Vector2 newVelocity = FarseerBody.LinearVelocity + velocityAddition;
@@ -666,20 +657,20 @@ namespace Barotrauma
force = velocityAddition.ClampLength(maxVelAddition) * Mass / (float)Timing.Step;
}
if (!IsValidValue(force, "clamped force", -1e10f, 1e10f)) return;
if (!IsValidValue(force, "clamped force", -1e10f, 1e10f)) { return; }
FarseerBody.ApplyForce(force);
}
public void ApplyForce(Vector2 force, Vector2 point)
{
if (!IsValidValue(force, "force", -1e10f, 1e10f)) return;
if (!IsValidValue(point, "point")) return;
if (!IsValidValue(force, "force", -1e10f, 1e10f)) { return; }
if (!IsValidValue(point, "point")) { return; }
FarseerBody.ApplyForce(force, point);
}
public void ApplyTorque(float torque)
{
if (!IsValidValue(torque, "torque")) return;
if (!IsValidValue(torque, "torque")) { return; }
FarseerBody.ApplyTorque(torque);
}
@@ -689,8 +680,8 @@ namespace Barotrauma
System.Diagnostics.Debug.Assert(Math.Abs(simPosition.X) < 1000000.0f);
System.Diagnostics.Debug.Assert(Math.Abs(simPosition.Y) < 1000000.0f);
if (!IsValidValue(simPosition, "position", -1e10f, 1e10f)) return false;
if (!IsValidValue(rotation, "rotation")) return false;
if (!IsValidValue(simPosition, "position", -1e10f, 1e10f)) { return false; }
if (!IsValidValue(rotation, "rotation")) { return false; }
FarseerBody.SetTransform(simPosition, rotation);
if (setPrevTransform) { SetPrevTransform(simPosition, rotation); }
@@ -703,8 +694,8 @@ namespace Barotrauma
System.Diagnostics.Debug.Assert(Math.Abs(simPosition.X) < 1000000.0f);
System.Diagnostics.Debug.Assert(Math.Abs(simPosition.Y) < 1000000.0f);
if (!IsValidValue(simPosition, "position", -1e10f, 1e10f)) return false;
if (!IsValidValue(rotation, "rotation")) return false;
if (!IsValidValue(simPosition, "position", -1e10f, 1e10f)) { return false; }
if (!IsValidValue(rotation, "rotation")) { return false; }
FarseerBody.SetTransformIgnoreContacts(ref simPosition, rotation);
if (setPrevTransform) { SetPrevTransform(simPosition, rotation); }
@@ -756,12 +747,13 @@ namespace Barotrauma
Vector2 vel = FarseerBody.LinearVelocity;
Vector2 deltaPos = simPosition - (Vector2)pullPos;
#if DEBUG
if (deltaPos.LengthSquared() > 100.0f * 100.0f)
{
#if DEBUG
DebugConsole.ThrowError("Attempted to move a physics body to an invalid position.\n" + Environment.StackTrace.CleanupStackTrace());
}
#endif
return;
}
deltaPos *= force;
ApplyLinearImpulse((deltaPos - vel * 0.5f) * FarseerBody.Mass, (Vector2)pullPos);
}
@@ -788,7 +780,7 @@ namespace Barotrauma
dragForce = Math.Min(drag, Mass * 500.0f) * -velDir;
}
ApplyForce(dragForce + buoyancy, maxVelocity: NetConfig.MaxPhysicsBodyVelocity);
ApplyForce(dragForce + buoyancy);
ApplyTorque(FarseerBody.AngularVelocity * FarseerBody.Mass * -0.08f);
}