Water flows more slowly through partially open gaps

This commit is contained in:
Regalis
2016-11-23 21:20:00 +02:00
parent b773413b45
commit 9061f0e53a
2 changed files with 8 additions and 11 deletions
+5 -7
View File
@@ -252,7 +252,7 @@ namespace Barotrauma
lerpedFlowForce = Vector2.Lerp(lerpedFlowForce, flowForce, deltaTime); lerpedFlowForce = Vector2.Lerp(lerpedFlowForce, flowForce, deltaTime);
if (LerpedFlowForce.Length() > 100.0f && flowTargetHull != null && flowTargetHull.Volume < flowTargetHull.FullVolume) if (LerpedFlowForce.LengthSquared() > 10000.0f && flowTargetHull != null && flowTargetHull.Volume < flowTargetHull.FullVolume)
{ {
//UpdateFlowForce(); //UpdateFlowForce();
@@ -531,7 +531,7 @@ namespace Barotrauma
//a variable affecting the water flow through the gap //a variable affecting the water flow through the gap
//the larger the gap is, the faster the water flows //the larger the gap is, the faster the water flows
float sizeModifier = size * open; float sizeModifier = size * open * open;
float delta = Hull.MaxCompress * sizeModifier * deltaTime; float delta = Hull.MaxCompress * sizeModifier * deltaTime;
@@ -562,12 +562,10 @@ namespace Barotrauma
if (hull1.Volume < hull1.FullVolume - Hull.MaxCompress && if (hull1.Volume < hull1.FullVolume - Hull.MaxCompress &&
hull1.Surface < rect.Y) hull1.Surface < rect.Y)
{ {
if (rect.X > hull1.Rect.X + hull1.Rect.Width / 2.0f) if (rect.X > hull1.Rect.X + hull1.Rect.Width / 2.0f)
{ {
float vel = ((rect.Y - rect.Height / 2) - (hull1.Surface + hull1.WaveY[hull1.WaveY.Length - 1])) * 0.1f; float vel = ((rect.Y - rect.Height / 2) - (hull1.Surface + hull1.WaveY[hull1.WaveY.Length - 1])) * 0.1f;
vel *= Math.Min(Math.Abs(flowForce.X) / 200.0f, 1.0f);
hull1.WaveVel[hull1.WaveY.Length - 1] += vel; hull1.WaveVel[hull1.WaveY.Length - 1] += vel;
hull1.WaveVel[hull1.WaveY.Length - 2] += vel; hull1.WaveVel[hull1.WaveY.Length - 2] += vel;
@@ -575,11 +573,11 @@ namespace Barotrauma
else else
{ {
float vel = ((rect.Y - rect.Height / 2) - (hull1.Surface + hull1.WaveY[0])) * 0.1f; float vel = ((rect.Y - rect.Height / 2) - (hull1.Surface + hull1.WaveY[0])) * 0.1f;
vel *= Math.Min(Math.Abs(flowForce.X) / 200.0f, 1.0f);
hull1.WaveVel[0] += vel; hull1.WaveVel[0] += vel;
hull1.WaveVel[1] += vel; hull1.WaveVel[1] += vel;
} }
} }
else else
{ {
+3 -4
View File
@@ -763,11 +763,10 @@ namespace Barotrauma
if(CastShadow) GenerateConvexHull(); if(CastShadow) GenerateConvexHull();
} }
sections[sectionIndex].gap.Open = (damage / prefab.MaxHealth - 0.5f) * 2.0f;
} }
if (sections[sectionIndex].gap != null)
sections[sectionIndex].gap.Open = (damage/prefab.MaxHealth - 0.5f)*2;
bool hadHole = SectionBodyDisabled(sectionIndex); bool hadHole = SectionBodyDisabled(sectionIndex);
sections[sectionIndex].damage = MathHelper.Clamp(damage, 0.0f, prefab.MaxHealth); sections[sectionIndex].damage = MathHelper.Clamp(damage, 0.0f, prefab.MaxHealth);