From 505b4f5f1a27b81bea35878cfbecfacb44ddaa3d Mon Sep 17 00:00:00 2001 From: Regalis Date: Thu, 3 Nov 2016 18:24:03 +0200 Subject: [PATCH] The sprites of structures with no body are flipped correctly --- Subsurface/Source/Map/Structure.cs | 41 +++++++++++++++++------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/Subsurface/Source/Map/Structure.cs b/Subsurface/Source/Map/Structure.cs index 8dce85657..bbdba3e63 100644 --- a/Subsurface/Source/Map/Structure.cs +++ b/Subsurface/Source/Map/Structure.cs @@ -288,32 +288,39 @@ namespace Barotrauma private void CreateSections() { int xsections = 1, ysections = 1; - int width, height; + int width = rect.Width, height = rect.Height; if (!HasBody) - { - sections = new WallSection[1]; - sections[0] = new WallSection(rect); - return; - - } + { + if (flippedX && isHorizontal) + { + xsections = (int)Math.Ceiling((float)rect.Width / prefab.sprite.SourceRect.Width); + width = prefab.sprite.SourceRect.Width; - if (isHorizontal) - { - xsections = (int)Math.Ceiling((float)rect.Width / wallSectionSize); + } + else + { + xsections = 1; + ysections = 1; + } sections = new WallSection[xsections]; - width = (int)wallSectionSize; - height = rect.Height; } else { - ysections = (int)Math.Ceiling((float)rect.Height / wallSectionSize); - sections = new WallSection[ysections]; - width = rect.Width; - height = (int)wallSectionSize; + if (isHorizontal) + { + xsections = (int)Math.Ceiling((float)rect.Width / wallSectionSize); + sections = new WallSection[xsections]; + width = (int)wallSectionSize; + } + else + { + ysections = (int)Math.Ceiling((float)rect.Height / wallSectionSize); + sections = new WallSection[ysections]; + width = rect.Width; + } } - for (int x = 0; x < xsections; x++) { for (int y = 0; y < ysections; y++)