RotationInterpolator.cs 1.2 KB

123456789101112131415161718192021222324252627282930
  1. // Copyright (c) Craftwork Games. All rights reserved.
  2. // Licensed under the MIT license.
  3. // See LICENSE file in the project root for full license information.
  4. using MonoGame.Extended.Particles.Data;
  5. namespace MonoGame.Extended.Particles.Modifiers.Interpolators;
  6. /// <summary>
  7. /// An interpolator that gradually changes the rotation angle of particles over their lifetime.
  8. /// </summary>
  9. /// <remarks>
  10. /// The <see cref="RotationInterpolator"/> transitions a particle's rotation value from the inherited
  11. /// <see cref="Interpolator{T}.StartValue"/> to <see cref="Interpolator{T}.EndValue"/> based on the
  12. /// provided interpolation amount.
  13. /// </remarks>
  14. public class RotationInterpolator : Interpolator<float>
  15. {
  16. /// <summary>
  17. /// Updates a particle's rotation by interpolating between the start and end values.
  18. /// </summary>
  19. /// <param name="amount">The normalized interpolation amount (from 0.0 to 1.0).</param>
  20. /// <param name="particle">A pointer to the particle to update.</param>
  21. public override unsafe void Update(float amount, Particle* particle)
  22. {
  23. if (!Enabled) { return; }
  24. particle->Rotation = StartValue + (EndValue - StartValue) * amount;
  25. }
  26. }