Unstable 1.1.14.0

This commit is contained in:
Markus Isberg
2023-10-02 16:43:54 +03:00
parent 94f5a93a0c
commit cf8f0de659
606 changed files with 21906 additions and 11456 deletions
@@ -88,6 +88,9 @@ namespace Barotrauma.Particles
[Editable, Serialize(false, IsPropertySaveable.Yes, description: "Only relevant for status effects. Makes the emitter copy the angle from the target of the effect instead of the entity applying the effect.")]
public bool CopyTargetAngle { get; set; }
[Editable, Serialize(false, IsPropertySaveable.Yes, description: "Only relevant for particles spawned by another particle. Makes the emitter copy the scale of the parent particle.")]
public bool CopyParentParticleScale { get; set; }
[Editable, Serialize("1,1,1,1", IsPropertySaveable.Yes)]
public Color ColorMultiplier { get; set; }
@@ -195,7 +198,11 @@ namespace Barotrauma.Particles
private void Emit(Vector2 position, Hull hullGuess, float angle, float particleRotation, float velocityMultiplier, float sizeMultiplier, Color? colorMultiplier = null, ParticlePrefab overrideParticle = null, bool mirrorAngle = false, Tuple<Vector2, Vector2> tracerPoints = null)
{
var particlePrefab = overrideParticle ?? Prefab.ParticlePrefab;
if (particlePrefab == null) { return; }
if (particlePrefab == null)
{
DebugConsole.AddWarning($"Could not find the particle prefab \"{Prefab.ParticlePrefabName}\".");
return;
}
Vector2 velocity = Vector2.Zero;
if (!MathUtils.NearlyEqual(Prefab.Properties.VelocityMax * velocityMultiplier, 0.0f) || !MathUtils.NearlyEqual(Prefab.Properties.DistanceMax, 0.0f))
@@ -206,7 +213,7 @@ namespace Barotrauma.Particles
position += dir * Rand.Range(Prefab.Properties.DistanceMin, Prefab.Properties.DistanceMax);
}
var particle = GameMain.ParticleManager.CreateParticle(particlePrefab, position, velocity, particleRotation, hullGuess, lifeTimeMultiplier: Prefab.Properties.LifeTimeMultiplier, tracerPoints: tracerPoints);
var particle = GameMain.ParticleManager.CreateParticle(particlePrefab, position, velocity, particleRotation, hullGuess, particlePrefab.DrawOnTop || Prefab.DrawOnTop, lifeTimeMultiplier: Prefab.Properties.LifeTimeMultiplier, tracerPoints: tracerPoints);
if (particle != null)
{
@@ -227,6 +234,7 @@ namespace Barotrauma.Particles
public Rectangle CalculateParticleBounds(Vector2 startPosition)
{
Rectangle bounds = new Rectangle((int)startPosition.X, (int)startPosition.Y, (int)startPosition.X, (int)startPosition.Y);
if (Prefab.ParticlePrefab == null) { return bounds; }
for (float angle = Prefab.Properties.AngleMinRad; angle <= Prefab.Properties.AngleMaxRad; angle += 0.1f)
{
@@ -255,16 +263,22 @@ namespace Barotrauma.Particles
}
bounds = new Rectangle(bounds.X, bounds.Y, bounds.Width - bounds.X, bounds.Height - bounds.Y);
return bounds;
}
}
class ParticleEmitterPrefab
{
private readonly Identifier particlePrefabName;
public readonly Identifier ParticlePrefabName;
public ParticlePrefab ParticlePrefab => ParticlePrefab.Prefabs[particlePrefabName];
public ParticlePrefab ParticlePrefab
{
get
{
ParticlePrefab.Prefabs.TryGet(ParticlePrefabName, out var prefab);
return prefab;
}
}
public readonly ParticleEmitterProperties Properties;
@@ -273,13 +287,13 @@ namespace Barotrauma.Particles
public ParticleEmitterPrefab(ContentXElement element)
{
Properties = new ParticleEmitterProperties(element);
particlePrefabName = element.GetAttributeIdentifier("particle", "");
ParticlePrefabName = element.GetAttributeIdentifier("particle", "");
}
public ParticleEmitterPrefab(ParticlePrefab prefab, ParticleEmitterProperties properties)
{
Properties = properties;
particlePrefabName = prefab.Identifier;
ParticlePrefabName = prefab.Identifier;
}
}
}