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

Added arbitrary hit handler to drum roll object

This commit is contained in:
Tim Oliver 2020-04-07 16:40:01 +08:00
parent f8b728f9e8
commit a52130857b

View File

@ -34,6 +34,14 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
private Color4 colourIdle; private Color4 colourIdle;
private Color4 colourEngaged; private Color4 colourEngaged;
private bool judgingStarted;
/// <summary>
/// A handler action for when the drumroll has been hit,
/// regardless of any judgement.
/// </summary>
public Action<TaikoAction> OnHit;
public DrawableDrumRoll(DrumRoll drumRoll) public DrawableDrumRoll(DrumRoll drumRoll)
: base(drumRoll) : base(drumRoll)
{ {
@ -86,15 +94,27 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
protected override TaikoPiece CreateMainPiece() => new ElongatedCirclePiece(); protected override TaikoPiece CreateMainPiece() => new ElongatedCirclePiece();
public override bool OnPressed(TaikoAction action) => false; public override bool OnPressed(TaikoAction action)
{
if (judgingStarted)
OnHit.Invoke(action);
return false;
}
private void onNewResult(DrawableHitObject obj, JudgementResult result) private void onNewResult(DrawableHitObject obj, JudgementResult result)
{ {
if (!(obj is DrawableDrumRollTick)) if (!(obj is DrawableDrumRollTick))
return; return;
DrawableDrumRollTick drumRollTick = (DrawableDrumRollTick)obj;
if (result.Type > HitResult.Miss) if (result.Type > HitResult.Miss)
{
OnHit.Invoke(drumRollTick.JudgedAction);
judgingStarted = true;
rollingHits++; rollingHits++;
}
else else
rollingHits--; rollingHits--;
@ -113,8 +133,11 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
return; return;
int countHit = NestedHitObjects.Count(o => o.IsHit); int countHit = NestedHitObjects.Count(o => o.IsHit);
if (countHit >= HitObject.RequiredGoodHits) if (countHit >= HitObject.RequiredGoodHits)
{
ApplyResult(r => r.Type = countHit >= HitObject.RequiredGreatHits ? HitResult.Great : HitResult.Good); ApplyResult(r => r.Type = countHit >= HitObject.RequiredGreatHits ? HitResult.Great : HitResult.Good);
}
else else
ApplyResult(r => r.Type = HitResult.Miss); ApplyResult(r => r.Type = HitResult.Miss);
} }