From acea7b2e728787a0d83bbf83c8c1f042d2c32e7e Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Mon, 3 Jun 2024 10:15:45 +0800 Subject: + plugins project --- .../Profiles/SprayProfile.cs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Profiles/SprayProfile.cs (limited to 'Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Profiles/SprayProfile.cs') diff --git a/Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Profiles/SprayProfile.cs b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Profiles/SprayProfile.cs new file mode 100644 index 0000000..6259210 --- /dev/null +++ b/Plugins/MonoGame.Extended/source/MonoGame.Extended.Particles/Profiles/SprayProfile.cs @@ -0,0 +1,20 @@ +using System; +using Microsoft.Xna.Framework; + +namespace MonoGame.Extended.Particles.Profiles +{ + public class SprayProfile : Profile + { + public Vector2 Direction { get; set; } + public float Spread { get; set; } + + public override void GetOffsetAndHeading(out Vector2 offset, out Vector2 heading) + { + var angle = (float) Math.Atan2(Direction.Y, Direction.X); + + angle = Random.NextSingle(angle - Spread/2f, angle + Spread/2f); + offset = Vector2.Zero; + heading = new Vector2((float) Math.Cos(angle), (float) Math.Sin(angle)); + } + } +} \ No newline at end of file -- cgit v1.1-26-g67d0