mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 22:56:36 +09:00
Update taiko InputDrum
to use new trigger logic
This commit is contained in:
@ -2,18 +2,19 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osuTK;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Taiko.Audio;
|
||||
using osu.Game.Rulesets.Taiko.Objects;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Skinning;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.UI
|
||||
{
|
||||
@ -25,11 +26,11 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
private const float middle_split = 0.025f;
|
||||
|
||||
[Cached]
|
||||
private DrumSampleContainer sampleContainer;
|
||||
private DrumSampleTriggerSource sampleTriggerSource;
|
||||
|
||||
public InputDrum(ControlPointInfo controlPoints)
|
||||
public InputDrum(HitObjectContainer hitObjectContainer)
|
||||
{
|
||||
sampleContainer = new DrumSampleContainer(controlPoints);
|
||||
sampleTriggerSource = new DrumSampleTriggerSource(hitObjectContainer);
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
}
|
||||
@ -70,7 +71,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
}
|
||||
}
|
||||
}),
|
||||
sampleContainer
|
||||
sampleTriggerSource
|
||||
};
|
||||
}
|
||||
|
||||
@ -95,7 +96,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
private readonly Sprite centreHit;
|
||||
|
||||
[Resolved]
|
||||
private DrumSampleContainer sampleContainer { get; set; }
|
||||
private DrumSampleTriggerSource sampleTriggerSource { get; set; }
|
||||
|
||||
public TaikoHalfDrum(bool flipped)
|
||||
{
|
||||
@ -156,21 +157,19 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
Drawable target = null;
|
||||
Drawable back = null;
|
||||
|
||||
var drumSample = sampleContainer.SampleAt(Time.Current);
|
||||
|
||||
if (action == CentreAction)
|
||||
{
|
||||
target = centreHit;
|
||||
back = centre;
|
||||
|
||||
drumSample.Centre?.Play();
|
||||
sampleTriggerSource.Play(HitType.Centre);
|
||||
}
|
||||
else if (action == RimAction)
|
||||
{
|
||||
target = rimHit;
|
||||
back = rim;
|
||||
|
||||
drumSample.Rim?.Play();
|
||||
sampleTriggerSource.Play(HitType.Rim);
|
||||
}
|
||||
|
||||
if (target != null)
|
||||
@ -201,5 +200,25 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class DrumSampleTriggerSource : GameplaySampleTriggerSource
|
||||
{
|
||||
public DrumSampleTriggerSource(HitObjectContainer hitObjectContainer)
|
||||
: base(hitObjectContainer)
|
||||
{
|
||||
}
|
||||
|
||||
public void Play(HitType hitType)
|
||||
{
|
||||
var hitObject = GetMostValidObject();
|
||||
|
||||
if (hitObject == null)
|
||||
return;
|
||||
|
||||
PlaySamples(new ISampleInfo[] { hitObject.SampleControlPoint.GetSampleInfo(hitType == HitType.Rim ? HitSampleInfo.HIT_CLAP : HitSampleInfo.HIT_NORMAL) });
|
||||
}
|
||||
|
||||
public override void Play() => throw new InvalidOperationException(@"Use override with HitType parameter instead");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user