v1.6.17.0 (Unto the Breach update)

This commit is contained in:
Regalis11
2024-10-22 17:29:04 +03:00
parent e74b3cdb17
commit 6e6c17e100
417 changed files with 17166 additions and 5870 deletions
@@ -453,7 +453,8 @@ namespace Barotrauma
}
CreateBody(width, height, radius, density, bodyType, _collisionCategories, _collidesWith, findNewContacts);
FarseerBody.Friction = element.GetAttributeFloat("friction", 0.5f);
FarseerBody.Restitution = element.GetAttributeFloat("restitution", 0.05f);
FarseerBody.Restitution = element.GetAttributeFloat("restitution", 0.05f);
FarseerBody.GravityScale = element.GetAttributeFloat("gravityscale", 1.0f);
FarseerBody.UserData = this;
SetTransformIgnoreContacts(position, 0.0f);
LastSentPosition = position;
@@ -585,9 +586,6 @@ namespace Barotrauma
default:
throw new NotImplementedException();
}
#if CLIENT
bodyShapeTexture = null;
#endif
}
public bool IsValidValue(float value, string valueName, float minValue = float.MinValue, float maxValue = float.MaxValue)
@@ -714,16 +712,31 @@ namespace Barotrauma
{
if (!IsValidValue(maxVelocity, "max velocity")) { return; }
if (force.LengthSquared() < 0.01f) { return; }
Vector2 velocityAddition = force / Mass * (float)Timing.Step;
Vector2 newVelocity = FarseerBody.LinearVelocity + velocityAddition;
float newSpeedSqr = newVelocity.LengthSquared();
if (newSpeedSqr > maxVelocity * maxVelocity && Vector2.Dot(FarseerBody.LinearVelocity, force) > 0.0f)
if (newSpeedSqr > maxVelocity * maxVelocity)
{
float newSpeed = (float)Math.Sqrt(newSpeedSqr);
float maxVelAddition = maxVelocity - newSpeed;
if (maxVelAddition <= 0.0f) { return; }
force = velocityAddition.ClampLength(maxVelAddition) * Mass / (float)Timing.Step;
float currSpeed = FarseerBody.LinearVelocity.Length();
//limit velocity if the force is increasing the velocity in the current or new direction of travel
// = we don't want to limit it if the force is slowing down the movement: if a projectile is moving at 50 m/s
// and we apply a force that can only impart a maximum velocity of 1 m/s, we don't want to clamp that projectile to 1 m/s!
//force is acting in the same direction as the current velocity
// -> the maximum allowed change is the difference from current to max speed
if (Vector2.Dot(FarseerBody.LinearVelocity, force) > 0.0f)
{
force = velocityAddition.ClampLength(Math.Max(maxVelocity - currSpeed, 0)) * Mass / (float)Timing.Step;
}
//the new velocity will be in the direction of the force
// -> make sure it's not too much, maximum allowed change is current speed plus the max speed
else if (Vector2.Dot(newVelocity, force) > 0.0f)
{
force = velocityAddition.ClampLength(maxVelocity + currSpeed) * Mass / (float)Timing.Step;
}
}
if (!IsValidValue(force, "clamped force", -1e10f, 1e10f)) { return; }