1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 11:20:04 +08:00

Don't recreate explosion counter each increment

This commit is contained in:
Dean Herbert 2020-09-22 12:24:26 +09:00
parent f629c33dc0
commit a27a65bf03

View File

@ -16,19 +16,14 @@ namespace osu.Game.Rulesets.Catch.Skinning
/// </summary>
public class LegacyComboCounter : CompositeDrawable, ICatchComboCounter
{
private readonly ISkin skin;
private readonly string fontName;
private readonly float fontOverlap;
private readonly LegacyRollingCounter counter;
private readonly LegacyRollingCounter explosion;
public LegacyComboCounter(ISkin skin)
{
this.skin = skin;
fontName = skin.GetConfig<LegacySetting, string>(LegacySetting.ComboPrefix)?.Value ?? "score";
fontOverlap = skin.GetConfig<LegacySetting, float>(LegacySetting.ComboOverlap)?.Value ?? -2f;
var fontName = skin.GetConfig<LegacySetting, string>(LegacySetting.ComboPrefix)?.Value ?? "score";
var fontOverlap = skin.GetConfig<LegacySetting, float>(LegacySetting.ComboOverlap)?.Value ?? -2f;
AutoSizeAxes = Axes.Both;
@ -37,18 +32,27 @@ namespace osu.Game.Rulesets.Catch.Skinning
Origin = Anchor.Centre;
Scale = new Vector2(0.8f);
InternalChild = counter = new LegacyRollingCounter(skin, fontName, fontOverlap)
InternalChildren = new Drawable[]
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
explosion = new LegacyRollingCounter(skin, fontName, fontOverlap)
{
Alpha = 0.65f,
Blending = BlendingParameters.Additive,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Scale = new Vector2(1.5f),
},
counter = new LegacyRollingCounter(skin, fontName, fontOverlap)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
},
};
}
public void DisplayInitialCombo(int combo) => updateCombo(combo, null, true);
public void UpdateCombo(int combo, Color4? hitObjectColour) => updateCombo(combo, hitObjectColour, false);
private LegacyRollingCounter lastExplosion;
private void updateCombo(int combo, Color4? hitObjectColour, bool immediate)
{
// There may still be existing transforms to the counter (including value change after 250ms),
@ -59,17 +63,12 @@ namespace osu.Game.Rulesets.Catch.Skinning
if (combo == 0)
{
counter.Current.Value = 0;
if (lastExplosion != null)
lastExplosion.Current.Value = 0;
explosion.Current.Value = 0;
this.FadeOut(immediate ? 0.0 : 400.0, Easing.Out);
return;
}
// Remove last explosion to not conflict with the upcoming one.
if (lastExplosion != null)
RemoveInternal(lastExplosion);
this.FadeIn().Delay(1000.0).FadeOut(300.0);
// For simplicity, in the case of rewinding we'll just set the counter to the current combo value.
@ -86,25 +85,11 @@ namespace osu.Game.Rulesets.Catch.Skinning
counter.Delay(250.0).ScaleTo(1f).ScaleTo(1.1f, 60.0).Then().ScaleTo(1f, 30.0);
var explosion = new LegacyRollingCounter(skin, fontName, fontOverlap)
{
Alpha = 0.65f,
Blending = BlendingParameters.Additive,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Scale = new Vector2(1.5f),
Colour = hitObjectColour ?? Color4.White,
Depth = 1f,
};
AddInternal(explosion);
explosion.Colour = hitObjectColour ?? Color4.White;
explosion.SetCountWithoutRolling(combo);
explosion.ScaleTo(1.9f, 400.0, Easing.Out)
.FadeOut(400.0)
.Expire(true);
lastExplosion = explosion;
explosion.ScaleTo(1.5f).ScaleTo(1.9f, 400.0, Easing.Out)
.FadeOutFromOne(400.0);
}
}
}