Explicitly set lifetime to ensure empty drawables are cleaned up

This commit is contained in:
Bartłomiej Dach 2020-11-10 14:50:19 +01:00
parent 0387d994bd
commit be4735cd2b
2 changed files with 8 additions and 1 deletions

View File

@ -116,8 +116,9 @@ public override Drawable GetDrawableComponent(ISkinComponent component)
case TaikoSkinComponents.TaikoExplosionKiai: case TaikoSkinComponents.TaikoExplosionKiai:
// suppress the default kiai explosion if the skin brings its own sprites. // suppress the default kiai explosion if the skin brings its own sprites.
// the drawable needs to expire as soon as possible to avoid accumulating empty drawables on the playfield.
if (hasExplosion.Value) if (hasExplosion.Value)
return Drawable.Empty(); return KiaiHitExplosion.EmptyExplosion();
return null; return null;

View File

@ -43,5 +43,11 @@ private void load()
{ {
Child = skinnable = new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.TaikoExplosionKiai), _ => new DefaultKiaiHitExplosion(hitType)); Child = skinnable = new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.TaikoExplosionKiai), _ => new DefaultKiaiHitExplosion(hitType));
} }
/// <summary>
/// Helper function to use when an explosion is not desired.
/// Lifetime is set to avoid accumulating empty drawables in the parent container.
/// </summary>
public static Drawable EmptyExplosion() => Empty().With(d => d.LifetimeEnd = double.MinValue);
} }
} }