1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-24 06:43:03 +08:00
osu-lazer/osu.Game.Rulesets.Taiko/Objects/DrumRoll.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

127 lines
4.2 KiB
C#
Raw Normal View History

// 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
2017-04-18 15:05:58 +08:00
using osu.Game.Rulesets.Objects.Types;
2017-03-17 12:56:14 +08:00
using System;
using System.Threading;
2017-07-26 12:22:46 +08:00
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
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;
2018-11-29 09:56:19 +08:00
using osu.Game.Rulesets.Taiko.Judgements;
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
{
2020-12-15 04:46:02 +08:00
public class DrumRoll : TaikoStrongableHitObject, IHasPath
2017-03-17 12:56:14 +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; }
2017-03-17 12:56:14 +08:00
/// <summary>
/// Numer of ticks per beat length.
2017-03-17 12:56:14 +08:00
/// </summary>
public int TickRate = 1;
2018-04-13 17:19:50 +08:00
2017-03-17 12:56:14 +08:00
/// <summary>
/// Number of drum roll ticks required for a "Good" hit.
/// </summary>
2017-03-22 00:33:22 +08:00
public double RequiredGoodHits { get; protected set; }
2018-04-13 17:19:50 +08:00
2017-03-17 12:56:14 +08:00
/// <summary>
/// Number of drum roll ticks required for a "Great" hit.
/// </summary>
2017-03-22 00:33:22 +08:00
public double RequiredGreatHits { get; protected set; }
2018-04-13 17:19:50 +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>
private double tickSpacing = 100;
2018-04-13 17:19:50 +08:00
private float overallDifficulty = BeatmapDifficulty.DEFAULT_DIFFICULTY;
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, IBeatmapDifficultyInfo difficulty)
2017-03-17 12:56:14 +08:00
{
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
2018-04-13 17:19:50 +08:00
TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);
2020-04-21 15:45:01 +08:00
double scoringDistance = base_distance * difficulty.SliderMultiplier * DifficultyControlPoint.SliderVelocity;
2020-04-21 15:45:01 +08:00
Velocity = scoringDistance / timingPoint.BeatLength;
2018-04-13 17:19:50 +08:00
tickSpacing = timingPoint.BeatLength / TickRate;
overallDifficulty = difficulty.OverallDifficulty;
2017-03-17 12:56:14 +08:00
}
2018-04-13 17:19:50 +08:00
protected override void CreateNestedHitObjects(CancellationToken cancellationToken)
2017-03-17 12:56:14 +08:00
{
createTicks(cancellationToken);
RequiredGoodHits = NestedHitObjects.Count * Math.Min(0.15, 0.05 + 0.10 / 6 * overallDifficulty);
RequiredGreatHits = NestedHitObjects.Count * Math.Min(0.30, 0.10 + 0.20 / 6 * overallDifficulty);
base.CreateNestedHitObjects(cancellationToken);
}
2018-04-13 17:19:50 +08:00
private void createTicks(CancellationToken cancellationToken)
{
if (tickSpacing == 0)
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
2017-04-05 12:52:22 +08:00
for (double t = StartTime; t < EndTime + tickSpacing / 2; t += tickSpacing)
2017-03-17 12:56:14 +08:00
{
cancellationToken.ThrowIfCancellationRequested();
AddNested(new DrumRollTick
2017-03-17 12:56:14 +08:00
{
FirstTick = first,
TickSpacing = tickSpacing,
2017-03-17 12:56:14 +08:00
StartTime = t,
IsStrong = IsStrong
});
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
public override Judgement CreateJudgement() => new TaikoDrumRollJudgement();
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
{
}
2020-04-21 15:45:01 +08:00
#region LegacyBeatmapEncoder
double IHasDistance.Distance => Duration * Velocity;
SliderPath IHasPath.Path
=> 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
}
}