(6eeea9b7c) v0.9.10.0.0
This commit is contained in:
@@ -10,6 +10,8 @@ namespace Barotrauma.Particles
|
||||
{
|
||||
private ParticlePrefab prefab;
|
||||
|
||||
private string debugName = "Particle (uninitialized)";
|
||||
|
||||
public delegate void OnChangeHullHandler(Vector2 position, Hull currentHull);
|
||||
public OnChangeHullHandler OnChangeHull;
|
||||
|
||||
@@ -92,10 +94,16 @@ namespace Barotrauma.Particles
|
||||
{
|
||||
get { return prefab; }
|
||||
}
|
||||
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return debugName;
|
||||
}
|
||||
|
||||
public void Init(ParticlePrefab prefab, Vector2 position, Vector2 speed, float rotation, Hull hullGuess = null, bool drawOnTop = false)
|
||||
{
|
||||
this.prefab = prefab;
|
||||
debugName = $"Particle ({prefab.Name})";
|
||||
|
||||
spriteIndex = Rand.Int(prefab.Sprites.Count);
|
||||
|
||||
|
||||
@@ -89,7 +89,21 @@ namespace Barotrauma.Particles
|
||||
{
|
||||
public readonly string Name;
|
||||
|
||||
public readonly ParticlePrefab ParticlePrefab;
|
||||
private string particlePrefabName;
|
||||
|
||||
private ParticlePrefab particlePrefab;
|
||||
public ParticlePrefab ParticlePrefab
|
||||
{
|
||||
get
|
||||
{
|
||||
if (particlePrefab == null && particlePrefabName != null)
|
||||
{
|
||||
particlePrefab = GameMain.ParticleManager?.FindPrefab(particlePrefabName);
|
||||
if (particlePrefab == null) { particlePrefabName = null; }
|
||||
}
|
||||
return particlePrefab;
|
||||
}
|
||||
}
|
||||
|
||||
public readonly float AngleMin, AngleMax;
|
||||
|
||||
@@ -114,8 +128,7 @@ namespace Barotrauma.Particles
|
||||
public ParticleEmitterPrefab(XElement element)
|
||||
{
|
||||
Name = element.Name.ToString();
|
||||
|
||||
ParticlePrefab = GameMain.ParticleManager.FindPrefab(element.GetAttributeString("particle", ""));
|
||||
particlePrefabName = element.GetAttributeString("particle", "");
|
||||
|
||||
if (element.Attribute("startrotation") == null)
|
||||
{
|
||||
|
||||
@@ -120,13 +120,13 @@ namespace Barotrauma.Particles
|
||||
return CreateParticle(prefabName, position, new Vector2((float)Math.Cos(angle), (float)-Math.Sin(angle)) * speed, angle, hullGuess);
|
||||
}
|
||||
|
||||
public Particle CreateParticle(string prefabName, Vector2 position, Vector2 velocity, float rotation=0.0f, Hull hullGuess = null)
|
||||
public Particle CreateParticle(string prefabName, Vector2 position, Vector2 velocity, float rotation = 0.0f, Hull hullGuess = null)
|
||||
{
|
||||
ParticlePrefab prefab = FindPrefab(prefabName);
|
||||
|
||||
if (prefab == null)
|
||||
{
|
||||
DebugConsole.ThrowError("Particle prefab \"" + prefabName+"\" not found!");
|
||||
DebugConsole.ThrowError("Particle prefab \"" + prefabName + "\" not found!");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ namespace Barotrauma.Particles
|
||||
|
||||
public Particle CreateParticle(ParticlePrefab prefab, Vector2 position, Vector2 velocity, float rotation = 0.0f, Hull hullGuess = null, bool drawOnTop = false)
|
||||
{
|
||||
if (particleCount >= MaxParticles || prefab == null) return null;
|
||||
if (particleCount >= MaxParticles || prefab == null || prefab.Sprites.Count == 0) { return null; }
|
||||
|
||||
Vector2 particleEndPos = prefab.CalculateEndPosition(position, velocity);
|
||||
|
||||
@@ -144,8 +144,8 @@ namespace Barotrauma.Particles
|
||||
|
||||
Rectangle expandedViewRect = MathUtils.ExpandRect(cam.WorldView, MaxOutOfViewDist);
|
||||
|
||||
if (minPos.X > expandedViewRect.Right || maxPos.X < expandedViewRect.X) return null;
|
||||
if (minPos.Y > expandedViewRect.Y || maxPos.Y < expandedViewRect.Y - expandedViewRect.Height) return null;
|
||||
if (minPos.X > expandedViewRect.Right || maxPos.X < expandedViewRect.X) { return null; }
|
||||
if (minPos.Y > expandedViewRect.Y || maxPos.Y < expandedViewRect.Y - expandedViewRect.Height) { return null; }
|
||||
|
||||
if (particles[particleCount] == null) particles[particleCount] = new Particle();
|
||||
|
||||
|
||||
@@ -255,6 +255,11 @@ namespace Barotrauma.Particles
|
||||
}
|
||||
}
|
||||
|
||||
if (Sprites.Count == 0)
|
||||
{
|
||||
DebugConsole.ThrowError($"Particle prefab \"{Name}\" in the file \"{file}\" has no sprites defined!");
|
||||
}
|
||||
|
||||
//if velocity change in water is not given, it defaults to the normal velocity change
|
||||
if (element.Attribute("velocitychangewater") == null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user