mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 18:03:11 +08:00
Combine hit types and remove old drumroll hits using a more efficient method
This commit is contained in:
parent
ff736a22dd
commit
b9f28c8373
@ -21,8 +21,6 @@ namespace osu.Game.Rulesets.Taiko.Tests.Skinning
|
||||
public override IReadOnlyList<Type> RequiredTypes => base.RequiredTypes.Concat(new[]
|
||||
{
|
||||
typeof(DrawableHit),
|
||||
typeof(DrawableCentreHit),
|
||||
typeof(DrawableRimHit),
|
||||
typeof(LegacyHit),
|
||||
typeof(LegacyCirclePiece),
|
||||
}).ToList();
|
||||
@ -30,25 +28,25 @@ namespace osu.Game.Rulesets.Taiko.Tests.Skinning
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
AddStep("Centre hit", () => SetContents(() => new DrawableCentreHit(createHitAtCurrentTime())
|
||||
AddStep("Centre hit", () => SetContents(() => new DrawableHit(createHitAtCurrentTime())
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
}));
|
||||
|
||||
AddStep("Centre hit (strong)", () => SetContents(() => new DrawableCentreHit(createHitAtCurrentTime(true))
|
||||
AddStep("Centre hit (strong)", () => SetContents(() => new DrawableHit(createHitAtCurrentTime(true))
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
}));
|
||||
|
||||
AddStep("Rim hit", () => SetContents(() => new DrawableRimHit(createHitAtCurrentTime())
|
||||
AddStep("Rim hit", () => SetContents(() => new DrawableHit(createHitAtCurrentTime())
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
}));
|
||||
|
||||
AddStep("Rim hit (strong)", () => SetContents(() => new DrawableRimHit(createHitAtCurrentTime(true))
|
||||
AddStep("Rim hit (strong)", () => SetContents(() => new DrawableHit(createHitAtCurrentTime(true))
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
|
@ -224,7 +224,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
||||
|
||||
h.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
||||
|
||||
drawableRuleset.Playfield.Add(new DrawableCentreHit(h));
|
||||
drawableRuleset.Playfield.Add(new DrawableHit(h));
|
||||
}
|
||||
|
||||
private void addRimHit(bool strong)
|
||||
@ -237,7 +237,7 @@ namespace osu.Game.Rulesets.Taiko.Tests
|
||||
|
||||
h.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
||||
|
||||
drawableRuleset.Playfield.Add(new DrawableRimHit(h));
|
||||
drawableRuleset.Playfield.Add(new DrawableHit(h));
|
||||
}
|
||||
|
||||
private class TestStrongNestedHit : DrawableStrongNestedHit
|
||||
|
@ -1,21 +0,0 @@
|
||||
// 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.Game.Rulesets.Taiko.Objects.Drawables.Pieces;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
{
|
||||
public class DrawableCentreHit : DrawableHit
|
||||
{
|
||||
public override TaikoAction[] HitActions { get; } = { TaikoAction.LeftCentre, TaikoAction.RightCentre };
|
||||
|
||||
public DrawableCentreHit(Hit hit)
|
||||
: base(hit)
|
||||
{
|
||||
}
|
||||
|
||||
protected override SkinnableDrawable CreateMainPiece() => new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.CentreHit),
|
||||
_ => new CentreHitCirclePiece(), confineMode: ConfineMode.ScaleToFit);
|
||||
}
|
||||
}
|
@ -6,7 +6,10 @@ using osu.Game.Beatmaps.ControlPoints;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
{
|
||||
public class DrawableFlyingCentreHit : DrawableCentreHit
|
||||
/// <summary>
|
||||
/// A hit used specifically for drum rolls, where spawning flying hits is required.
|
||||
/// </summary>
|
||||
public class DrawableFlyingHit : DrawableHit
|
||||
{
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
@ -14,7 +17,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
ApplyResult(r => r.Type = r.Judgement.MaxResult);
|
||||
}
|
||||
|
||||
public DrawableFlyingCentreHit(double time, bool isStrong = false)
|
||||
public DrawableFlyingHit(double time, bool isStrong = false)
|
||||
: base(new IgnoreHit { StartTime = time, IsStrong = isStrong })
|
||||
{
|
||||
HitObject.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
@ -1,23 +0,0 @@
|
||||
// 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.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
{
|
||||
public class DrawableFlyingRimHit : DrawableRimHit
|
||||
{
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
ApplyResult(r => r.Type = r.Judgement.MaxResult);
|
||||
}
|
||||
|
||||
public DrawableFlyingRimHit(double time, bool isStrong = false)
|
||||
: base(new IgnoreHit { StartTime = time, IsStrong = isStrong })
|
||||
{
|
||||
HitObject.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
||||
}
|
||||
}
|
||||
}
|
@ -8,31 +8,45 @@ using osu.Framework.Graphics;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.Taiko.Objects.Drawables.Pieces;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
{
|
||||
public abstract class DrawableHit : DrawableTaikoHitObject<Hit>
|
||||
public class DrawableHit : DrawableTaikoHitObject<Hit>
|
||||
{
|
||||
/// <summary>
|
||||
/// A list of keys which can result in hits for this HitObject.
|
||||
/// </summary>
|
||||
public abstract TaikoAction[] HitActions { get; }
|
||||
public TaikoAction[] HitActions { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The action that caused this <see cref="DrawableHit"/> to be hit.
|
||||
/// </summary>
|
||||
public TaikoAction? HitAction { get; private set; }
|
||||
public TaikoAction? HitAction
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
private bool validActionPressed;
|
||||
|
||||
private bool pressHandledThisFrame;
|
||||
|
||||
protected DrawableHit(Hit hit)
|
||||
public DrawableHit(Hit hit)
|
||||
: base(hit)
|
||||
{
|
||||
FillMode = FillMode.Fit;
|
||||
|
||||
HitActions =
|
||||
HitObject.Type == HitType.Centre
|
||||
? new[] { TaikoAction.LeftCentre, TaikoAction.RightCentre }
|
||||
: new[] { TaikoAction.LeftRim, TaikoAction.RightRim };
|
||||
}
|
||||
|
||||
protected override SkinnableDrawable CreateMainPiece() => HitObject.Type == HitType.Centre
|
||||
? new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.CentreHit), _ => new CentreHitCirclePiece(), confineMode: ConfineMode.ScaleToFit)
|
||||
: new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.RimHit), _ => new RimHitCirclePiece(), confineMode: ConfineMode.ScaleToFit);
|
||||
|
||||
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
||||
{
|
||||
Debug.Assert(HitObject.HitWindows != null);
|
||||
@ -58,7 +72,6 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
{
|
||||
if (pressHandledThisFrame)
|
||||
return true;
|
||||
|
||||
if (Judged)
|
||||
return false;
|
||||
|
||||
@ -66,14 +79,12 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
|
||||
// Only count this as handled if the new judgement is a hit
|
||||
var result = UpdateResult(true);
|
||||
|
||||
if (IsHit)
|
||||
HitAction = action;
|
||||
|
||||
// Regardless of whether we've hit or not, any secondary key presses in the same frame should be discarded
|
||||
// E.g. hitting a non-strong centre as a strong should not fall through and perform a hit on the next note
|
||||
pressHandledThisFrame = true;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -81,7 +92,6 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
{
|
||||
if (action == HitAction)
|
||||
HitAction = null;
|
||||
|
||||
base.OnReleased(action);
|
||||
}
|
||||
|
||||
|
@ -1,21 +0,0 @@
|
||||
// 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.Game.Rulesets.Taiko.Objects.Drawables.Pieces;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
{
|
||||
public class DrawableRimHit : DrawableHit
|
||||
{
|
||||
public override TaikoAction[] HitActions { get; } = { TaikoAction.LeftRim, TaikoAction.RightRim };
|
||||
|
||||
public DrawableRimHit(Hit hit)
|
||||
: base(hit)
|
||||
{
|
||||
}
|
||||
|
||||
protected override SkinnableDrawable CreateMainPiece() => new SkinnableDrawable(new TaikoSkinComponent(TaikoSkinComponents.RimHit),
|
||||
_ => new RimHitCirclePiece(), confineMode: ConfineMode.ScaleToFit);
|
||||
}
|
||||
}
|
@ -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);
|
||||
|
35
osu.Game.Rulesets.Taiko/UI/DrumRollHitContainer.cs
Normal file
35
osu.Game.Rulesets.Taiko/UI/DrumRollHitContainer.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user