Migrate DrawableDrumRoll to use a nested hitobject for strong hits

This commit is contained in:
smoogipoo
2018-08-03 16:20:08 +09:00
parent fdf889359f
commit 4494853446
3 changed files with 33 additions and 17 deletions

View File

@ -13,7 +13,6 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Taiko.Judgements;
namespace osu.Game.Rulesets.Taiko.Objects.Drawables namespace osu.Game.Rulesets.Taiko.Objects.Drawables
{ {
@ -24,9 +23,6 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
/// </summary> /// </summary>
private const int rolling_hits_for_engaged_colour = 5; private const int rolling_hits_for_engaged_colour = 5;
private readonly JudgementResult result;
private readonly JudgementResult strongResult;
/// <summary> /// <summary>
/// Rolling number of tick hits. This increases for hits and decreases for misses. /// Rolling number of tick hits. This increases for hits and decreases for misses.
/// </summary> /// </summary>
@ -48,9 +44,6 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
AddNested(newTick); AddNested(newTick);
tickContainer.Add(newTick); tickContainer.Add(newTick);
} }
result = Results.Single(r => !(r.Judgement is TaikoStrongHitJudgement));
strongResult = Results.SingleOrDefault(r => r.Judgement is TaikoStrongHitJudgement);
} }
protected override TaikoPiece CreateMainPiece() => new ElongatedCirclePiece(); protected override TaikoPiece CreateMainPiece() => new ElongatedCirclePiece();
@ -90,17 +83,9 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
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(result, r => r.Type = countHit >= HitObject.RequiredGreatHits ? HitResult.Great : HitResult.Good);
if (HitObject.IsStrong)
ApplyResult(strongResult, r => r.Type = HitResult.Great);
}
else else
{ ApplyResult(r => r.Type = HitResult.Miss);
ApplyResult(result, r => r.Type = HitResult.Miss);
if (HitObject.IsStrong)
ApplyResult(strongResult, r => r.Type = HitResult.Miss);
}
} }
protected override void UpdateState(ArmedState state) protected override void UpdateState(ArmedState state)
@ -113,5 +98,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
break; break;
} }
} }
protected override DrawableStrongHitObject CreateStrongObject(StrongHitObject hitObject) => new DrawableStrongDrumRoll(hitObject, this);
} }
} }

View File

@ -0,0 +1,28 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Game.Rulesets.Scoring;
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
{
public class DrawableStrongDrumRoll : DrawableStrongHitObject
{
private readonly DrawableDrumRoll drumRoll;
public DrawableStrongDrumRoll(StrongHitObject strong, DrawableDrumRoll drumRoll)
: base(strong)
{
this.drumRoll = drumRoll;
}
protected override void CheckForJudgements(bool userTriggered, double timeOffset)
{
if (!drumRoll.Judged)
return;
ApplyResult(r => r.Type = drumRoll.IsHit ? HitResult.Great : HitResult.Miss);
}
public override bool OnPressed(TaikoAction action) => false;
}
}

View File

@ -10,6 +10,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
protected DrawableStrongHitObject(StrongHitObject strong) protected DrawableStrongHitObject(StrongHitObject strong)
: base(strong) : base(strong)
{ {
AlwaysPresent = true;
} }
protected override void UpdateState(ArmedState state) protected override void UpdateState(ArmedState state)