// 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; using Microsoft.Xna.Framework.Graphics; namespace MonoGame.Extended.Particles.Profiles; /// /// Provides an abstract base class for particle emission profiles. /// /// /// A profile determines how particles are initially positioned and directed when they are emitted. Different profiles /// create different distribution patterns, such as points, lines, circles, or boxes. /// public abstract class Profile { /// /// 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 abstract unsafe void GetOffsetAndHeading(Vector2* offset, Vector2* heading); /// /// Creates a that emits particles from a single point. /// /// A new instance. public static Profile Point() { return new PointProfile(); } /// /// Creates a that emits particles along a line segment. /// /// The direction vector of the line. /// The length of the line segment. /// A new instance. public static Profile Line(Vector2 axis, float length) { return new LineProfile { Axis = axis, Length = length }; } /// /// Creates a that emits particles along a line segment. /// /// The direction vector of the line. /// The length of the line segment. /// The radiation mode that determines how particle headings are calculated. /// A new instance. public static Profile Line(Vector2 axis, float length, LineRadiation radiate) { return new LineProfile { Axis = axis, Length = length, Radiate = radiate, Direction = Vector2.Zero }; } /// /// Creates a that emits particles along a line segment. /// /// The direction vector of the line. /// The length of the line segment. /// The radiation mode that determines how particle headings are calculated. /// /// The emission direction vector used when is /// or as a scale factor when is or /// . /// /// A new instance. public static Profile Line(Vector2 axis, float length, LineRadiation radiate, Vector2 direction) { return new LineProfile { Axis = axis, Length = length, Radiate = radiate, Direction = direction }; } /// /// Creates a that emits particles from the perimeter of a circle. /// /// The radius of the ring. /// The radiation pattern for particle headings. /// A new instance. public static Profile Ring(float radius, CircleRadiation radiate) { return new RingProfile { Radius = radius, Radiate = radiate }; } /// /// Creates a that emits particles from the perimeter of a rectangle. /// /// The width of the rectangle. /// The height of the rectangle. /// A new instance. public static Profile Box(float width, float height) { return new BoxProfile { Width = width, Height = height }; } /// /// Creates a that emits particles from within a rectangular area. /// /// The width of the rectangle. /// The height of the rectangle. /// A new instance. public static Profile BoxFill(float width, float height) { return new BoxFillProfile { Width = width, Height = height }; } /// /// Creates a that emits particles from the perimeter of a rectangle with uniform density. /// /// The width of the rectangle. /// The height of the rectangle. /// A new instance. public static Profile BoxUniform(float width, float height) { return new BoxUniformProfile { Width = width, Height = height }; } /// /// Creates a that emits particles from within a circular area. /// /// The radius of the circle. /// The radiation pattern for particle headings. /// A new instance. public static Profile Circle(float radius, CircleRadiation radiate) { return new CircleProfile { Radius = radius, Radiate = radiate }; } /// /// Creates a that emits particles in a directional cone. /// /// The central direction of the spray. /// The angular spread of the spray, in radians. /// A new instance. public static Profile Spray(Vector2 direction, float spread) { return new SprayProfile { Direction = direction, Spread = spread }; } /// public override string ToString() { return GetType().Name; } }