mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 09:27:29 +08:00
Refactor osu!taiko circle piece logic to read better
This commit is contained in:
parent
491f119988
commit
ab3b51e4a0
@ -26,7 +26,7 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
|
||||
private static readonly Vector2 max_circle_sprite_size = new Vector2(160);
|
||||
|
||||
private Drawable backgroundLayer = null!;
|
||||
private Drawable? foregroundLayer;
|
||||
private TextureAnimation? foregroundLayer;
|
||||
|
||||
private Bindable<int> currentCombo { get; } = new BindableInt();
|
||||
|
||||
@ -48,40 +48,44 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(ISkinSource skin, DrawableHitObject drawableHitObject, IBeatSyncProvider? beatSyncProvider)
|
||||
{
|
||||
Drawable? getDrawableFor(string lookup)
|
||||
Drawable? getDrawableFor(string lookup, bool animatable)
|
||||
{
|
||||
const string normal_hit = "taikohit";
|
||||
const string big_hit = "taikobig";
|
||||
|
||||
string prefix = ((drawableHitObject.HitObject as TaikoStrongableHitObject)?.IsStrong ?? false) ? big_hit : normal_hit;
|
||||
|
||||
return skin.GetAnimation($"{prefix}{lookup}", true, false, maxSize: max_circle_sprite_size) ??
|
||||
return skin.GetAnimation($"{prefix}{lookup}", animatable, false, maxSize: max_circle_sprite_size) ??
|
||||
// fallback to regular size if "big" version doesn't exist.
|
||||
skin.GetAnimation($"{normal_hit}{lookup}", true, false, maxSize: max_circle_sprite_size);
|
||||
skin.GetAnimation($"{normal_hit}{lookup}", animatable, false, maxSize: max_circle_sprite_size);
|
||||
}
|
||||
|
||||
// backgroundLayer is guaranteed to exist due to the pre-check in TaikoLegacySkinTransformer.
|
||||
AddInternal(backgroundLayer = new LegacyKiaiFlashingDrawable(() => getDrawableFor("circle")));
|
||||
AddInternal(backgroundLayer = new LegacyKiaiFlashingDrawable(() => getDrawableFor("circle", false))
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre
|
||||
});
|
||||
|
||||
foregroundLayer = (TextureAnimation?)getDrawableFor("circleoverlay", true);
|
||||
|
||||
foregroundLayer = getDrawableFor("circleoverlay");
|
||||
if (foregroundLayer != null)
|
||||
{
|
||||
foregroundLayer.Anchor = Anchor.Centre;
|
||||
foregroundLayer.Origin = Anchor.Centre;
|
||||
|
||||
// Animations in taiko skins are used in a custom way (>150 combo and animating in time with beat).
|
||||
// For now just stop at first frame for sanity.
|
||||
foregroundLayer.Stop();
|
||||
|
||||
AddInternal(foregroundLayer);
|
||||
}
|
||||
|
||||
drawableHitObject.StartTimeBindable.BindValueChanged(startTime =>
|
||||
{
|
||||
timingPoint = beatSyncProvider?.ControlPoints?.TimingPointAt(startTime.NewValue) ?? TimingControlPoint.DEFAULT;
|
||||
}, true);
|
||||
|
||||
// Animations in taiko skins are used in a custom way (>150 combo and animating in time with beat).
|
||||
// For now just stop at first frame for sanity.
|
||||
foreach (var c in InternalChildren)
|
||||
{
|
||||
(c as IFramedAnimation)?.Stop();
|
||||
|
||||
c.Anchor = Anchor.Centre;
|
||||
c.Origin = Anchor.Centre;
|
||||
}
|
||||
|
||||
if (gameplayState != null)
|
||||
currentCombo.BindTo(gameplayState.ScoreProcessor.Combo);
|
||||
}
|
||||
@ -101,12 +105,14 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
|
||||
foreach (var c in InternalChildren)
|
||||
c.Scale = new Vector2(DrawHeight / circle_piece_size.Y);
|
||||
|
||||
if (foregroundLayer is IFramedAnimation animatableForegroundLayer)
|
||||
animateForegroundLayer(animatableForegroundLayer);
|
||||
animateForegroundLayer();
|
||||
}
|
||||
|
||||
private void animateForegroundLayer(IFramedAnimation animatableForegroundLayer)
|
||||
private void animateForegroundLayer()
|
||||
{
|
||||
if (foregroundLayer == null)
|
||||
return;
|
||||
|
||||
int multiplier;
|
||||
|
||||
if (currentCombo.Value >= 150)
|
||||
@ -119,12 +125,12 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Legacy
|
||||
}
|
||||
else
|
||||
{
|
||||
animatableForegroundLayer.GotoFrame(0);
|
||||
foregroundLayer.GotoFrame(0);
|
||||
return;
|
||||
}
|
||||
|
||||
animationFrame = Math.Abs(Time.Current - timingPoint.Time) % ((timingPoint.BeatLength * 2) / multiplier) >= timingPoint.BeatLength / multiplier ? 0 : 1;
|
||||
animatableForegroundLayer.GotoFrame(animationFrame);
|
||||
foregroundLayer.GotoFrame(animationFrame);
|
||||
}
|
||||
|
||||
private Color4 accentColour;
|
||||
|
Loading…
Reference in New Issue
Block a user