From ab1d5235284bb0b3f98c602736262403da9eb6e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Tue, 15 Aug 2023 07:44:05 +0200 Subject: [PATCH] Fix kiai stars flickering on and off during gameplay Closes #24503. The problematic reset of `lastParticleAdded` has been moved to a place that should hopefully (a) not cause such problems and (b) be much more explicit about what's happening. --- osu.Game/Graphics/ParticleSpewer.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/osu.Game/Graphics/ParticleSpewer.cs b/osu.Game/Graphics/ParticleSpewer.cs index 37a4fe77bd5a..64c70095bf95 100644 --- a/osu.Game/Graphics/ParticleSpewer.cs +++ b/osu.Game/Graphics/ParticleSpewer.cs @@ -49,6 +49,18 @@ protected ParticleSpewer(Texture texture, int perSecond, double maxDuration) this.maxDuration = maxDuration; } + protected override void LoadComplete() + { + base.LoadComplete(); + + Active.BindValueChanged(active => + { + // ensure that particles can be spawned immediately after the spewer becomes active. + if (active.NewValue) + lastParticleAdded = null; + }); + } + protected override void Update() { base.Update(); @@ -56,12 +68,8 @@ protected override void Update() Invalidate(Invalidation.DrawNode); if (!Active.Value || !CanSpawnParticles) - { - lastParticleAdded = null; return; - } - // Always want to spawn the first particle in an activation immediately. if (lastParticleAdded == null) { lastParticleAdded = Time.Current;