Interpolator.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. /// Represents a base class for all particle interpolators.
  8. /// </summary>
  9. /// <remarks>
  10. /// Interpolators are specialized modifiers that gradually change particle properties
  11. /// based on a normalized time value (between 0.0 and 1.0) over the particle's lifetime.
  12. /// This enables smooth transitions between initial and final states, such as color fades,
  13. /// size changes, or opacity adjustments.
  14. /// </remarks>
  15. public abstract class Interpolator
  16. {
  17. /// <summary>
  18. /// Gets or sets the display name of this interpolator.
  19. /// </summary>
  20. public string Name;
  21. /// <summary>
  22. /// Indicates if this interpolator is enabled.
  23. /// </summary>
  24. /// <remarks>
  25. /// This value determines if this interpolator is enabled. When an interpolator is disabled, the interpolator is
  26. /// not applied to the modifier.
  27. /// </remarks>
  28. public bool Enabled;
  29. /// <summary>
  30. /// Initializes a new instance of the <see cref="Interpolator"/> class.
  31. /// </summary>
  32. protected Interpolator()
  33. {
  34. Name = GetType().Name;
  35. Enabled = true;
  36. }
  37. /// <summary>
  38. /// Updates a single particle property based on the interpolation amount.
  39. /// </summary>
  40. /// <param name="amount">The normalized interpolation amount (from 0.0 to 1.0).</param>
  41. /// <param name="particle">A pointer to the particle to update.</param>
  42. /// <remarks>
  43. /// This method is called for each particle during its lifetime. The <paramref name="amount"/>
  44. /// parameter represents the particle's age as a fraction of its total lifespan.
  45. /// </remarks>
  46. public abstract unsafe void Update(float amount, Particle* particle);
  47. }