mirror of https://github.com/ppy/osu
Change `ParticleSpewer.Active` to a Bindable
This commit is contained in:
parent
4c753420d3
commit
328c9a5dd0
|
@ -25,7 +25,7 @@ public TestSceneParticleJet()
|
|||
Child = jet = createJet();
|
||||
});
|
||||
|
||||
AddToggleStep("toggle spawning", value => jet.Active = value);
|
||||
AddToggleStep("toggle spawning", value => jet.Active.Value = value);
|
||||
}
|
||||
|
||||
[SetUpSteps]
|
||||
|
@ -37,11 +37,11 @@ public void SetUpSteps()
|
|||
[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 @@ public abstract class ParticleSpewer : Sprite
|
|||
/// <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 @@ protected override void Update()
|
|||
// 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());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue