mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:57:39 +08:00
Cleanups
This commit is contained in:
parent
412e4ff681
commit
38263714a1
@ -145,7 +145,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
||||
if (RNG.Next(10) == 0)
|
||||
{
|
||||
((TaikoPlayfield)rulesetContainer.Playfield).OnJudgement(h, new JudgementResult(new TaikoJudgement()) { Type = hitResult });
|
||||
((TaikoPlayfield)rulesetContainer.Playfield).OnJudgement(h, new JudgementResult(new TaikoStrongHitJudgement()) { Type = HitResult.Great });
|
||||
((TaikoPlayfield)rulesetContainer.Playfield).OnJudgement(h, new JudgementResult(new TaikoStrongJudgement()) { Type = HitResult.Great });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Judgements
|
||||
{
|
||||
public class TaikoStrongHitJudgement : TaikoJudgement
|
||||
public class TaikoStrongJudgement : TaikoJudgement
|
||||
{
|
||||
public override bool AffectsCombo => false;
|
||||
}
|
@ -99,6 +99,24 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
}
|
||||
}
|
||||
|
||||
protected override DrawableStrongHitObject CreateStrongObject(StrongHitObject hitObject) => new DrawableStrongDrumRoll(hitObject, this);
|
||||
protected override DrawableStrongHandler CreateStrongHandler(StrongHitObject hitObject) => new StrongHandler(hitObject, this);
|
||||
|
||||
private class StrongHandler : DrawableStrongHandler
|
||||
{
|
||||
public StrongHandler(StrongHitObject strong, DrawableDrumRoll drumRoll)
|
||||
: base(strong, drumRoll)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void CheckForJudgements(bool userTriggered, double timeOffset)
|
||||
{
|
||||
if (!MainObject.Judged)
|
||||
return;
|
||||
|
||||
ApplyResult(r => r.Type = MainObject.IsHit ? HitResult.Great : HitResult.Miss);
|
||||
}
|
||||
|
||||
public override bool OnPressed(TaikoAction action) => false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,6 +51,24 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
|
||||
public override bool OnPressed(TaikoAction action) => UpdateJudgement(true);
|
||||
|
||||
protected override DrawableStrongHitObject CreateStrongObject(StrongHitObject hitObject) => new DrawableStrongDrumRollTick(hitObject, this);
|
||||
protected override DrawableStrongHandler CreateStrongHandler(StrongHitObject hitObject) => new StrongHandler(hitObject, this);
|
||||
|
||||
private class StrongHandler : DrawableStrongHandler
|
||||
{
|
||||
public StrongHandler(StrongHitObject strong, DrawableDrumRollTick tick)
|
||||
: base(strong, tick)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void CheckForJudgements(bool userTriggered, double timeOffset)
|
||||
{
|
||||
if (!MainObject.Judged)
|
||||
return;
|
||||
|
||||
ApplyResult(r => r.Type = MainObject.IsHit ? HitResult.Great : HitResult.Miss);
|
||||
}
|
||||
|
||||
public override bool OnPressed(TaikoAction action) => false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
@ -126,6 +127,64 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
}
|
||||
}
|
||||
|
||||
protected override DrawableStrongHitObject CreateStrongObject(StrongHitObject hitObject) => new DrawableStrongHit(hitObject, this);
|
||||
protected override DrawableStrongHandler CreateStrongHandler(StrongHitObject hitObject) => new StrongHandler(hitObject, this);
|
||||
|
||||
private class StrongHandler : DrawableStrongHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// The lenience for the second key press.
|
||||
/// This does not adjust by map difficulty in ScoreV2 yet.
|
||||
/// </summary>
|
||||
private const double second_hit_window = 30;
|
||||
|
||||
public new DrawableHit MainObject => (DrawableHit)base.MainObject;
|
||||
|
||||
public StrongHandler(StrongHitObject strong, DrawableHit hit)
|
||||
: base(strong, hit)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void CheckForJudgements(bool userTriggered, double timeOffset)
|
||||
{
|
||||
if (!MainObject.Result.HasResult)
|
||||
{
|
||||
base.CheckForJudgements(userTriggered, timeOffset);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!MainObject.Result.IsHit)
|
||||
{
|
||||
ApplyResult(r => r.Type = HitResult.Miss);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!userTriggered)
|
||||
{
|
||||
if (timeOffset > second_hit_window)
|
||||
ApplyResult(r => r.Type = HitResult.Miss);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Math.Abs(MainObject.Result.TimeOffset - timeOffset) < second_hit_window)
|
||||
ApplyResult(r => r.Type = HitResult.Great);
|
||||
}
|
||||
|
||||
public override bool OnPressed(TaikoAction action)
|
||||
{
|
||||
// Don't process actions until the main hitobject is hit
|
||||
if (!MainObject.IsHit)
|
||||
return false;
|
||||
|
||||
// Don't process actions if the pressed button was released
|
||||
if (MainObject.HitAction == null)
|
||||
return false;
|
||||
|
||||
// Don't handle invalid hit action presses
|
||||
if (!MainObject.HitActions.Contains(action))
|
||||
return false;
|
||||
|
||||
return UpdateJudgement(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,25 +0,0 @@
|
||||
// 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
|
||||
{
|
||||
public DrawableStrongDrumRoll(StrongHitObject strong, DrawableDrumRoll drumRoll)
|
||||
: base(strong, drumRoll)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void CheckForJudgements(bool userTriggered, double timeOffset)
|
||||
{
|
||||
if (!MainObject.Judged)
|
||||
return;
|
||||
|
||||
ApplyResult(r => r.Type = MainObject.IsHit ? HitResult.Great : HitResult.Miss);
|
||||
}
|
||||
|
||||
public override bool OnPressed(TaikoAction action) => false;
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
// 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 DrawableStrongDrumRollTick : DrawableStrongHitObject
|
||||
{
|
||||
public DrawableStrongDrumRollTick(StrongHitObject strong, DrawableDrumRollTick tick)
|
||||
: base(strong, tick)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void CheckForJudgements(bool userTriggered, double timeOffset)
|
||||
{
|
||||
if (!MainObject.Judged)
|
||||
return;
|
||||
|
||||
ApplyResult(r => r.Type = MainObject.IsHit ? HitResult.Great : HitResult.Miss);
|
||||
}
|
||||
|
||||
public override bool OnPressed(TaikoAction action) => false;
|
||||
}
|
||||
}
|
@ -2,16 +2,20 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Taiko.Judgements;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
{
|
||||
public abstract class DrawableStrongHitObject : DrawableTaikoHitObject
|
||||
/// <summary>
|
||||
/// Used as a nested hitobject to provide <see cref="TaikoStrongJudgement"/>s for <see cref="DrawableTaikoHitObject"/>s.
|
||||
/// </summary>
|
||||
public abstract class DrawableStrongHandler : DrawableTaikoHitObject
|
||||
{
|
||||
public override bool DisplayJudgement => false;
|
||||
|
||||
public readonly DrawableHitObject MainObject;
|
||||
|
||||
protected DrawableStrongHitObject(StrongHitObject strong, DrawableHitObject mainObject)
|
||||
protected DrawableStrongHandler(StrongHitObject strong, DrawableHitObject mainObject)
|
||||
: base(strong)
|
||||
{
|
||||
MainObject = mainObject;
|
@ -1,67 +0,0 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
{
|
||||
public class DrawableStrongHit : DrawableStrongHitObject
|
||||
{
|
||||
/// <summary>
|
||||
/// The lenience for the second key press.
|
||||
/// This does not adjust by map difficulty in ScoreV2 yet.
|
||||
/// </summary>
|
||||
private const double second_hit_window = 30;
|
||||
|
||||
public DrawableHit MainObject => (DrawableHit)base.MainObject;
|
||||
|
||||
public DrawableStrongHit(StrongHitObject strong, DrawableHit hit)
|
||||
: base(strong, hit)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void CheckForJudgements(bool userTriggered, double timeOffset)
|
||||
{
|
||||
if (!MainObject.Result.HasResult)
|
||||
{
|
||||
base.CheckForJudgements(userTriggered, timeOffset);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!MainObject.Result.IsHit)
|
||||
{
|
||||
ApplyResult(r => r.Type = HitResult.Miss);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!userTriggered)
|
||||
{
|
||||
if (timeOffset > second_hit_window)
|
||||
ApplyResult(r => r.Type = HitResult.Miss);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Math.Abs(MainObject.Result.TimeOffset - timeOffset) < second_hit_window)
|
||||
ApplyResult(r => r.Type = HitResult.Great);
|
||||
}
|
||||
|
||||
public override bool OnPressed(TaikoAction action)
|
||||
{
|
||||
// Don't process actions until the main hitobject is hit
|
||||
if (!MainObject.IsHit)
|
||||
return false;
|
||||
|
||||
// Don't process actions if the pressed button was released
|
||||
if (MainObject.HitAction == null)
|
||||
return false;
|
||||
|
||||
// Don't handle invalid hit action presses
|
||||
if (!MainObject.HitActions.Contains(action))
|
||||
return false;
|
||||
|
||||
return UpdateJudgement(true);
|
||||
}
|
||||
}
|
||||
}
|
@ -105,7 +105,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
var strongObject = HitObject.NestedHitObjects.OfType<StrongHitObject>().FirstOrDefault();
|
||||
if (strongObject != null)
|
||||
{
|
||||
var vis = CreateStrongObject(strongObject);
|
||||
var vis = CreateStrongHandler(strongObject);
|
||||
if (vis != null)
|
||||
{
|
||||
AddNested(vis);
|
||||
@ -121,6 +121,12 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
|
||||
protected virtual TaikoPiece CreateMainPiece() => new CirclePiece();
|
||||
|
||||
protected virtual DrawableStrongHitObject CreateStrongObject(StrongHitObject hitObject) => null;
|
||||
/// <summary>
|
||||
/// Creates the handler for this <see cref="DrawableHitObject"/>'s <see cref="StrongHitObject"/>.
|
||||
/// This is only invoked if <see cref="TaikoHitObject.IsStrong"/> is true for <see cref="HitObject"/>.
|
||||
/// </summary>
|
||||
/// <param name="hitObject">The strong hitobject.</param>
|
||||
/// <returns>The strong hitobject handler.</returns>
|
||||
protected virtual DrawableStrongHandler CreateStrongHandler(StrongHitObject hitObject) => null;
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,6 @@ namespace osu.Game.Rulesets.Taiko.Objects
|
||||
{
|
||||
public class StrongHitObject : TaikoHitObject
|
||||
{
|
||||
protected override Judgement CreateJudgement() => new TaikoStrongHitJudgement();
|
||||
protected override Judgement CreateJudgement() => new TaikoStrongJudgement();
|
||||
}
|
||||
}
|
||||
|
@ -234,9 +234,9 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
|
||||
switch (result.Judgement)
|
||||
{
|
||||
case TaikoStrongHitJudgement _:
|
||||
case TaikoStrongJudgement _:
|
||||
if (result.IsHit)
|
||||
hitExplosionContainer.Children.FirstOrDefault(e => e.JudgedObject == ((DrawableStrongHitObject)judgedObject).MainObject)?.VisualiseSecondHit();
|
||||
hitExplosionContainer.Children.FirstOrDefault(e => e.JudgedObject == ((DrawableStrongHandler)judgedObject).MainObject)?.VisualiseSecondHit();
|
||||
break;
|
||||
default:
|
||||
judgementContainer.Add(new DrawableTaikoJudgement(result, judgedObject)
|
||||
|
Loading…
Reference in New Issue
Block a user