mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 07:33:55 +09:00
Change ParticleSpewer.Active
to a Bindable
This commit is contained in:
@ -25,7 +25,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
Child = jet = createJet();
|
||||
});
|
||||
|
||||
AddToggleStep("toggle spawning", value => jet.Active = value);
|
||||
AddToggleStep("toggle spawning", value => jet.Active.Value = value);
|
||||
}
|
||||
|
||||
[SetUpSteps]
|
||||
@ -37,11 +37,11 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Test]
|
||||
public void TestPresence()
|
||||
{
|
||||
AddStep("start jet", () => jet.Active = true);
|
||||
AddStep("start jet", () => jet.Active.Value = true);
|
||||
AddAssert("is present", () => jet.IsPresent);
|
||||
|
||||
AddWaitStep("wait for some particles", 3);
|
||||
AddStep("stop jet", () => jet.Active = false);
|
||||
AddStep("stop jet", () => jet.Active.Value = false);
|
||||
|
||||
AddWaitStep("wait for clean screen", 5);
|
||||
AddAssert("is not present", () => !jet.IsPresent);
|
||||
|
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.OpenGL.Vertices;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
@ -23,9 +24,9 @@ namespace osu.Game.Graphics.Particles
|
||||
/// <summary>
|
||||
/// Determines whether particles are being spawned.
|
||||
/// </summary>
|
||||
public bool Active { get; set; }
|
||||
public readonly BindableBool Active = new BindableBool();
|
||||
|
||||
public bool HasActiveParticles => Active || (lastParticleAdded + maxLifetime) > Time.Current;
|
||||
public bool HasActiveParticles => Active.Value || (lastParticleAdded + maxLifetime) > Time.Current;
|
||||
public override bool IsPresent => base.IsPresent && HasActiveParticles;
|
||||
|
||||
protected virtual float ParticleGravity => 0;
|
||||
@ -49,7 +50,7 @@ namespace osu.Game.Graphics.Particles
|
||||
// this can happen when seeking in replays.
|
||||
if (lastParticleAdded > Time.Current) lastParticleAdded = 0;
|
||||
|
||||
if (Active && Time.Current > lastParticleAdded + cooldown)
|
||||
if (Active.Value && Time.Current > lastParticleAdded + cooldown)
|
||||
{
|
||||
addParticle(SpawnParticle());
|
||||
}
|
||||
|
Reference in New Issue
Block a user