v1.6.17.0 (Unto the Breach update)

This commit is contained in:
Regalis11
2024-10-22 17:29:04 +03:00
parent e74b3cdb17
commit 6e6c17e100
417 changed files with 17166 additions and 5870 deletions
@@ -72,7 +72,7 @@ namespace Barotrauma.Particles
public float VelocityChangeMultiplier;
public bool DrawOnTop { get; private set; }
public ParticleDrawOrder DrawOrder { get; private set; }
public ParticlePrefab.DrawTargetType DrawTarget
{
@@ -110,7 +110,7 @@ namespace Barotrauma.Particles
{
return debugName;
}
public void Init(ParticlePrefab prefab, Vector2 position, Vector2 speed, float rotation, Hull hullGuess = null, bool drawOnTop = false, float collisionIgnoreTimer = 0f, float lifeTimeMultiplier = 1f, Tuple<Vector2, Vector2> tracerPoints = null)
public void Init(ParticlePrefab prefab, Vector2 position, Vector2 speed, float rotation, Hull hullGuess = null, ParticleDrawOrder drawOrder = ParticleDrawOrder.Default, float collisionIgnoreTimer = 0f, float lifeTimeMultiplier = 1f, Tuple<Vector2, Vector2> tracerPoints = null)
{
this.prefab = prefab;
#if DEBUG
@@ -205,7 +205,7 @@ namespace Barotrauma.Particles
prevRotation = rotation;
}
DrawOnTop = drawOnTop;
DrawOrder = drawOrder;
this.collisionIgnoreTimer = collisionIgnoreTimer;
}
@@ -8,6 +8,7 @@ namespace Barotrauma.Particles
{
class ParticleEmitterProperties : ISerializableEntity
{
private const float MinValue = int.MinValue,
MaxValue = int.MaxValue;
@@ -98,8 +99,8 @@ namespace Barotrauma.Particles
[Editable, Serialize(1f, IsPropertySaveable.Yes)]
public float LifeTimeMultiplier { get; set; }
[Editable, Serialize(false, IsPropertySaveable.Yes)]
public bool DrawOnTop { get; set; }
[Editable, Serialize(ParticleDrawOrder.Default, IsPropertySaveable.Yes)]
public ParticleDrawOrder DrawOrder { get; set; }
[Serialize(0f, IsPropertySaveable.Yes)]
public float Angle
@@ -127,6 +128,12 @@ namespace Barotrauma.Particles
public ParticleEmitterProperties(XElement element)
{
SerializableProperties = SerializableProperty.DeserializeProperties(this, element);
//backwards compatibility
if (element.GetAttributeBool("drawontop", false))
{
DrawOrder = ParticleDrawOrder.Foreground;
}
}
}
@@ -215,7 +222,9 @@ namespace Barotrauma.Particles
position += dir * Rand.Range(Prefab.Properties.DistanceMin, Prefab.Properties.DistanceMax);
}
var particle = GameMain.ParticleManager.CreateParticle(particlePrefab, position, velocity, particleRotation, hullGuess, particlePrefab.DrawOnTop || Prefab.DrawOnTop, lifeTimeMultiplier: Prefab.Properties.LifeTimeMultiplier, tracerPoints: tracerPoints);
var particle = GameMain.ParticleManager.CreateParticle(particlePrefab, position, velocity, particleRotation, hullGuess,
particlePrefab.DrawOrder != ParticleDrawOrder.Default ? particlePrefab.DrawOrder : Prefab.DrawOrder,
lifeTimeMultiplier: Prefab.Properties.LifeTimeMultiplier, tracerPoints: tracerPoints);
if (particle != null)
{
@@ -286,7 +295,9 @@ namespace Barotrauma.Particles
public readonly ContentPackage? ContentPackage;
public bool DrawOnTop => Properties.DrawOnTop || ParticlePrefab is { DrawOnTop: true };
public ParticleDrawOrder DrawOrder => Properties.DrawOrder != ParticleDrawOrder.Default ?
Properties.DrawOrder :
(ParticlePrefab?.DrawOrder ?? ParticleDrawOrder.Default);
public ParticleEmitterPrefab(ContentXElement element)
{
@@ -11,6 +11,13 @@ namespace Barotrauma.Particles
AlphaBlend, Additive//, Distortion
}
enum ParticleDrawOrder
{
Default,
Foreground,
Background
}
class ParticleManager
{
private const int MaxOutOfViewDist = 500;
@@ -91,7 +98,7 @@ 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)
@@ -134,7 +141,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 +220,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 +232,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);
}
}
@@ -151,7 +151,7 @@ namespace Barotrauma.Particles
public float Friction { get; private set; }
[Editable(0.0f, 1.0f)]
[Serialize(0.5f, IsPropertySaveable.No, description: "How much of the particle's velocity is conserved when it collides with something, i.e. the \"bounciness\" of the particle. (1.0 = the particle stops completely).")]
[Serialize(0.5f, IsPropertySaveable.No, description: "How much of the particle's velocity is conserved when it collides with something, i.e. the \"bounciness\" of the particle. (0.0 = the particle stops completely).")]
public float Restitution { get; private set; }
//size -----------------------------------------
@@ -188,8 +188,8 @@ namespace Barotrauma.Particles
[Editable, Serialize(DrawTargetType.Air, IsPropertySaveable.No, description: "Should the particle be rendered in air, water or both.")]
public DrawTargetType DrawTarget { get; private set; }
[Editable, Serialize(false, IsPropertySaveable.No, description: "Should the particle be always rendered on top of entities?")]
public bool DrawOnTop { get; private set; }
[Editable, Serialize(ParticleDrawOrder.Default, IsPropertySaveable.No, description: "Should the particle be always forced to render on top of entities or behind everything?")]
public ParticleDrawOrder DrawOrder { get; private set; }
[Editable, Serialize(false, IsPropertySaveable.No, description: "Draw the particle even when it's calculated to be outside of view (the formula doesn't take scales into account). ")]
public bool DrawAlways { get; private set; }
@@ -226,6 +226,16 @@ namespace Barotrauma.Particles
SerializableProperties = SerializableProperty.DeserializeProperties(this, element);
//backwards compatibility
if (element.GetAttributeBool("drawontop", false))
{
DrawOrder = ParticleDrawOrder.Foreground;
}
if (BlendState == ParticleBlendState.Additive && DrawOrder == ParticleDrawOrder.Background)
{
DebugConsole.AddWarning($"Error in particle prefab {Identifier}: additive particles cannot be rendered in the background.");
}
foreach (var subElement in element.Elements())
{
switch (subElement.Name.ToString().ToLowerInvariant())