2019-01-24 08:43:03 +00:00
|
|
|
|
// 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.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-04-18 07:05:58 +00:00
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
2020-05-15 09:07:41 +00:00
|
|
|
|
using System.Threading;
|
2023-04-26 15:55:38 +00:00
|
|
|
|
using osu.Framework.Bindables;
|
2017-07-26 04:22:46 +00:00
|
|
|
|
using osu.Game.Beatmaps;
|
2017-05-23 04:55:18 +00:00
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
2021-08-30 05:40:25 +00:00
|
|
|
|
using osu.Game.Beatmaps.Formats;
|
2018-11-29 01:56:19 +00:00
|
|
|
|
using osu.Game.Rulesets.Judgements;
|
2020-04-21 07:45:01 +00:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2019-09-06 06:24:00 +00:00
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2020-04-21 07:45:01 +00:00
|
|
|
|
using osuTK;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-04-18 07:05:58 +00:00
|
|
|
|
namespace osu.Game.Rulesets.Taiko.Objects
|
2017-03-17 04:56:14 +00:00
|
|
|
|
{
|
2023-04-26 15:55:38 +00:00
|
|
|
|
public class DrumRoll : TaikoStrongableHitObject, IHasPath, IHasSliderVelocity
|
2017-03-17 04:56:14 +00:00
|
|
|
|
{
|
2017-04-03 05:10:20 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Drum roll distance that results in a duration of 1 speed-adjusted beat length.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private const float base_distance = 100;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-02-05 08:12:26 +00:00
|
|
|
|
public double EndTime
|
|
|
|
|
{
|
|
|
|
|
get => StartTime + Duration;
|
|
|
|
|
set => Duration = value - StartTime;
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-04-05 04:52:53 +00:00
|
|
|
|
public double Duration { get; set; }
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-04-21 07:45:01 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Velocity of this <see cref="DrumRoll"/>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public double Velocity { get; private set; }
|
|
|
|
|
|
2023-04-30 17:32:24 +00:00
|
|
|
|
public BindableNumber<double> SliderVelocityBindable { get; } = new BindableDouble(1)
|
|
|
|
|
{
|
|
|
|
|
Precision = 0.01,
|
|
|
|
|
MinValue = 0.1,
|
|
|
|
|
MaxValue = 10
|
|
|
|
|
};
|
2023-04-26 15:55:38 +00:00
|
|
|
|
|
|
|
|
|
public double SliderVelocity
|
|
|
|
|
{
|
|
|
|
|
get => SliderVelocityBindable.Value;
|
|
|
|
|
set => SliderVelocityBindable.Value = value;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-17 04:56:14 +00:00
|
|
|
|
/// <summary>
|
2017-04-03 06:32:38 +00:00
|
|
|
|
/// Numer of ticks per beat length.
|
2017-03-17 04:56:14 +00:00
|
|
|
|
/// </summary>
|
2017-04-03 06:32:38 +00:00
|
|
|
|
public int TickRate = 1;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-04-03 06:32:38 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The length (in milliseconds) between ticks of this drumroll.
|
|
|
|
|
/// <para>Half of this value is the hit window of the ticks.</para>
|
|
|
|
|
/// </summary>
|
2022-06-24 11:01:16 +00:00
|
|
|
|
private double tickSpacing = 100;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2021-10-01 05:56:42 +00:00
|
|
|
|
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, IBeatmapDifficultyInfo difficulty)
|
2017-03-17 04:56:14 +00:00
|
|
|
|
{
|
2017-12-22 12:42:54 +00:00
|
|
|
|
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-05-23 04:55:18 +00:00
|
|
|
|
TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);
|
2020-04-21 07:45:01 +00:00
|
|
|
|
|
2023-04-26 15:55:38 +00:00
|
|
|
|
double scoringDistance = base_distance * difficulty.SliderMultiplier * SliderVelocity;
|
2020-04-21 07:45:01 +00:00
|
|
|
|
Velocity = scoringDistance / timingPoint.BeatLength;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2023-06-06 07:54:33 +00:00
|
|
|
|
TickRate = difficulty.SliderTickRate == 3 ? 3 : 4;
|
|
|
|
|
|
2022-06-24 11:01:16 +00:00
|
|
|
|
tickSpacing = timingPoint.BeatLength / TickRate;
|
2017-03-17 04:56:14 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-05-15 09:07:41 +00:00
|
|
|
|
protected override void CreateNestedHitObjects(CancellationToken cancellationToken)
|
2017-03-17 04:56:14 +00:00
|
|
|
|
{
|
2022-08-05 14:30:07 +00:00
|
|
|
|
createTicks(cancellationToken);
|
2018-08-03 07:11:57 +00:00
|
|
|
|
|
2020-05-15 09:07:41 +00:00
|
|
|
|
base.CreateNestedHitObjects(cancellationToken);
|
2017-12-22 12:42:54 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2022-08-05 14:30:07 +00:00
|
|
|
|
private void createTicks(CancellationToken cancellationToken)
|
2017-12-22 12:42:54 +00:00
|
|
|
|
{
|
2022-06-24 11:01:16 +00:00
|
|
|
|
if (tickSpacing == 0)
|
2022-08-05 14:30:07 +00:00
|
|
|
|
return;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-03-17 04:56:14 +00:00
|
|
|
|
bool first = true;
|
2019-04-01 03:16:05 +00:00
|
|
|
|
|
2023-06-08 07:56:39 +00:00
|
|
|
|
for (double t = StartTime; t < EndTime + tickSpacing / 2; t += tickSpacing)
|
2017-03-17 04:56:14 +00:00
|
|
|
|
{
|
2020-05-15 10:25:14 +00:00
|
|
|
|
cancellationToken.ThrowIfCancellationRequested();
|
|
|
|
|
|
2022-08-05 14:30:07 +00:00
|
|
|
|
AddNested(new DrumRollTick
|
2017-03-17 04:56:14 +00:00
|
|
|
|
{
|
|
|
|
|
FirstTick = first,
|
2022-06-24 11:01:16 +00:00
|
|
|
|
TickSpacing = tickSpacing,
|
2017-03-17 04:56:14 +00:00
|
|
|
|
StartTime = t,
|
2023-04-29 21:52:24 +00:00
|
|
|
|
IsStrong = IsStrong,
|
Propagate samples to drum roll/swell ticks for correct playback
In d97daee96be2c10f90709cc30beceb1f369ae225, `DrumSampleTriggerSource`
was changed such that in order to play sounds for the user's inputs, the
bank of the normal sound would always be used.
The problem is that in the case of taiko objects which have nested
objects (swells and drum rolls), the samples were not propagated fully
(drum rolls, where only the finish sample was kept, for the purposes of
determining strongability), or not propagated at all (swells) to ticks.
As ticks of both objects are valid return values of
`GetMostValidHitObject()`, this would lead to the drum making no sounds
if the next object was a drum roll or swell, until that drum roll or
swell was completed. To fix, propagate the full set of samples, so that
`DrumSampleTriggerSource` can retrieve the normal sound to copy the bank
from.
Note that this may not necessarily reproduce prior behaviour. This is
because it is not guaranteed that all realised samples for a given
hitobject have the same bank - some may have been overriden locally on a
given hitobject. Previously, the bank would have been retrieved from the
sample control point, wherein there is only one possible bank to use;
however, when deciding the sound to play on the basis of a constructed
hitobject, it is possible that there are cases wherein the hitnormal
sample was overridden on that given hitobject, and in such cases, this
PR would make samples _play_, but not necessarily the _same_ samples
as prior to #23308.
If that turns out to be the case, this will have to be revisited.
2023-05-21 14:49:17 +00:00
|
|
|
|
Samples = Samples
|
2017-12-22 12:42:54 +00:00
|
|
|
|
});
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-03-17 04:56:14 +00:00
|
|
|
|
first = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-12-06 08:09:42 +00:00
|
|
|
|
|
2022-08-30 12:44:44 +00:00
|
|
|
|
public override Judgement CreateJudgement() => new IgnoreJudgement();
|
2019-09-02 07:10:30 +00:00
|
|
|
|
|
2019-10-09 10:08:31 +00:00
|
|
|
|
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
2020-04-21 07:45:01 +00:00
|
|
|
|
|
2023-05-23 10:07:54 +00:00
|
|
|
|
protected override StrongNestedHitObject CreateStrongNestedHit(double startTime) => new StrongNestedHit(this)
|
2023-05-21 16:28:30 +00:00
|
|
|
|
{
|
|
|
|
|
StartTime = startTime,
|
|
|
|
|
Samples = Samples
|
|
|
|
|
};
|
2020-12-13 11:59:46 +00:00
|
|
|
|
|
|
|
|
|
public class StrongNestedHit : StrongNestedHitObject
|
|
|
|
|
{
|
2022-09-06 08:27:29 +00:00
|
|
|
|
// The strong hit of the drum roll doesn't actually provide any score.
|
|
|
|
|
public override Judgement CreateJudgement() => new IgnoreJudgement();
|
2023-05-09 10:30:54 +00:00
|
|
|
|
|
|
|
|
|
public StrongNestedHit(TaikoHitObject parent)
|
|
|
|
|
: base(parent)
|
|
|
|
|
{
|
|
|
|
|
}
|
2020-12-13 11:59:46 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-21 07:45:01 +00:00
|
|
|
|
#region LegacyBeatmapEncoder
|
|
|
|
|
|
|
|
|
|
double IHasDistance.Distance => Duration * Velocity;
|
|
|
|
|
|
2020-05-26 08:44:47 +00:00
|
|
|
|
SliderPath IHasPath.Path
|
2021-08-30 05:40:25 +00:00
|
|
|
|
=> new SliderPath(PathType.Linear, new[] { Vector2.Zero, new Vector2(1) }, ((IHasDistance)this).Distance / LegacyBeatmapEncoder.LEGACY_TAIKO_VELOCITY_MULTIPLIER);
|
2020-04-21 07:45:01 +00:00
|
|
|
|
|
|
|
|
|
#endregion
|
2017-03-17 04:56:14 +00:00
|
|
|
|
}
|
2017-12-21 07:02:33 +00:00
|
|
|
|
}
|