// Copyright (c) Craftwork Games. All rights reserved. // Licensed under the MIT license. // See LICENSE file in the project root for full license information. using MonoGame.Extended.Particles.Data; namespace MonoGame.Extended.Particles.Modifiers; /// /// A modifier that applies a constant rotational velocity to particles. /// /// /// The changes the orientation of particles over time /// by applying a continuous rotation at a specified rate. /// /// The rotation is applied uniformly to all particles, but can be combined with other modifiers /// to create more complex behaviors. For non-uniform rotation, consider using multiple particle /// emitters with different rotation rates or implementing a custom modifier. /// public class RotationModifier : Modifier { /// /// Gets or sets the rate at which particles rotate, in radians per second. /// /// /// Positive values cause clockwise rotation, while negative values cause /// counter-clockwise rotation. /// public float RotationRate { get; set; } /// /// Updates all particles by applying rotation based on the elapsed time. /// /// protected internal override unsafe void Update(float elapsedSeconds, ParticleIterator iterator, int particleCount) { if (!Enabled) { return; } float rotationRateDelta = RotationRate * elapsedSeconds; for (int i = 0; i < particleCount && iterator.HasNext; i++) { Particle* particle = iterator.Next(); particle->Rotation += rotationRateDelta; } } }