2019-01-24 16:43:03 +08: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 17:19:50 +08:00
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2023-04-30 05:52:24 +08:00
|
|
|
|
using System.Linq;
|
2017-04-18 15:05:58 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
2020-05-15 17:07:41 +08:00
|
|
|
|
using System.Threading;
|
2023-04-26 23:55:38 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2023-04-30 05:52:24 +08:00
|
|
|
|
using osu.Game.Audio;
|
2017-07-26 12:22:46 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
2017-05-23 12:55:18 +08:00
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
2021-08-30 13:40:25 +08:00
|
|
|
|
using osu.Game.Beatmaps.Formats;
|
2018-11-29 09:56:19 +08:00
|
|
|
|
using osu.Game.Rulesets.Judgements;
|
2020-04-21 15:45:01 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2019-09-06 14:24:00 +08:00
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2020-04-21 15:45:01 +08:00
|
|
|
|
using osuTK;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-04-18 15:05:58 +08:00
|
|
|
|
namespace osu.Game.Rulesets.Taiko.Objects
|
2017-03-17 12:56:14 +08:00
|
|
|
|
{
|
2023-04-26 23:55:38 +08:00
|
|
|
|
public class DrumRoll : TaikoStrongableHitObject, IHasPath, IHasSliderVelocity
|
2017-03-17 12:56:14 +08:00
|
|
|
|
{
|
2017-04-03 13:10:20 +08: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 17:19:50 +08:00
|
|
|
|
|
2020-02-05 16:12:26 +08:00
|
|
|
|
public double EndTime
|
|
|
|
|
{
|
|
|
|
|
get => StartTime + Duration;
|
|
|
|
|
set => Duration = value - StartTime;
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-04-05 12:52:53 +08:00
|
|
|
|
public double Duration { get; set; }
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-04-21 15:45:01 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Velocity of this <see cref="DrumRoll"/>.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public double Velocity { get; private set; }
|
|
|
|
|
|
2023-05-01 01:32:24 +08:00
|
|
|
|
public BindableNumber<double> SliderVelocityBindable { get; } = new BindableDouble(1)
|
|
|
|
|
{
|
|
|
|
|
Precision = 0.01,
|
|
|
|
|
MinValue = 0.1,
|
|
|
|
|
MaxValue = 10
|
|
|
|
|
};
|
2023-04-26 23:55:38 +08:00
|
|
|
|
|
|
|
|
|
public double SliderVelocity
|
|
|
|
|
{
|
|
|
|
|
get => SliderVelocityBindable.Value;
|
|
|
|
|
set => SliderVelocityBindable.Value = value;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-17 12:56:14 +08:00
|
|
|
|
/// <summary>
|
2017-04-03 14:32:38 +08:00
|
|
|
|
/// Numer of ticks per beat length.
|
2017-03-17 12:56:14 +08:00
|
|
|
|
/// </summary>
|
2017-04-03 14:32:38 +08:00
|
|
|
|
public int TickRate = 1;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-04-03 14:32:38 +08: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 19:01:16 +08:00
|
|
|
|
private double tickSpacing = 100;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-10-01 13:56:42 +08:00
|
|
|
|
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, IBeatmapDifficultyInfo difficulty)
|
2017-03-17 12:56:14 +08:00
|
|
|
|
{
|
2017-12-22 20:42:54 +08:00
|
|
|
|
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-05-23 12:55:18 +08:00
|
|
|
|
TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);
|
2020-04-21 15:45:01 +08:00
|
|
|
|
|
2023-04-26 23:55:38 +08:00
|
|
|
|
double scoringDistance = base_distance * difficulty.SliderMultiplier * SliderVelocity;
|
2020-04-21 15:45:01 +08:00
|
|
|
|
Velocity = scoringDistance / timingPoint.BeatLength;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-06-24 19:01:16 +08:00
|
|
|
|
tickSpacing = timingPoint.BeatLength / TickRate;
|
2017-03-17 12:56:14 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-05-15 17:07:41 +08:00
|
|
|
|
protected override void CreateNestedHitObjects(CancellationToken cancellationToken)
|
2017-03-17 12:56:14 +08:00
|
|
|
|
{
|
2022-08-05 22:30:07 +08:00
|
|
|
|
createTicks(cancellationToken);
|
2018-08-03 15:11:57 +08:00
|
|
|
|
|
2020-05-15 17:07:41 +08:00
|
|
|
|
base.CreateNestedHitObjects(cancellationToken);
|
2017-12-22 20:42:54 +08:00
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2022-08-05 22:30:07 +08:00
|
|
|
|
private void createTicks(CancellationToken cancellationToken)
|
2017-12-22 20:42:54 +08:00
|
|
|
|
{
|
2022-06-24 19:01:16 +08:00
|
|
|
|
if (tickSpacing == 0)
|
2022-08-05 22:30:07 +08:00
|
|
|
|
return;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-03-17 12:56:14 +08:00
|
|
|
|
bool first = true;
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2022-06-24 19:01:16 +08:00
|
|
|
|
for (double t = StartTime; t < EndTime + tickSpacing / 2; t += tickSpacing)
|
2017-03-17 12:56:14 +08:00
|
|
|
|
{
|
2020-05-15 18:25:14 +08:00
|
|
|
|
cancellationToken.ThrowIfCancellationRequested();
|
|
|
|
|
|
2022-08-05 22:30:07 +08:00
|
|
|
|
AddNested(new DrumRollTick
|
2017-03-17 12:56:14 +08:00
|
|
|
|
{
|
|
|
|
|
FirstTick = first,
|
2022-06-24 19:01:16 +08:00
|
|
|
|
TickSpacing = tickSpacing,
|
2017-03-17 12:56:14 +08:00
|
|
|
|
StartTime = t,
|
2023-04-30 05:52:24 +08:00
|
|
|
|
IsStrong = IsStrong,
|
|
|
|
|
Samples = Samples.Where(s => s.Name == HitSampleInfo.HIT_FINISH).ToList()
|
2017-12-22 20:42:54 +08:00
|
|
|
|
});
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-03-17 12:56:14 +08:00
|
|
|
|
first = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-12-06 16:09:42 +08:00
|
|
|
|
|
2022-08-30 20:44:44 +08:00
|
|
|
|
public override Judgement CreateJudgement() => new IgnoreJudgement();
|
2019-09-02 15:10:30 +08:00
|
|
|
|
|
2019-10-09 18:08:31 +08:00
|
|
|
|
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
2020-04-21 15:45:01 +08:00
|
|
|
|
|
2020-12-13 19:59:46 +08:00
|
|
|
|
protected override StrongNestedHitObject CreateStrongNestedHit(double startTime) => new StrongNestedHit { StartTime = startTime };
|
|
|
|
|
|
|
|
|
|
public class StrongNestedHit : StrongNestedHitObject
|
|
|
|
|
{
|
2022-09-06 16:27:29 +08:00
|
|
|
|
// The strong hit of the drum roll doesn't actually provide any score.
|
|
|
|
|
public override Judgement CreateJudgement() => new IgnoreJudgement();
|
2020-12-13 19:59:46 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-21 15:45:01 +08:00
|
|
|
|
#region LegacyBeatmapEncoder
|
|
|
|
|
|
|
|
|
|
double IHasDistance.Distance => Duration * Velocity;
|
|
|
|
|
|
2020-05-26 16:44:47 +08:00
|
|
|
|
SliderPath IHasPath.Path
|
2021-08-30 13:40:25 +08:00
|
|
|
|
=> new SliderPath(PathType.Linear, new[] { Vector2.Zero, new Vector2(1) }, ((IHasDistance)this).Distance / LegacyBeatmapEncoder.LEGACY_TAIKO_VELOCITY_MULTIPLIER);
|
2020-04-21 15:45:01 +08:00
|
|
|
|
|
|
|
|
|
#endregion
|
2017-03-17 12:56:14 +08:00
|
|
|
|
}
|
2017-12-21 15:02:33 +08:00
|
|
|
|
}
|