Positioning out-of-sub particles relative to the level, easier to climb stairs
This commit is contained in:
@@ -73,6 +73,9 @@ namespace Barotrauma.Particles
|
||||
|
||||
spriteIndex = Rand.Int(prefab.Sprites.Count);
|
||||
|
||||
currentHull = Hull.FindHull(position, hullGuess);
|
||||
if (currentHull == null) position = Submarine.Loaded == null ? position : position + Submarine.Loaded.Position;
|
||||
|
||||
this.position = position;
|
||||
prevPosition = position;
|
||||
|
||||
@@ -102,8 +105,6 @@ namespace Barotrauma.Particles
|
||||
|
||||
if (prefab.DeleteOnCollision || prefab.CollidesWithWalls)
|
||||
{
|
||||
currentHull = Hull.FindHull(position, hullGuess);
|
||||
|
||||
hullGaps = currentHull==null ? new List<Gap>() : currentHull.FindGaps();
|
||||
//hullLimits = new List<Hull>();
|
||||
//hullLimits = FindLimits(position);
|
||||
@@ -253,7 +254,6 @@ namespace Barotrauma.Particles
|
||||
public void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
drawPosition = Physics.Interpolate(prevPosition, position);
|
||||
drawPosition.Y = -drawPosition.Y;
|
||||
float drawRotation = Physics.Interpolate(prevRotation, rotation);
|
||||
|
||||
//drawPosition = ConvertUnits.ToDisplayUnits(drawPosition);
|
||||
@@ -263,10 +263,14 @@ namespace Barotrauma.Particles
|
||||
if (prefab.GrowTime>0.0f && totalLifeTime-lifeTime < prefab.GrowTime)
|
||||
{
|
||||
drawSize *= ((totalLifeTime - lifeTime) / prefab.GrowTime);
|
||||
|
||||
}
|
||||
|
||||
prefab.Sprites[spriteIndex].Draw(spriteBatch, drawPosition, color * alpha,
|
||||
Vector2 screenSpacePos = currentHull == null && Submarine.Loaded != null ? drawPosition - Submarine.Loaded.Position : drawPosition;
|
||||
screenSpacePos.Y = -screenSpacePos.Y;
|
||||
|
||||
prefab.Sprites[spriteIndex].Draw(spriteBatch,
|
||||
screenSpacePos,
|
||||
color * alpha,
|
||||
prefab.Sprites[spriteIndex].origin, drawRotation,
|
||||
drawSize, SpriteEffects.None, prefab.Sprites[spriteIndex].Depth);
|
||||
|
||||
|
||||
@@ -51,14 +51,14 @@ namespace Barotrauma.Particles
|
||||
ParticleAmount = ToolBox.GetAttributeInt(element, "particleamount", 1);
|
||||
}
|
||||
|
||||
public void Emit(Vector2 position)
|
||||
public void Emit(Vector2 position, Hull hullGuess = null)
|
||||
{
|
||||
for (int i = 0; i<ParticleAmount; i++)
|
||||
{
|
||||
float angle = Rand.Range(AngleMin, AngleMax);
|
||||
Vector2 velocity = new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)) * Rand.Range(VelocityMin, VelocityMax);
|
||||
|
||||
GameMain.ParticleManager.CreateParticle(particlePrefab, position, velocity);
|
||||
GameMain.ParticleManager.CreateParticle(particlePrefab, position, velocity, 0.0f, hullGuess);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,9 +47,9 @@ namespace Barotrauma.Particles
|
||||
}
|
||||
}
|
||||
|
||||
public Particle CreateParticle(string prefabName, Vector2 position, float angle, float speed)
|
||||
public Particle CreateParticle(string prefabName, Vector2 position, float angle, float speed, Hull hullGuess = null)
|
||||
{
|
||||
return CreateParticle(prefabName, position, new Vector2((float)Math.Cos(angle), (float)-Math.Sin(angle)) * speed, angle);
|
||||
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 speed, float rotation=0.0f, Hull hullGuess = null)
|
||||
|
||||
Reference in New Issue
Block a user