mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 01:42:55 +08:00
Move strong hit handling to DrumSamplePlayer
and separte trigger sources
This commit is contained in:
parent
27af07b74b
commit
a9587fd1aa
@ -195,7 +195,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
/// 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 const double SECOND_HIT_WINDOW = 30;
|
||||
|
||||
public StrongNestedHit()
|
||||
: this(null)
|
||||
@ -223,12 +223,12 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
|
||||
if (!userTriggered)
|
||||
{
|
||||
if (timeOffset - ParentHitObject.Result.TimeOffset > second_hit_window)
|
||||
if (timeOffset - ParentHitObject.Result.TimeOffset > SECOND_HIT_WINDOW)
|
||||
ApplyResult(r => r.Type = r.Judgement.MinResult);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Math.Abs(timeOffset - ParentHitObject.Result.TimeOffset) <= second_hit_window)
|
||||
if (Math.Abs(timeOffset - ParentHitObject.Result.TimeOffset) <= SECOND_HIT_WINDOW)
|
||||
ApplyResult(r => r.Type = r.Judgement.MaxResult);
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@ using osu.Game.Skinning;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Skinning.Argon
|
||||
{
|
||||
public partial class ArgonDrumSamplePlayer : DrumSamplePlayer
|
||||
internal partial class ArgonDrumSamplePlayer : DrumSamplePlayer
|
||||
{
|
||||
protected override DrumSampleTriggerSource CreateTriggerSource(HitObjectContainer hitObjectContainer, SampleBalance balance) =>
|
||||
new ArgonDrumSampleTriggerSource(hitObjectContainer, balance);
|
||||
@ -45,6 +45,7 @@ namespace osu.Game.Rulesets.Taiko.Skinning.Argon
|
||||
|
||||
// let the magic begin...
|
||||
|
||||
// TODO: should we only play strong samples if the user correctly hits them? arguable.
|
||||
if ((hitObject as TaikoStrongableHitObject)?.IsStrong == true || hitObject is StrongNestedHitObject)
|
||||
{
|
||||
PlaySamples(new ISampleInfo[]
|
||||
|
@ -7,28 +7,35 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Rulesets.Taiko.Objects;
|
||||
using osu.Game.Rulesets.Taiko.Objects.Drawables;
|
||||
using osu.Game.Rulesets.UI;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.UI
|
||||
{
|
||||
public partial class DrumSamplePlayer : CompositeDrawable, IKeyBindingHandler<TaikoAction>
|
||||
internal partial class DrumSamplePlayer : CompositeDrawable, IKeyBindingHandler<TaikoAction>
|
||||
{
|
||||
private DrumSampleTriggerSource leftRimSampleTriggerSource = null!;
|
||||
private DrumSampleTriggerSource leftCentreSampleTriggerSource = null!;
|
||||
private DrumSampleTriggerSource rightCentreSampleTriggerSource = null!;
|
||||
private DrumSampleTriggerSource rightRimSampleTriggerSource = null!;
|
||||
private DrumSampleTriggerSource leftCentreTrigger = null!;
|
||||
private DrumSampleTriggerSource rightCentreTrigger = null!;
|
||||
private DrumSampleTriggerSource leftRimTrigger = null!;
|
||||
private DrumSampleTriggerSource rightRimTrigger = null!;
|
||||
private DrumSampleTriggerSource strongCentreTrigger = null!;
|
||||
private DrumSampleTriggerSource strongRimTrigger = null!;
|
||||
|
||||
private double lastHitTime;
|
||||
private TaikoAction? lastAction;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(DrawableRuleset drawableRuleset)
|
||||
{
|
||||
var hitObjectContainer = drawableRuleset.Playfield.HitObjectContainer;
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
leftRimSampleTriggerSource = CreateTriggerSource(hitObjectContainer, SampleBalance.Left),
|
||||
leftCentreSampleTriggerSource = CreateTriggerSource(hitObjectContainer, SampleBalance.Left),
|
||||
rightCentreSampleTriggerSource = CreateTriggerSource(hitObjectContainer, SampleBalance.Right),
|
||||
rightRimSampleTriggerSource = CreateTriggerSource(hitObjectContainer, SampleBalance.Right),
|
||||
leftCentreTrigger = CreateTriggerSource(hitObjectContainer, SampleBalance.Left),
|
||||
rightCentreTrigger = CreateTriggerSource(hitObjectContainer, SampleBalance.Right),
|
||||
leftRimTrigger = CreateTriggerSource(hitObjectContainer, SampleBalance.Left),
|
||||
rightRimTrigger = CreateTriggerSource(hitObjectContainer, SampleBalance.Right),
|
||||
strongCentreTrigger = CreateTriggerSource(hitObjectContainer, SampleBalance.Centre),
|
||||
strongRimTrigger = CreateTriggerSource(hitObjectContainer, SampleBalance.Centre)
|
||||
};
|
||||
}
|
||||
|
||||
@ -37,28 +44,93 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
|
||||
public bool OnPressed(KeyBindingPressEvent<TaikoAction> e)
|
||||
{
|
||||
HitType hitType;
|
||||
|
||||
DrumSampleTriggerSource triggerSource;
|
||||
|
||||
bool strong = checkStrongValidity(e.Action, lastAction, Time.Current - lastHitTime);
|
||||
|
||||
switch (e.Action)
|
||||
{
|
||||
case TaikoAction.LeftRim:
|
||||
leftRimSampleTriggerSource.Play(HitType.Rim);
|
||||
break;
|
||||
|
||||
case TaikoAction.LeftCentre:
|
||||
leftCentreSampleTriggerSource.Play(HitType.Centre);
|
||||
hitType = HitType.Centre;
|
||||
triggerSource = strong ? strongCentreTrigger : leftCentreTrigger;
|
||||
break;
|
||||
|
||||
case TaikoAction.RightCentre:
|
||||
rightCentreSampleTriggerSource.Play(HitType.Centre);
|
||||
hitType = HitType.Centre;
|
||||
triggerSource = strong ? strongCentreTrigger : rightCentreTrigger;
|
||||
break;
|
||||
|
||||
case TaikoAction.LeftRim:
|
||||
hitType = HitType.Rim;
|
||||
triggerSource = strong ? strongRimTrigger : leftRimTrigger;
|
||||
break;
|
||||
|
||||
case TaikoAction.RightRim:
|
||||
rightRimSampleTriggerSource.Play(HitType.Rim);
|
||||
hitType = HitType.Rim;
|
||||
triggerSource = strong ? strongRimTrigger : rightRimTrigger;
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strong && hitType == HitType.Centre)
|
||||
flushCenterTriggerSources();
|
||||
|
||||
if (strong && hitType == HitType.Rim)
|
||||
flushRimTriggerSources();
|
||||
|
||||
triggerSource.Play(hitType);
|
||||
|
||||
lastHitTime = Time.Current;
|
||||
lastAction = e.Action;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool checkStrongValidity(TaikoAction newAction, TaikoAction? lastAction, double timeBetweenActions)
|
||||
{
|
||||
if (lastAction == null)
|
||||
return false;
|
||||
|
||||
if (timeBetweenActions > DrawableHit.StrongNestedHit.SECOND_HIT_WINDOW)
|
||||
return false;
|
||||
|
||||
switch (newAction)
|
||||
{
|
||||
case TaikoAction.LeftCentre:
|
||||
return lastAction == TaikoAction.RightCentre;
|
||||
|
||||
case TaikoAction.RightCentre:
|
||||
return lastAction == TaikoAction.LeftCentre;
|
||||
|
||||
case TaikoAction.LeftRim:
|
||||
return lastAction == TaikoAction.RightRim;
|
||||
|
||||
case TaikoAction.RightRim:
|
||||
return lastAction == TaikoAction.LeftRim;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void flushCenterTriggerSources()
|
||||
{
|
||||
leftCentreTrigger.StopAllPlayback();
|
||||
rightCentreTrigger.StopAllPlayback();
|
||||
strongCentreTrigger.StopAllPlayback();
|
||||
}
|
||||
|
||||
private void flushRimTriggerSources()
|
||||
{
|
||||
leftRimTrigger.StopAllPlayback();
|
||||
rightRimTrigger.StopAllPlayback();
|
||||
strongRimTrigger.StopAllPlayback();
|
||||
}
|
||||
|
||||
public void OnReleased(KeyBindingReleaseEvent<TaikoAction> e)
|
||||
{
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
|
||||
var baseSample = hitObject.CreateHitSampleInfo(hitType == HitType.Rim ? HitSampleInfo.HIT_CLAP : HitSampleInfo.HIT_NORMAL);
|
||||
|
||||
// TODO: should we only play strong samples if the user correctly hits them? arguable.
|
||||
if ((hitObject as TaikoStrongableHitObject)?.IsStrong == true || hitObject is StrongNestedHitObject)
|
||||
{
|
||||
PlaySamples(new ISampleInfo[]
|
||||
|
Loading…
Reference in New Issue
Block a user