From 9061f0e53a1c97575d4db2417c7ffc0800a432ea Mon Sep 17 00:00:00 2001 From: Regalis Date: Wed, 23 Nov 2016 21:20:00 +0200 Subject: [PATCH] Water flows more slowly through partially open gaps --- Subsurface/Source/Map/Gap.cs | 12 +++++------- Subsurface/Source/Map/Structure.cs | 7 +++---- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Subsurface/Source/Map/Gap.cs b/Subsurface/Source/Map/Gap.cs index 3d346aaa6..b99a83ddf 100644 --- a/Subsurface/Source/Map/Gap.cs +++ b/Subsurface/Source/Map/Gap.cs @@ -252,7 +252,7 @@ namespace Barotrauma 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(); @@ -531,7 +531,7 @@ namespace Barotrauma //a variable affecting the water flow through the gap //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; @@ -562,12 +562,10 @@ namespace Barotrauma if (hull1.Volume < hull1.FullVolume - Hull.MaxCompress && hull1.Surface < rect.Y) { - - 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; - + vel *= Math.Min(Math.Abs(flowForce.X) / 200.0f, 1.0f); hull1.WaveVel[hull1.WaveY.Length - 1] += vel; hull1.WaveVel[hull1.WaveY.Length - 2] += vel; @@ -575,11 +573,11 @@ namespace Barotrauma else { 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[1] += vel; - } + } } else { diff --git a/Subsurface/Source/Map/Structure.cs b/Subsurface/Source/Map/Structure.cs index 966bff8c9..46d56a1bd 100644 --- a/Subsurface/Source/Map/Structure.cs +++ b/Subsurface/Source/Map/Structure.cs @@ -763,11 +763,10 @@ namespace Barotrauma 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); sections[sectionIndex].damage = MathHelper.Clamp(damage, 0.0f, prefab.MaxHealth);