// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using osu.Game.Rulesets.Objects.Types; using System; using System.Collections.Generic; using System.Threading; using osu.Game.Audio; using osu.Game.Beatmaps; using osu.Game.Beatmaps.ControlPoints; using osu.Game.Rulesets.Judgements; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Taiko.Beatmaps; using osu.Game.Rulesets.Taiko.Judgements; using osuTK; namespace osu.Game.Rulesets.Taiko.Objects { public class DrumRoll : TaikoHitObject, IHasCurve { /// /// Drum roll distance that results in a duration of 1 speed-adjusted beat length. /// private const float base_distance = 100; public double EndTime { get => StartTime + Duration; set => Duration = value - StartTime; } public double Duration { get; set; } /// /// Velocity of this . /// public double Velocity { get; private set; } /// /// Numer of ticks per beat length. /// public int TickRate = 1; /// /// Number of drum roll ticks required for a "Good" hit. /// public double RequiredGoodHits { get; protected set; } /// /// Number of drum roll ticks required for a "Great" hit. /// public double RequiredGreatHits { get; protected set; } /// /// The length (in milliseconds) between ticks of this drumroll. /// Half of this value is the hit window of the ticks. /// private double tickSpacing = 100; private float overallDifficulty = BeatmapDifficulty.DEFAULT_DIFFICULTY; protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty) { base.ApplyDefaultsToSelf(controlPointInfo, difficulty); TimingControlPoint timingPoint = controlPointInfo.TimingPointAt(StartTime); DifficultyControlPoint difficultyPoint = controlPointInfo.DifficultyPointAt(StartTime); double scoringDistance = base_distance * difficulty.SliderMultiplier * difficultyPoint.SpeedMultiplier; Velocity = scoringDistance / timingPoint.BeatLength; tickSpacing = timingPoint.BeatLength / TickRate; overallDifficulty = difficulty.OverallDifficulty; } protected override void CreateNestedHitObjects(CancellationToken cancellationToken) { 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); } private void createTicks(CancellationToken cancellationToken) { if (tickSpacing == 0) return; bool first = true; for (double t = StartTime; t < EndTime + tickSpacing / 2; t += tickSpacing) { cancellationToken.ThrowIfCancellationRequested(); AddNested(new DrumRollTick { FirstTick = first, TickSpacing = tickSpacing, StartTime = t, IsStrong = IsStrong }); first = false; } } public override Judgement CreateJudgement() => new TaikoDrumRollJudgement(); protected override HitWindows CreateHitWindows() => HitWindows.Empty; #region LegacyBeatmapEncoder double IHasDistance.Distance => Duration * Velocity; int IHasRepeats.RepeatCount { get => 0; set { } } List> IHasRepeats.NodeSamples => new List>(); SliderPath IHasCurve.Path => new SliderPath(PathType.Linear, new[] { Vector2.Zero, new Vector2(1) }, ((IHasDistance)this).Distance / TaikoBeatmapConverter.LEGACY_VELOCITY_MULTIPLIER); #endregion } }