diff --git a/Subsurface/Source/GameMain.cs b/Subsurface/Source/GameMain.cs index d11b0f9a2..b9ad84ce6 100644 --- a/Subsurface/Source/GameMain.cs +++ b/Subsurface/Source/GameMain.cs @@ -292,6 +292,8 @@ namespace Barotrauma { Timing.Accumulator += gameTime.ElapsedGameTime.TotalSeconds; + bool paused = false; + while (Timing.Accumulator >= Timing.Step) { fixedTime.IsRunningSlowly = gameTime.IsRunningSlowly; @@ -302,8 +304,6 @@ namespace Barotrauma PlayerInput.Update(Timing.Step); - bool paused = false; - if (titleScreenOpen) { if (TitleScreen.LoadState >= 100.0f && @@ -342,7 +342,7 @@ namespace Barotrauma Timing.Accumulator -= Timing.Step; } - Timing.Alpha = Timing.Accumulator / Timing.Step; + if (!paused) Timing.Alpha = Timing.Accumulator / Timing.Step; } diff --git a/Subsurface/Source/Map/Hull.cs b/Subsurface/Source/Map/Hull.cs index 62f5ddcdd..9474d9430 100644 --- a/Subsurface/Source/Map/Hull.cs +++ b/Subsurface/Source/Map/Hull.cs @@ -403,17 +403,7 @@ namespace Barotrauma foreach (Gap gap in ConnectedGaps) { float gapFlow = gap.LerpedFlowForce.Length(); - -#if DEBUG - var asd = MapEntity.FindEntityByID(gap.ID); - - if (asd != gap) - { - int adslkmfdlasfk = 9; - } -#endif - - + if (gapFlow > strongestFlow) { strongestFlow = gapFlow; @@ -492,11 +482,9 @@ namespace Barotrauma waveVel[i] = waveVel[i] * -0.5f; } - //acceleration float a = -WaveStiffness * waveY[i] - waveVel[i] * WaveDampening; waveVel[i] = waveVel[i] + a; - } for (int j = 0; j < 2; j++) @@ -517,6 +505,9 @@ namespace Barotrauma } } + //interpolate the position of the rendered surface towards the "target surface" + surface = MathHelper.Lerp(surface, surfaceY, deltaTime*10.0f); + if (volume < FullVolume) { LethalPressure -= 10.0f * deltaTime; @@ -608,15 +599,7 @@ namespace Barotrauma isHighlighted ? Color.LightBlue*0.5f : Color.Red*0.5f, true,0, (int)Math.Max((1.5f / GameScreen.Selected.Cam.Zoom), 1.0f)); } } - - private float GetSurfaceY() - { - float top = rect.Y + Submarine.DrawPosition.Y; - float bottom = top - rect.Height; - - return bottom + Volume / rect.Width; - } - + public void Render(GraphicsDevice graphicsDevice, Camera cam) { if (renderer.PositionInBuffer > renderer.vertices.Length - 6) return; @@ -626,10 +609,7 @@ namespace Barotrauma //calculate where the surface should be based on the water volume float top = rect.Y + submarinePos.Y; float bottom = top - rect.Height; - float surfaceY = bottom + Volume / rect.Width; - //interpolate the position of the rendered surface towards the "target surface" - surface = surface + ((surfaceY - submarinePos.Y) - surface) / 10.0f; float drawSurface = surface + submarinePos.Y; Matrix transform = cam.Transform * Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f; diff --git a/Subsurface/Source/Map/Levels/Level.cs b/Subsurface/Source/Map/Levels/Level.cs index f5ae51cea..c3adb7194 100644 --- a/Subsurface/Source/Map/Levels/Level.cs +++ b/Subsurface/Source/Map/Levels/Level.cs @@ -814,6 +814,11 @@ namespace Barotrauma WrappingWall.UpdateWallShift(Submarine.MainSub.WorldPosition, wrappingWalls); } + if (Hull.renderer != null) + { + Hull.renderer.ScrollWater((float)deltaTime); + } + renderer.Update(deltaTime); } diff --git a/Subsurface/Source/Screens/GameScreen.cs b/Subsurface/Source/Screens/GameScreen.cs index 3dfcc9889..aa1bd038d 100644 --- a/Subsurface/Source/Screens/GameScreen.cs +++ b/Subsurface/Source/Screens/GameScreen.cs @@ -166,13 +166,6 @@ namespace Barotrauma { cam.UpdateTransform(true); - if (Hull.renderer != null) - { - Hull.renderer.ScrollWater((float)deltaTime); - } - - //damageStencil = TextureLoader.FromFile("Content/Map/background.png"); - DrawMap(graphics, spriteBatch); spriteBatch.Begin();