1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-21 07:53:38 +08:00
osu-lazer/osu.Game.Rulesets.Mania/UI/PoolableHitExplosion.cs

53 lines
1.4 KiB
C#
Raw Normal View History

2020-07-29 14:36:42 +08: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 15:37:17 +08:00
#nullable disable
2020-07-29 14:36:42 +08:00
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Pooling;
2020-07-29 15:14:19 +08:00
using osu.Game.Rulesets.Judgements;
2020-07-29 14:36:42 +08:00
using osu.Game.Skinning;
namespace osu.Game.Rulesets.Mania.UI
{
2022-11-24 13:32:20 +08:00
public partial class PoolableHitExplosion : PoolableDrawable
2020-07-29 14:36:42 +08:00
{
public const double DURATION = 200;
2020-07-29 15:14:19 +08:00
public JudgementResult Result { get; private set; }
2020-07-29 14:36:42 +08:00
private SkinnableDrawable skinnableExplosion;
public PoolableHitExplosion()
{
RelativeSizeAxes = Axes.Both;
}
[BackgroundDependencyLoader]
private void load()
{
InternalChild = skinnableExplosion = new SkinnableDrawable(new ManiaSkinComponentLookup(ManiaSkinComponents.HitExplosion), _ => new DefaultHitExplosion())
2020-07-29 14:36:42 +08:00
{
RelativeSizeAxes = Axes.Both
};
}
2020-07-29 15:14:19 +08:00
public void Apply(JudgementResult result)
{
Result = result;
}
2020-07-29 14:36:42 +08:00
protected override void PrepareForUse()
{
base.PrepareForUse();
LifetimeStart = Time.Current;
2020-07-29 15:14:19 +08:00
(skinnableExplosion?.Drawable as IHitExplosion)?.Animate(Result);
2020-07-29 14:36:42 +08:00
this.Delay(DURATION).Then().Expire();
}
}
}