Particle system improvements:

- particles can collide with the outer walls of the sub
- drag + waterdrag parameters
- fixed particles "twitching" when the submarine is moving fast
- submarine velocity only affects the initial velocity of the particles (i.e. accelerating the sub doesn't automatically accelerate them)
This commit is contained in:
Regalis
2016-09-21 19:45:20 +03:00
parent b01b52172a
commit 721f4ff5a6
10 changed files with 230 additions and 68 deletions

View File

@@ -537,8 +537,22 @@ namespace Barotrauma
if (sectionIndex < 0 || sectionIndex > sections.Length - 1) return;
if (GameMain.Client == null) SetDamage(sectionIndex, sections[sectionIndex].damage + damage);
var section = sections[sectionIndex];
int particleAmount = (int)(Math.Min(Health - section.damage, damage) * Rand.Range(0.1f, 1.0f));
for (int i = 0; i < particleAmount; i++)
{
Vector2 particlePos = new Vector2(
Rand.Range(section.rect.X, section.rect.Right),
Rand.Range(section.rect.Y - section.rect.Height, section.rect.Y));
if (Submarine != null) particlePos += Submarine.DrawPosition;
var particle = GameMain.ParticleManager.CreateParticle("shrapnel", particlePos, Rand.Vector(Rand.Range(1.0f, 50.0f)));
if (particle == null) break;
}
if (GameMain.Client == null) SetDamage(sectionIndex, section.damage + damage);
}
public int FindSectionIndex(Vector2 displayPos)