Skip to content

Commit

Permalink
particles now have different IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
saint11 committed Nov 25, 2023
1 parent f4ce5eb commit 93ccd02
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Murder/Core/Particles/Data/EmitterShape.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public Vector2 GetRandomPosition(Random random)
{
case EmitterShapeKind.Point:
// Just return the central point
return Vector2.Zero;
return Vector2.Zero;

case EmitterShapeKind.Line:
// Lerp between the start and the end of the line.
Expand Down
8 changes: 4 additions & 4 deletions src/Murder/Core/Particles/ParticleSystemTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ public ParticleSystemTracker(Emitter emitter, Particle particle, int seed = 0)
/// <param name="allowSpawn">Whether spawning new entities is allowed, e.g. the entity is not deactivated.</param>
/// <param name="emitterPosition">Emitter position in game where the particles are fired from.</param>
/// <returns>Returns whether the emitter is still running.</returns>
public bool Step(bool allowSpawn, Vector2 emitterPosition)
public bool Step(bool allowSpawn, Vector2 emitterPosition, int id)
{
_lastEmitterPosition = emitterPosition;

if (!_hasStarted)
{
Start(emitterPosition);
Start(emitterPosition, id);
}

float dt = Emitter.ScaledTime ? Game.DeltaTime : Game.UnscaledDeltaTime;
Expand Down Expand Up @@ -95,10 +95,10 @@ public bool Step(bool allowSpawn, Vector2 emitterPosition)
return false;
}

public void Start(Vector2 emitterPosition)
public void Start(Vector2 emitterPosition, int id)
{
_hasStarted = true;
_random = new Random((int)(_seed + emitterPosition.X + emitterPosition.Y / 320f));
_random = new Random((int)(_seed + emitterPosition.X + emitterPosition.Y / 320f) + id * 111);

_time = _lastTimeSpawned = 0;
_currentLength = Calculator.RoundToInt(Emitter.Burst.GetValue(_random));
Expand Down
2 changes: 1 addition & 1 deletion src/Murder/Core/Particles/WorldParticleSystemTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public void Step(World world)
{
int entityId = _indexToEntityId[i];
Vector2 position = world.GetEntity(entityId).TryGetMurderTransform()?.GetGlobal()?.Vector2 ?? Vector2.Zero;
_poolTrackers[i].Step(_activeParticleSystems.Contains(entityId), position);
_poolTrackers[i].Step(_activeParticleSystems.Contains(entityId), position, entityId);
}
}

Expand Down

0 comments on commit 93ccd02

Please sign in to comment.