// Copyright (c) Craftwork Games. All rights reserved.
// Licensed under the MIT license.
// See LICENSE file in the project root for full license information.
using Microsoft.Xna.Framework;
namespace MonoGame.Extended.Particles.Profiles;
///
/// A profile that randomly distributes particles throughout a rectangular area.
///
///
/// The generates random positions within a rectangle centered the emitter's position, with
/// random unit vector headings. This creates a uniform distribution of particles across the defined area, with
/// particles moving in all directions.
///
public sealed class BoxFillProfile : Profile
{
///
/// Gets or sets the width of the rectangular area.
///
public float Width { get; set; }
///
/// Gets or sets the height of the rectangular area.
///
public float Height { get; set; }
///
/// Computes the offset and heading for a new particle.
///
/// A pointer to the Vector2 where the offset from the emitter position will be stored.
/// A pointer to the Vector2 where the unit direction vector will be stored.
public override unsafe void GetOffsetAndHeading(Vector2* offset, Vector2* heading)
{
offset->X = FastRandom.Shared.NextSingle(Width * -0.5f, Width * 0.5f);
offset->Y = FastRandom.Shared.NextSingle(Height * -0.5f, Height * 0.5f);
FastRandom.Shared.NextUnitVector(heading);
}
}