From cfcb46034c51bc4a95186f4e304e8b84294706fa Mon Sep 17 00:00:00 2001 From: Opelkuh <25430283+Opelkuh@users.noreply.github.com> Date: Fri, 10 Sep 2021 00:02:37 +0200 Subject: [PATCH] Remove `ParticleJet` --- .../Visual/Gameplay/TestSceneParticleJet.cs | 61 ------------ .../Gameplay/TestSceneParticleSpewer.cs | 94 +++++++++++++++++++ osu.Game/Graphics/Particles/ParticleJet.cs | 48 ---------- 3 files changed, 94 insertions(+), 109 deletions(-) delete mode 100644 osu.Game.Tests/Visual/Gameplay/TestSceneParticleJet.cs create mode 100644 osu.Game.Tests/Visual/Gameplay/TestSceneParticleSpewer.cs delete mode 100644 osu.Game/Graphics/Particles/ParticleJet.cs diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneParticleJet.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneParticleJet.cs deleted file mode 100644 index e570abcf88..0000000000 --- a/osu.Game.Tests/Visual/Gameplay/TestSceneParticleJet.cs +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using NUnit.Framework; -using osu.Framework.Allocation; -using osu.Framework.Graphics; -using osu.Framework.Testing; -using osu.Game.Graphics.Particles; -using osu.Game.Skinning; - -namespace osu.Game.Tests.Visual.Gameplay -{ - [TestFixture] - public class TestSceneParticleJet : OsuTestScene - { - private ParticleJet jet; - - [Resolved] - private SkinManager skinManager { get; set; } - - public TestSceneParticleJet() - { - AddStep("create", () => - { - Child = jet = createJet(); - }); - - AddToggleStep("toggle spawning", value => jet.Active.Value = value); - } - - [SetUpSteps] - public void SetUpSteps() - { - AddStep("create jet", () => Child = jet = createJet()); - } - - [Test] - public void TestPresence() - { - AddStep("start jet", () => jet.Active.Value = true); - AddAssert("is present", () => jet.IsPresent); - - AddWaitStep("wait for some particles", 3); - AddStep("stop jet", () => jet.Active.Value = false); - - AddWaitStep("wait for clean screen", 5); - AddAssert("is not present", () => !jet.IsPresent); - } - - private ParticleJet createJet() - { - return new ParticleJet(skinManager.DefaultLegacySkin.GetTexture("star2"), 180) - { - Anchor = Anchor.BottomCentre, - Origin = Anchor.BottomCentre, - RelativePositionAxes = Axes.Y, - Y = -0.1f, - }; - } - } -} diff --git a/osu.Game.Tests/Visual/Gameplay/TestSceneParticleSpewer.cs b/osu.Game.Tests/Visual/Gameplay/TestSceneParticleSpewer.cs new file mode 100644 index 0000000000..3a59374c98 --- /dev/null +++ b/osu.Game.Tests/Visual/Gameplay/TestSceneParticleSpewer.cs @@ -0,0 +1,94 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using NUnit.Framework; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Textures; +using osu.Framework.Testing; +using osu.Framework.Utils; +using osu.Game.Graphics.Particles; +using osu.Game.Skinning; +using osuTK; + +namespace osu.Game.Tests.Visual.Gameplay +{ + [TestFixture] + public class TestSceneParticleSpewer : OsuTestScene + { + private TestParticleSpewer spewer; + + [Resolved] + private SkinManager skinManager { get; set; } + + [BackgroundDependencyLoader] + private void load() + { + Child = spewer = createSpewer(); + + AddToggleStep("toggle spawning", value => spewer.Active.Value = value); + AddSliderStep("particle gravity", 0f, 250f, 0f, value => spewer.Gravity = value); + AddSliderStep("particle velocity", 0f, 500f, 250f, value => spewer.MaxVelocity = value); + } + + [SetUpSteps] + public void SetUpSteps() + { + AddStep("create jet", () => Child = spewer = createSpewer()); + } + + [Test] + public void TestPresence() + { + AddStep("start jet", () => spewer.Active.Value = true); + AddAssert("is present", () => spewer.IsPresent); + + AddWaitStep("wait for some particles", 3); + AddStep("stop jet", () => spewer.Active.Value = false); + + AddWaitStep("wait for clean screen", 8); + AddAssert("is not present", () => !spewer.IsPresent); + } + + private TestParticleSpewer createSpewer() + { + return new TestParticleSpewer(skinManager.DefaultLegacySkin.GetTexture("star2")) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + }; + } + + private class TestParticleSpewer : ParticleSpewer + { + private const int lifetime = 1500; + private const int rate = 250; + + public float Gravity = 0; + public float MaxVelocity = 250; + + protected override float ParticleGravity => Gravity; + + public TestParticleSpewer(Texture texture) + : base(texture, rate, lifetime) + { + } + + protected override FallingParticle SpawnParticle() + { + var p = base.SpawnParticle(); + p.Velocity = new Vector2( + RNG.NextSingle(-MaxVelocity, MaxVelocity), + RNG.NextSingle(-MaxVelocity, MaxVelocity) + ); + p.Duration = RNG.NextSingle(lifetime); + p.StartAngle = RNG.NextSingle(MathF.PI * 2); + p.EndAngle = RNG.NextSingle(MathF.PI * 2); + p.EndScale = RNG.NextSingle(0.5f, 1.5f); + + return p; + } + } + } +} diff --git a/osu.Game/Graphics/Particles/ParticleJet.cs b/osu.Game/Graphics/Particles/ParticleJet.cs deleted file mode 100644 index a76aa6b75f..0000000000 --- a/osu.Game/Graphics/Particles/ParticleJet.cs +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using System; -using osu.Framework.Graphics.Textures; -using osu.Framework.Utils; -using osuTK; - -namespace osu.Game.Graphics.Particles -{ - public class ParticleJet : ParticleSpewer - { - private const int particles_per_second = 80; - private const double particle_lifetime = 500; - private const int angle_spread = 10; - private const float velocity_min = 1300f; - private const float velocity_max = 1500f; - - private readonly int angle; - - protected override float ParticleGravity => 750f; - - public ParticleJet(Texture texture, int angle) - : base(texture, particles_per_second, particle_lifetime) - { - this.angle = angle; - } - - protected override FallingParticle SpawnParticle() - { - var p = base.SpawnParticle(); - - var directionRads = MathUtils.DegreesToRadians( - RNG.NextSingle(angle - angle_spread / 2, angle + angle_spread / 2) - ); - var direction = new Vector2(MathF.Sin(directionRads), MathF.Cos(directionRads)); - - p.StartPosition = OriginPosition; - p.Duration = RNG.NextSingle((float)particle_lifetime * 0.8f, (float)particle_lifetime); - p.Velocity = direction * new Vector2(RNG.NextSingle(velocity_min, velocity_max)); - p.StartAngle = RNG.NextSingle(-2f, 2f); - p.EndAngle = RNG.NextSingle(-2f, 2f); - p.EndScale = 2f; - - return p; - } - } -}