Fixed particles in water being drawn under ruin structures (making it seem like plasma cutters aren't working), fixed all structures having the default health of 100 because of mismatching parameter name (Health vs MaxHealth)

This commit is contained in:
Joonas Rikkonen
2017-12-05 22:30:24 +02:00
parent fd09cb4ef5
commit 0b603ba10b
4 changed files with 40 additions and 62 deletions
@@ -147,7 +147,7 @@ namespace Barotrauma
{ {
if (damageEffect != null) if (damageEffect != null)
{ {
float newCutoff = Math.Min((sections[i].damage / prefab.MaxHealth), 0.65f); float newCutoff = Math.Min((sections[i].damage / prefab.Health), 0.65f);
if (Math.Abs(newCutoff - Submarine.DamageEffectCutoff) > 0.01f) if (Math.Abs(newCutoff - Submarine.DamageEffectCutoff) > 0.01f)
{ {
@@ -128,34 +128,28 @@ namespace Barotrauma
Level.Loaded.DrawBack(graphics, spriteBatch, cam); Level.Loaded.DrawBack(graphics, spriteBatch, cam);
} }
//draw structures that are in water and not part of any sub (e.g. ruins)
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, null, cam.Transform);
Submarine.DrawBack(spriteBatch, false, s => s is Structure && s.Submarine == null);
spriteBatch.End();
//draw alpha blended particles that are in water and behind subs
#if LINUX #if LINUX
spriteBatch.Begin(SpriteSortMode.Deferred, spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, null, DepthStencilState.DepthRead, null, null, cam.Transform);
BlendState.NonPremultiplied,
null, DepthStencilState.DepthRead, null, null,
cam.Transform);
#else #else
spriteBatch.Begin(SpriteSortMode.Deferred, spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, DepthStencilState.DepthRead, null, null, cam.Transform);
BlendState.AlphaBlend,
null, DepthStencilState.DepthRead, null, null,
cam.Transform);
#endif #endif
GameMain.ParticleManager.Draw(spriteBatch, true, false, Particles.ParticleBlendState.AlphaBlend); GameMain.ParticleManager.Draw(spriteBatch, true, false, Particles.ParticleBlendState.AlphaBlend);
spriteBatch.End(); spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Deferred, //draw additive particles that are in water and behind subs
BlendState.Additive, spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, null, DepthStencilState.Default, null, null, cam.Transform);
null, DepthStencilState.Default, null, null,
cam.Transform);
GameMain.ParticleManager.Draw(spriteBatch, true, false, Particles.ParticleBlendState.Additive); GameMain.ParticleManager.Draw(spriteBatch, true, false, Particles.ParticleBlendState.Additive);
spriteBatch.End(); spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.BackToFront, //draw submarine structures that are behind water
BlendState.AlphaBlend, spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, null, cam.Transform);
null, null, null, null, Submarine.DrawBack(spriteBatch, false, s => s is Structure && s.Submarine != null);
cam.Transform);
Submarine.DrawBack(spriteBatch, false, s => s is Structure);
spriteBatch.End(); spriteBatch.End();
graphics.SetRenderTarget(renderTarget); graphics.SetRenderTarget(renderTarget);
@@ -180,29 +174,21 @@ namespace Barotrauma
//draw the rendertarget and particles that are only supposed to be drawn in water into renderTargetWater //draw the rendertarget and particles that are only supposed to be drawn in water into renderTargetWater
graphics.SetRenderTarget(renderTargetWater); graphics.SetRenderTarget(renderTargetWater);
spriteBatch.Begin(SpriteSortMode.Deferred, spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Opaque);
BlendState.Opaque);
spriteBatch.Draw(renderTarget, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), waterColor); spriteBatch.Draw(renderTarget, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), waterColor);
spriteBatch.End(); spriteBatch.End();
//draw alpha blended particles that are inside a sub
#if LINUX #if LINUX
spriteBatch.Begin(SpriteSortMode.Deferred, spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, null, DepthStencilState.DepthRead, null, null, cam.Transform);
BlendState.NonPremultiplied,
null, DepthStencilState.DepthRead, null, null,
cam.Transform);
#else #else
spriteBatch.Begin(SpriteSortMode.Deferred, spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, DepthStencilState.DepthRead, null, null, cam.Transform);
BlendState.AlphaBlend,
null, DepthStencilState.DepthRead, null, null,
cam.Transform);
#endif #endif
GameMain.ParticleManager.Draw(spriteBatch, true, true, Particles.ParticleBlendState.AlphaBlend); GameMain.ParticleManager.Draw(spriteBatch, true, true, Particles.ParticleBlendState.AlphaBlend);
spriteBatch.End(); spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Deferred, //draw additive particles that are inside a sub
BlendState.Additive, spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, null, DepthStencilState.Default, null, null, cam.Transform);
null, DepthStencilState.Default, null, null,
cam.Transform);
GameMain.ParticleManager.Draw(spriteBatch, true, true, Particles.ParticleBlendState.Additive); GameMain.ParticleManager.Draw(spriteBatch, true, true, Particles.ParticleBlendState.Additive);
spriteBatch.End(); spriteBatch.End();
@@ -210,29 +196,21 @@ namespace Barotrauma
//draw the rendertarget and particles that are only supposed to be drawn in air into renderTargetAir //draw the rendertarget and particles that are only supposed to be drawn in air into renderTargetAir
graphics.SetRenderTarget(renderTargetAir); graphics.SetRenderTarget(renderTargetAir);
spriteBatch.Begin(SpriteSortMode.Deferred, spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Opaque);
BlendState.Opaque);
spriteBatch.Draw(renderTarget, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White); spriteBatch.Draw(renderTarget, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
spriteBatch.End(); spriteBatch.End();
#if LINUX
spriteBatch.Begin(SpriteSortMode.Deferred,
BlendState.NonPremultiplied,
null, DepthStencilState.DepthRead, null, null,
cam.Transform);
#else
spriteBatch.Begin(SpriteSortMode.Deferred,
BlendState.AlphaBlend,
null, DepthStencilState.DepthRead, null, null,
cam.Transform);
#endif
//draw alpha blended particles that are not in water
#if LINUX
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, null, DepthStencilState.DepthRead, null, null, cam.Transform);
#else
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, DepthStencilState.DepthRead, null, null, cam.Transform);
#endif
GameMain.ParticleManager.Draw(spriteBatch, false, null, Particles.ParticleBlendState.AlphaBlend); GameMain.ParticleManager.Draw(spriteBatch, false, null, Particles.ParticleBlendState.AlphaBlend);
spriteBatch.End(); spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Deferred, //draw additive particles that are not in water
BlendState.Additive, spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, null, DepthStencilState.DepthRead, null, null, cam.Transform);
null, DepthStencilState.DepthRead, null, null,
cam.Transform);
GameMain.ParticleManager.Draw(spriteBatch, false, null, Particles.ParticleBlendState.Additive); GameMain.ParticleManager.Draw(spriteBatch, false, null, Particles.ParticleBlendState.Additive);
spriteBatch.End(); spriteBatch.End();
@@ -106,7 +106,7 @@ namespace Barotrauma
public float Health public float Health
{ {
get { return prefab.MaxHealth; } get { return prefab.Health; }
} }
public override bool DrawBelowWater public override bool DrawBelowWater
@@ -535,7 +535,7 @@ namespace Barotrauma
{ {
if (sectionIndex < 0 || sectionIndex >= sections.Length) return false; if (sectionIndex < 0 || sectionIndex >= sections.Length) return false;
return (sections[sectionIndex].damage>=prefab.MaxHealth); return (sections[sectionIndex].damage>=prefab.Health);
} }
/// <summary> /// <summary>
@@ -545,7 +545,7 @@ namespace Barotrauma
{ {
if (sectionIndex < 0 || sectionIndex >= sections.Length) return false; if (sectionIndex < 0 || sectionIndex >= sections.Length) return false;
return (sections[sectionIndex].damage >= prefab.MaxHealth*0.5f); return (sections[sectionIndex].damage >= prefab.Health*0.5f);
} }
public int SectionLength(int sectionIndex) public int SectionLength(int sectionIndex)
@@ -686,7 +686,7 @@ namespace Barotrauma
} }
AdjustKarma(attacker, damageDiff); AdjustKarma(attacker, damageDiff);
if (damage < prefab.MaxHealth*0.5f) if (damage < prefab.Health*0.5f)
{ {
if (sections[sectionIndex].gap != null) if (sections[sectionIndex].gap != null)
{ {
@@ -715,11 +715,11 @@ namespace Barotrauma
#endif #endif
} }
sections[sectionIndex].gap.Open = (damage / prefab.MaxHealth - 0.5f) * 2.0f; sections[sectionIndex].gap.Open = (damage / prefab.Health - 0.5f) * 2.0f;
} }
bool hadHole = SectionBodyDisabled(sectionIndex); bool hadHole = SectionBodyDisabled(sectionIndex);
sections[sectionIndex].damage = MathHelper.Clamp(damage, 0.0f, prefab.MaxHealth); sections[sectionIndex].damage = MathHelper.Clamp(damage, 0.0f, prefab.Health);
bool hasHole = SectionBodyDisabled(sectionIndex); bool hasHole = SectionBodyDisabled(sectionIndex);
@@ -10,7 +10,7 @@ namespace Barotrauma
{ {
private bool canSpriteFlipX; private bool canSpriteFlipX;
private float maxHealth; private float health;
//default size //default size
private Vector2 size; private Vector2 size;
@@ -31,10 +31,10 @@ namespace Barotrauma
} }
[Serialize(100.0f, false)] [Serialize(100.0f, false)]
public float MaxHealth public float Health
{ {
get { return maxHealth; } get { return health; }
set { maxHealth = Math.Max(value, 0.0f); } set { health = Math.Max(value, 0.0f); }
} }
[Serialize(false, false)] [Serialize(false, false)]