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