2020-03-13 03:59:30 +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.
|
|
|
|
|
|
|
|
using osu.Framework.Graphics;
|
2021-07-25 14:50:52 +00:00
|
|
|
using osu.Game.Rulesets.Catch.Skinning.Default;
|
2021-06-04 10:46:50 +00:00
|
|
|
using osu.Game.Rulesets.Objects.Pooling;
|
2021-07-25 14:50:52 +00:00
|
|
|
using osu.Game.Skinning;
|
2020-03-13 03:59:30 +00:00
|
|
|
|
2021-08-12 19:09:08 +00:00
|
|
|
#nullable enable
|
|
|
|
|
2020-03-13 03:59:30 +00:00
|
|
|
namespace osu.Game.Rulesets.Catch.UI
|
|
|
|
{
|
2021-06-04 10:46:50 +00:00
|
|
|
public class HitExplosion : PoolableDrawableWithLifetime<HitExplosionEntry>
|
2020-03-13 03:59:30 +00:00
|
|
|
{
|
2021-08-12 19:09:08 +00:00
|
|
|
private readonly SkinnableDrawable skinnableExplosion;
|
2020-12-01 02:32:20 +00:00
|
|
|
|
|
|
|
public HitExplosion()
|
2020-03-13 03:59:30 +00:00
|
|
|
{
|
2021-07-25 14:50:52 +00:00
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
Anchor = Anchor.BottomCentre;
|
2020-03-13 03:59:30 +00:00
|
|
|
Origin = Anchor.BottomCentre;
|
|
|
|
|
2021-08-07 16:19:29 +00:00
|
|
|
InternalChild = skinnableExplosion = new SkinnableDrawable(new CatchSkinComponent(CatchSkinComponents.HitExplosion), _ => new DefaultHitExplosion())
|
2020-03-13 03:59:30 +00:00
|
|
|
{
|
2021-07-25 17:00:37 +00:00
|
|
|
CentreComponent = false,
|
2021-07-25 14:50:52 +00:00
|
|
|
Anchor = Anchor.BottomCentre,
|
|
|
|
Origin = Anchor.BottomCentre
|
2020-03-13 03:59:30 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-06-04 10:46:50 +00:00
|
|
|
protected override void OnApply(HitExplosionEntry entry)
|
|
|
|
{
|
2021-07-25 14:50:52 +00:00
|
|
|
base.OnApply(entry);
|
2021-08-11 21:32:58 +00:00
|
|
|
if (IsLoaded)
|
|
|
|
apply(entry);
|
|
|
|
}
|
2020-12-01 02:32:20 +00:00
|
|
|
|
2021-08-11 21:32:58 +00:00
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
apply(Entry);
|
|
|
|
}
|
|
|
|
|
2021-08-12 19:09:08 +00:00
|
|
|
private void apply(HitExplosionEntry? entry)
|
2021-08-11 21:32:58 +00:00
|
|
|
{
|
2021-08-12 19:09:08 +00:00
|
|
|
if (entry == null)
|
|
|
|
return;
|
|
|
|
|
2021-08-07 16:19:29 +00:00
|
|
|
ApplyTransformsAt(double.MinValue, true);
|
|
|
|
ClearTransforms(true);
|
|
|
|
|
|
|
|
(skinnableExplosion.Drawable as IHitExplosion)?.Animate(entry);
|
|
|
|
LifetimeEnd = skinnableExplosion.Drawable.LatestTransformEndTime;
|
2020-12-01 02:32:20 +00:00
|
|
|
}
|
2020-03-13 03:59:30 +00:00
|
|
|
}
|
|
|
|
}
|