osu/osu.Game.Rulesets.Mania/UI/PoolableHitExplosion.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

51 lines
1.3 KiB
C#
Raw Normal View History

2020-07-29 06:36:42 +00:00
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2022-06-17 07:37:17 +00:00
#nullable disable
2020-07-29 06:36:42 +00:00
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Pooling;
2020-07-29 07:14:19 +00:00
using osu.Game.Rulesets.Judgements;
2020-07-29 06:36:42 +00:00
using osu.Game.Skinning;
namespace osu.Game.Rulesets.Mania.UI
{
public class PoolableHitExplosion : PoolableDrawable
{
public const double DURATION = 200;
2020-07-29 07:14:19 +00:00
public JudgementResult Result { get; private set; }
2020-07-29 06:36:42 +00:00
private SkinnableDrawable skinnableExplosion;
public PoolableHitExplosion()
{
RelativeSizeAxes = Axes.Both;
}
[BackgroundDependencyLoader]
private void load()
{
2021-05-12 07:35:05 +00:00
InternalChild = skinnableExplosion = new SkinnableDrawable(new ManiaSkinComponent(ManiaSkinComponents.HitExplosion), _ => new DefaultHitExplosion())
2020-07-29 06:36:42 +00:00
{
RelativeSizeAxes = Axes.Both
};
}
2020-07-29 07:14:19 +00:00
public void Apply(JudgementResult result)
{
Result = result;
}
2020-07-29 06:36:42 +00:00
protected override void PrepareForUse()
{
base.PrepareForUse();
2020-07-29 07:14:19 +00:00
(skinnableExplosion?.Drawable as IHitExplosion)?.Animate(Result);
2020-07-29 06:36:42 +00:00
this.Delay(DURATION).Then().Expire();
}
}
}