osu/osu.Game.Rulesets.Taiko/Objects/DrumRoll.cs

125 lines
4.1 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 09:19:50 +00:00
using osu.Game.Rulesets.Objects.Types;
using System;
2020-04-21 07:45:01 +00:00
using System.Collections.Generic;
using osu.Game.Audio;
2018-04-13 09:19:50 +00:00
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.ControlPoints;
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 osu.Game.Rulesets.Taiko.Beatmaps;
2018-11-29 01:56:19 +00:00
using osu.Game.Rulesets.Taiko.Judgements;
2020-04-21 07:45:01 +00:00
using osuTK;
2018-04-13 09:19:50 +00:00
namespace osu.Game.Rulesets.Taiko.Objects
{
2020-04-21 08:31:49 +00:00
public class DrumRoll : TaikoHitObject, IHasCurve
2018-04-13 09:19:50 +00:00
{
/// <summary>
/// Drum roll distance that results in a duration of 1 speed-adjusted beat length.
/// </summary>
private const float base_distance = 100;
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
public double Duration { get; set; }
2020-04-21 07:45:01 +00:00
/// <summary>
/// Velocity of this <see cref="DrumRoll"/>.
/// </summary>
public double Velocity { get; private set; }
2018-04-13 09:19:50 +00:00
/// <summary>
/// Numer of ticks per beat length.
/// </summary>
public int TickRate = 1;
/// <summary>
/// Number of drum roll ticks required for a "Good" hit.
/// </summary>
public double RequiredGoodHits { get; protected set; }
/// <summary>
/// Number of drum roll ticks required for a "Great" hit.
/// </summary>
public double RequiredGreatHits { get; protected set; }
/// <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;
private float overallDifficulty = BeatmapDifficulty.DEFAULT_DIFFICULTY;
2018-04-13 09:19:50 +00:00
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
{
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime);
2020-04-21 07:45:01 +00:00
DifficultyControlPoint difficultyPoint = controlPointInfo.DifficultyPointAt(StartTime);
double scoringDistance = base_distance * difficulty.SliderMultiplier * difficultyPoint.SpeedMultiplier;
Velocity = scoringDistance / timingPoint.BeatLength;
2018-04-13 09:19:50 +00:00
tickSpacing = timingPoint.BeatLength / TickRate;
overallDifficulty = difficulty.OverallDifficulty;
2018-04-13 09:19:50 +00:00
}
protected override void CreateNestedHitObjects()
{
createTicks();
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();
2018-04-13 09:19:50 +00:00
}
private void createTicks()
{
if (tickSpacing == 0)
return;
bool first = true;
2019-04-01 03:16:05 +00:00
2018-04-13 09:19:50 +00:00
for (double t = StartTime; t < EndTime + tickSpacing / 2; t += tickSpacing)
{
AddNested(new DrumRollTick
{
FirstTick = first,
TickSpacing = tickSpacing,
StartTime = t,
IsStrong = IsStrong
});
first = false;
}
}
2018-12-06 08:09:42 +00:00
public override Judgement CreateJudgement() => new TaikoDrumRollJudgement();
2019-10-09 10:08:31 +00:00
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
2020-04-21 07:45:01 +00:00
#region LegacyBeatmapEncoder
double IHasDistance.Distance => Duration * Velocity;
int IHasRepeats.RepeatCount { get => 0; set { } }
List<IList<HitSampleInfo>> IHasRepeats.NodeSamples => new List<IList<HitSampleInfo>>();
SliderPath IHasCurve.Path
=> new SliderPath(PathType.Linear, new[] { Vector2.Zero, new Vector2(1) }, ((IHasDistance)this).Distance / TaikoBeatmapConverter.LEGACY_VELOCITY_MULTIPLIER);
#endregion
2018-04-13 09:19:50 +00:00
}
}