(bbd192053) Rebind Select and Use keys. Refactor GameSettings to support legacy bindings, when they are set. That is, if the new "deselect" and "shoot" keys are not defined, but the player config file is found, use the "select" and the "use" keys instead of the defaults.

This commit is contained in:
Joonas Rikkonen
2019-04-04 11:08:02 +03:00
parent 79ea41e6c9
commit 7491b06a5d
55 changed files with 594 additions and 584 deletions
@@ -605,7 +605,7 @@ namespace Barotrauma
{
if (!IsValidValue(impulse, "impulse", -1e10f, 1e10f)) return;
if (!IsValidValue(point, "point")) return;
if (!IsValidValue(impulse / body.Mass, "new velocity", -1000.0f, 1000.0f)) return;
if (!IsValidValue(impulse / body.Mass, "new velocity")) return;
body.ApplyLinearImpulse(impulse, point);
}
@@ -646,20 +646,15 @@ namespace Barotrauma
/// </summary>
public void ApplyForce(Vector2 force, float maxVelocity)
{
if (!IsValidValue(force, "force", -1e10f, 1e10f)) return;
if (!IsValidValue(maxVelocity, "max velocity")) return;
float currSpeed = body.LinearVelocity.Length();
Vector2 velocityAddition = force / Mass * (float)Timing.Step;
Vector2 newVelocity = body.LinearVelocity + velocityAddition;
float newSpeedSqr = newVelocity.LengthSquared();
if (newSpeedSqr > maxVelocity * maxVelocity)
{
newVelocity = newVelocity.ClampLength(maxVelocity);
}
newVelocity = newVelocity.ClampLength(Math.Max(currSpeed, maxVelocity));
Vector2 clampedForce = (newVelocity - body.LinearVelocity) * Mass / (float)Timing.Step;
if (!IsValidValue(force, "clamped force", -1e10f, 1e10f)) return;
body.ApplyForce(force);
body.ApplyForce((newVelocity - body.LinearVelocity) * Mass / (float)Timing.Step);
}
public void ApplyForce(Vector2 force, Vector2 point)