Unstable 1.8.4.0

This commit is contained in:
Markus Isberg
2025-03-12 12:56:27 +00:00
parent a4c3e868e4
commit a4a3427e4e
627 changed files with 29860 additions and 10018 deletions
@@ -11,6 +11,13 @@ namespace Barotrauma.Particles
AlphaBlend, Additive//, Distortion
}
enum ParticleDrawOrder
{
Default,
Foreground,
Background
}
class ParticleManager
{
private const int MaxOutOfViewDist = 500;
@@ -91,11 +98,14 @@ namespace Barotrauma.Particles
return CreateParticle(prefab, position, velocity, rotation, hullGuess, collisionIgnoreTimer: collisionIgnoreTimer, tracerPoints:tracerPoints);
}
public Particle CreateParticle(ParticlePrefab prefab, Vector2 position, Vector2 velocity, float rotation = 0.0f, Hull hullGuess = null, bool drawOnTop = false, float collisionIgnoreTimer = 0f, float lifeTimeMultiplier = 1f, Tuple<Vector2, Vector2> tracerPoints = null)
public Particle CreateParticle(ParticlePrefab prefab, Vector2 position, Vector2 velocity, float rotation = 0.0f, Hull hullGuess = null, ParticleDrawOrder drawOrder = ParticleDrawOrder.Default, float collisionIgnoreTimer = 0f, float lifeTimeMultiplier = 1f, Tuple<Vector2, Vector2> tracerPoints = null)
{
if (prefab == null || prefab.Sprites.Count == 0) { return null; }
if (particleCount >= MaxParticles)
{
//maximum number of particles reached, and this is not a high-prio particle or something that should always draw
// -> the particle won't be created, we can return early
if (particleCount >= MaxParticles && prefab.Priority == 0 && !prefab.DrawAlways) { return null; }
for (int i = 0; i < particleCount; i++)
{
if (particles[i].Prefab.Priority < prefab.Priority ||
@@ -134,7 +144,7 @@ namespace Barotrauma.Particles
if (particles[particleCount] == null) { particles[particleCount] = new Particle(); }
Particle particle = particles[particleCount];
particle.Init(prefab, position, velocity, rotation, hullGuess, drawOnTop, collisionIgnoreTimer, lifeTimeMultiplier, tracerPoints: tracerPoints);
particle.Init(prefab, position, velocity, rotation, hullGuess, drawOrder, collisionIgnoreTimer, lifeTimeMultiplier, tracerPoints: tracerPoints);
particleCount++;
particlesInCreationOrder.AddFirst(particle);
@@ -213,7 +223,7 @@ namespace Barotrauma.Particles
return activeParticles;
}
public void Draw(SpriteBatch spriteBatch, bool inWater, bool? inSub, ParticleBlendState blendState)
public void Draw(SpriteBatch spriteBatch, bool inWater, bool? inSub, ParticleBlendState blendState, bool? background = false)
{
ParticlePrefab.DrawTargetType drawTarget = inWater ? ParticlePrefab.DrawTargetType.Water : ParticlePrefab.DrawTargetType.Air;
@@ -225,12 +235,16 @@ namespace Barotrauma.Particles
if (inSub.HasValue)
{
bool isOutside = particle.CurrentHull == null;
if (!particle.DrawOnTop && isOutside == inSub.Value)
if (particle.DrawOrder != ParticleDrawOrder.Foreground && isOutside == inSub.Value)
{
continue;
}
}
if (background.HasValue)
{
bool isBackgroundParticle = particle.DrawOrder == ParticleDrawOrder.Background;
if (background.Value != isBackgroundParticle) { continue; }
}
particle.Draw(spriteBatch);
}
}