From ff7f43ca83b92b83506fdf40a7bf88e69aff2938 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Tue, 13 Feb 2018 12:28:54 +0200 Subject: [PATCH] Fixed inconsistent decal draw order --- Barotrauma/BarotraumaClient/Source/Map/Hull.cs | 6 ++++-- Barotrauma/BarotraumaClient/Source/Particles/Decal.cs | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/Map/Hull.cs b/Barotrauma/BarotraumaClient/Source/Map/Hull.cs index c9992a390..efa913405 100644 --- a/Barotrauma/BarotraumaClient/Source/Map/Hull.cs +++ b/Barotrauma/BarotraumaClient/Source/Map/Hull.cs @@ -190,10 +190,12 @@ namespace Barotrauma { Rectangle hullDrawRect = rect; if (Submarine != null) hullDrawRect.Location += Submarine.DrawPosition.ToPoint(); - + + float depth = 1.0f; foreach (Decal d in decals) { - d.Draw(spriteBatch, this); + d.Draw(spriteBatch, this, depth); + depth -= 0.000001f; } } diff --git a/Barotrauma/BarotraumaClient/Source/Particles/Decal.cs b/Barotrauma/BarotraumaClient/Source/Particles/Decal.cs index 42ead6b92..4fdc15d52 100644 --- a/Barotrauma/BarotraumaClient/Source/Particles/Decal.cs +++ b/Barotrauma/BarotraumaClient/Source/Particles/Decal.cs @@ -105,13 +105,13 @@ namespace Barotrauma.Particles fadeTimer = Prefab.FadeInTime; } - public void Draw(SpriteBatch spriteBatch, Hull hull) + public void Draw(SpriteBatch spriteBatch, Hull hull, float depth) { Vector2 drawPos = position + hull.Rect.Location.ToVector2(); drawPos += hull.Submarine.DrawPosition; drawPos.Y = -drawPos.Y; - spriteBatch.Draw(Sprite.Texture, drawPos, clippedSourceRect, Color * GetAlpha(), 0, Vector2.Zero, scale, SpriteEffects.None, 1); + spriteBatch.Draw(Sprite.Texture, drawPos, clippedSourceRect, Color * GetAlpha(), 0, Vector2.Zero, scale, SpriteEffects.None, depth); } private float GetAlpha()