Combine hit types and remove old drumroll hits using a more efficient method

This commit is contained in:
Dean Herbert
2020-04-27 16:13:28 +09:00
parent ff736a22dd
commit b9f28c8373
10 changed files with 67 additions and 113 deletions

View File

@ -49,10 +49,7 @@ namespace osu.Game.Rulesets.Taiko.UI
switch (h)
{
case Hit hit:
if (hit.Type == HitType.Centre)
return new DrawableCentreHit(hit);
else
return new DrawableRimHit(hit);
return new DrawableHit(hit);
case DrumRoll drumRoll:
return new DrawableDrumRoll(drumRoll);

View File

@ -0,0 +1,35 @@
// 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.Containers;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Taiko.Objects.Drawables;
using osu.Game.Rulesets.UI.Scrolling;
namespace osu.Game.Rulesets.Taiko.UI
{
internal class DrumRollHitContainer : ScrollingHitObjectContainer
{
protected override void Update()
{
base.Update();
// Remove any auxiliary hit notes that were spawned during a drum roll but subsequently rewound.
for (var i = AliveInternalChildren.Count - 1; i >= 0; i--)
{
var flyingHit = (DrawableFlyingHit)AliveInternalChildren[i];
if (Time.Current < flyingHit.HitObject.StartTime)
Remove(flyingHit);
}
}
protected override void OnChildLifetimeBoundaryCrossed(LifetimeBoundaryCrossedEvent e)
{
base.OnChildLifetimeBoundaryCrossed(e);
// ensure all old hits are removed on becoming alive (may miss being in the AliveInternalChildren list above).
if (e.Kind == LifetimeBoundaryKind.Start && e.Direction == LifetimeBoundaryCrossingDirection.Backward)
Remove((DrawableHitObject)e.Child);
}
}
}

View File

@ -93,10 +93,7 @@ namespace osu.Game.Rulesets.Taiko.UI
Children = new Drawable[]
{
HitObjectContainer,
drumRollHitContainer = new ScrollingHitObjectContainer
{
Name = "Drumroll hit"
}
drumRollHitContainer = new DrumRollHitContainer()
}
},
kiaiExplosionContainer = new Container<KiaiHitExplosion>
@ -149,23 +146,11 @@ namespace osu.Game.Rulesets.Taiko.UI
// This is basically allowing for correct alignment as relative pieces move around them.
rightArea.Padding = new MarginPadding { Left = leftArea.DrawWidth };
hitTargetOffsetContent.Padding = new MarginPadding { Left = HitTarget.DrawWidth / 2 };
// When rewinding, make sure to remove any auxiliary hit notes that were
// spawned and played during a drum roll.
if (Time.Elapsed < 0)
{
foreach (var o in drumRollHitContainer.Objects)
{
if (o.HitObject.StartTime >= Time.Current)
drumRollHitContainer.Remove(o);
}
}
}
public override void Add(DrawableHitObject h)
{
h.OnNewResult += OnNewResult;
base.Add(h);
switch (h)
@ -184,7 +169,6 @@ namespace osu.Game.Rulesets.Taiko.UI
{
if (!DisplayJudgements.Value)
return;
if (!judgedObject.DisplayResult)
return;
@ -226,20 +210,12 @@ namespace osu.Game.Rulesets.Taiko.UI
{
bool isStrong = drawableTick.HitObject.IsStrong;
double time = drawableTick.HitObject.GetEndTime();
DrawableHit drawableHit;
if (drawableTick.JudgementType == HitType.Rim)
drawableHit = new DrawableFlyingRimHit(time, isStrong);
else
drawableHit = new DrawableFlyingCentreHit(time, isStrong);
drumRollHitContainer.Add(drawableHit);
drumRollHitContainer.Add(new DrawableFlyingHit(time, isStrong));
}
private void addExplosion(DrawableHitObject drawableObject, HitType type)
{
hitExplosionContainer.Add(new HitExplosion(drawableObject, type));
if (drawableObject.HitObject.Kiai)
kiaiExplosionContainer.Add(new KiaiHitExplosion(drawableObject, type));
}