From 0422beebdeb232feb2a1f7a8dc63890089d99955 Mon Sep 17 00:00:00 2001 From: Regalis Date: Thu, 27 Oct 2016 19:39:07 +0300 Subject: [PATCH] Small optimization: structures that haven't taken damage aren't rendered using the damage shader --- Subsurface/Source/Map/Structure.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Subsurface/Source/Map/Structure.cs b/Subsurface/Source/Map/Structure.cs index 61d04c532..a09161393 100644 --- a/Subsurface/Source/Map/Structure.cs +++ b/Subsurface/Source/Map/Structure.cs @@ -61,6 +61,8 @@ namespace Barotrauma public float lastUpdate; + private bool takenDamage; + public SpriteEffects SpriteEffects = SpriteEffects.None; public bool resizeHorizontal @@ -141,7 +143,7 @@ namespace Barotrauma { get { - return prefab.HasBody; + return takenDamage && prefab.HasBody; } } @@ -753,6 +755,8 @@ namespace Barotrauma bool hadHole = SectionBodyDisabled(sectionIndex); sections[sectionIndex].damage = MathHelper.Clamp(damage, 0.0f, prefab.MaxHealth); + takenDamage = sections.Any(s => s.damage > 0.0f); + bool hasHole = SectionBodyDisabled(sectionIndex); if (hadHole == hasHole) return; @@ -928,6 +932,8 @@ namespace Barotrauma s.sections[index].damage = ToolBox.GetAttributeFloat(subElement, "damage", 0.0f); + s.takenDamage = s.takenDamage || s.sections[index].damage > 0.0f; + s.sections[index].GapID = ToolBox.GetAttributeInt(subElement, "gap", -1); break;