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

View File

@@ -147,7 +147,7 @@ namespace Barotrauma
{
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)
{

View File

@@ -128,34 +128,28 @@ namespace Barotrauma
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
spriteBatch.Begin(SpriteSortMode.Deferred,
BlendState.NonPremultiplied,
null, DepthStencilState.DepthRead, null, null,
cam.Transform);
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);
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, DepthStencilState.DepthRead, null, null, cam.Transform);
#endif
GameMain.ParticleManager.Draw(spriteBatch, true, false, Particles.ParticleBlendState.AlphaBlend);
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Deferred,
BlendState.Additive,
null, DepthStencilState.Default, null, null,
cam.Transform);
//draw additive particles that are in water and behind subs
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, null, DepthStencilState.Default, null, null, cam.Transform);
GameMain.ParticleManager.Draw(spriteBatch, true, false, Particles.ParticleBlendState.Additive);
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.BackToFront,
BlendState.AlphaBlend,
null, null, null, null,
cam.Transform);
Submarine.DrawBack(spriteBatch, false, s => s is Structure);
//draw submarine structures that are behind water
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();
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
graphics.SetRenderTarget(renderTargetWater);
spriteBatch.Begin(SpriteSortMode.Deferred,
BlendState.Opaque);
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Opaque);
spriteBatch.Draw(renderTarget, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), waterColor);
spriteBatch.End();
//draw alpha blended particles that are inside a sub
#if LINUX
spriteBatch.Begin(SpriteSortMode.Deferred,
BlendState.NonPremultiplied,
null, DepthStencilState.DepthRead, null, null,
cam.Transform);
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);
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, DepthStencilState.DepthRead, null, null, cam.Transform);
#endif
GameMain.ParticleManager.Draw(spriteBatch, true, true, Particles.ParticleBlendState.AlphaBlend);
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Deferred,
BlendState.Additive,
null, DepthStencilState.Default, null, null,
cam.Transform);
//draw additive particles that are inside a sub
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, null, DepthStencilState.Default, null, null, cam.Transform);
GameMain.ParticleManager.Draw(spriteBatch, true, true, Particles.ParticleBlendState.Additive);
spriteBatch.End();
@@ -210,29 +196,21 @@ namespace Barotrauma
//draw the rendertarget and particles that are only supposed to be drawn in air into renderTargetAir
graphics.SetRenderTarget(renderTargetAir);
spriteBatch.Begin(SpriteSortMode.Deferred,
BlendState.Opaque);
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Opaque);
spriteBatch.Draw(renderTarget, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
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);
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Deferred,
BlendState.Additive,
null, DepthStencilState.DepthRead, null, null,
cam.Transform);
//draw additive particles that are not in water
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, null, DepthStencilState.DepthRead, null, null, cam.Transform);
GameMain.ParticleManager.Draw(spriteBatch, false, null, Particles.ParticleBlendState.Additive);
spriteBatch.End();

View File

@@ -106,7 +106,7 @@ namespace Barotrauma
public float Health
{
get { return prefab.MaxHealth; }
get { return prefab.Health; }
}
public override bool DrawBelowWater
@@ -535,7 +535,7 @@ namespace Barotrauma
{
if (sectionIndex < 0 || sectionIndex >= sections.Length) return false;
return (sections[sectionIndex].damage>=prefab.MaxHealth);
return (sections[sectionIndex].damage>=prefab.Health);
}
/// <summary>
@@ -545,7 +545,7 @@ namespace Barotrauma
{
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)
@@ -686,7 +686,7 @@ namespace Barotrauma
}
AdjustKarma(attacker, damageDiff);
if (damage < prefab.MaxHealth*0.5f)
if (damage < prefab.Health*0.5f)
{
if (sections[sectionIndex].gap != null)
{
@@ -715,11 +715,11 @@ namespace Barotrauma
#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);
sections[sectionIndex].damage = MathHelper.Clamp(damage, 0.0f, prefab.MaxHealth);
sections[sectionIndex].damage = MathHelper.Clamp(damage, 0.0f, prefab.Health);
bool hasHole = SectionBodyDisabled(sectionIndex);

View File

@@ -10,7 +10,7 @@ namespace Barotrauma
{
private bool canSpriteFlipX;
private float maxHealth;
private float health;
//default size
private Vector2 size;
@@ -31,10 +31,10 @@ namespace Barotrauma
}
[Serialize(100.0f, false)]
public float MaxHealth
public float Health
{
get { return maxHealth; }
set { maxHealth = Math.Max(value, 0.0f); }
get { return health; }
set { health = Math.Max(value, 0.0f); }
}
[Serialize(false, false)]