PointProfile.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233
  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 Microsoft.Xna.Framework;
  5. namespace MonoGame.Extended.Particles.Profiles;
  6. /// <summary>
  7. /// A profile that emits all particles from a single point with random headings.
  8. /// </summary>
  9. /// <remarks>
  10. /// The <see cref="PointProfile"/> is the simplest emission profile, where all particles originate exactly at the
  11. /// emitter position with no offset. Each particle is given a random heading in any direction, creating a radial
  12. /// dispersion pattern.
  13. /// </remarks>
  14. public sealed class PointProfile : Profile
  15. {
  16. /// <summary>
  17. /// Computes the offset and heading for a new particle.
  18. /// </summary>
  19. /// <param name="offset">A pointer to the Vector2 where the offset from the emitter position will be stored.</param>
  20. /// <param name="heading">A pointer to the Vector2 where the unit direction vector will be stored.</param>
  21. /// <remarks>
  22. /// The offset is always set to (0,0), meaning particles will spawn exactly at the emitter position.
  23. /// </remarks>
  24. public override unsafe void GetOffsetAndHeading(Vector2* offset, Vector2* heading)
  25. {
  26. offset->X = 0.0f;
  27. offset->Y = 0.0f;
  28. FastRandom.Shared.NextUnitVector(heading);
  29. }
  30. }