2019-01-24 17:43:03 +09: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 18:19:50 +09:00
|
|
|
|
|
2022-03-14 17:08:04 +09:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2020-09-17 17:05:24 +09:00
|
|
|
|
using System.Threading;
|
2022-03-14 17:08:04 +09:00
|
|
|
|
using osu.Game.Audio;
|
2017-07-26 13:22:46 +09:00
|
|
|
|
using osu.Game.Beatmaps;
|
2017-05-23 13:55:18 +09:00
|
|
|
|
using osu.Game.Beatmaps.ControlPoints;
|
2018-08-02 20:36:38 +09:00
|
|
|
|
using osu.Game.Rulesets.Judgements;
|
2020-07-21 18:22:37 +09:00
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
2018-08-02 20:36:38 +09:00
|
|
|
|
using osu.Game.Rulesets.Osu.Judgements;
|
2019-09-06 15:24:00 +09:00
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2021-10-24 18:15:40 -07:00
|
|
|
|
using osuTK;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2017-04-18 16:05:58 +09:00
|
|
|
|
namespace osu.Game.Rulesets.Osu.Objects
|
2016-09-02 18:35:49 +09:00
|
|
|
|
{
|
2020-05-27 12:38:39 +09:00
|
|
|
|
public class Spinner : OsuHitObject, IHasDuration
|
2016-09-02 18:35:49 +09:00
|
|
|
|
{
|
2023-09-26 13:48:18 +09:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The RPM required to clear the spinner at ODs [ 0, 5, 10 ].
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static readonly (int min, int mid, int max) clear_rpm_range = (90, 150, 225);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The RPM required to complete the spinner and receive full score at ODs [ 0, 5, 10 ].
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static readonly (int min, int mid, int max) complete_rpm_range = (250, 380, 430);
|
|
|
|
|
|
2020-02-07 19:08:37 +09:00
|
|
|
|
public double EndTime
|
|
|
|
|
{
|
|
|
|
|
get => StartTime + Duration;
|
|
|
|
|
set => Duration = value - StartTime;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public double Duration { get; set; }
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2017-05-14 06:45:35 +03:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Number of spins required to finish the spinner without miss.
|
|
|
|
|
/// </summary>
|
2017-05-14 09:36:09 +03:00
|
|
|
|
public int SpinsRequired { get; protected set; } = 1;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2023-09-12 20:51:22 +09:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The number of spins required to start receiving bonus score. The first bonus is awarded on this spin count.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int SpinsRequiredForBonus => SpinsRequired + bonus_spins_gap;
|
|
|
|
|
|
2023-08-27 01:27:48 +03:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The gap between spinner completion and the first bonus-awarding spin.
|
|
|
|
|
/// </summary>
|
|
|
|
|
private const int bonus_spins_gap = 2;
|
|
|
|
|
|
2020-07-24 19:34:13 +09:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Number of spins available to give bonus, beyond <see cref="SpinsRequired"/>.
|
|
|
|
|
/// </summary>
|
2020-07-24 21:03:55 +09:00
|
|
|
|
public int MaximumBonusSpins { get; protected set; } = 1;
|
2020-07-21 18:22:37 +09:00
|
|
|
|
|
2021-10-25 17:15:43 -07:00
|
|
|
|
public override Vector2 StackOffset => Vector2.Zero;
|
2021-10-24 18:15:40 -07:00
|
|
|
|
|
2021-10-01 14:56:42 +09:00
|
|
|
|
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, IBeatmapDifficultyInfo difficulty)
|
2017-05-14 06:45:35 +03:00
|
|
|
|
{
|
2017-12-22 21:42:54 +09:00
|
|
|
|
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2023-09-26 13:48:18 +09:00
|
|
|
|
// The average RPS required over the length of the spinner to clear the spinner.
|
|
|
|
|
double minRps = IBeatmapDifficultyInfo.DifficultyRange(difficulty.OverallDifficulty, clear_rpm_range) / 60;
|
|
|
|
|
|
|
|
|
|
// The RPS required over the length of the spinner to receive full score (all normal + bonus ticks).
|
|
|
|
|
double maxRps = IBeatmapDifficultyInfo.DifficultyRange(difficulty.OverallDifficulty, complete_rpm_range) / 60;
|
2020-07-24 22:09:25 +09:00
|
|
|
|
|
|
|
|
|
double secondsDuration = Duration / 1000;
|
2020-07-24 21:03:55 +09:00
|
|
|
|
|
2023-10-04 13:53:33 +09:00
|
|
|
|
// Allow a 0.1ms floating point precision error in the calculation of the duration.
|
|
|
|
|
const double duration_error = 0.0001;
|
|
|
|
|
|
|
|
|
|
SpinsRequired = (int)(minRps * secondsDuration + duration_error);
|
|
|
|
|
MaximumBonusSpins = Math.Max(0, (int)(maxRps * secondsDuration + duration_error) - SpinsRequired - bonus_spins_gap);
|
2017-05-14 06:45:35 +03:00
|
|
|
|
}
|
2018-08-02 20:36:38 +09:00
|
|
|
|
|
2020-09-17 17:05:24 +09:00
|
|
|
|
protected override void CreateNestedHitObjects(CancellationToken cancellationToken)
|
2019-08-20 21:17:27 +03:00
|
|
|
|
{
|
2020-09-17 17:05:24 +09:00
|
|
|
|
base.CreateNestedHitObjects(cancellationToken);
|
2019-08-20 21:17:27 +03:00
|
|
|
|
|
2023-08-27 01:27:48 +03:00
|
|
|
|
int totalSpins = MaximumBonusSpins + SpinsRequired + bonus_spins_gap;
|
2020-07-21 18:22:37 +09:00
|
|
|
|
|
|
|
|
|
for (int i = 0; i < totalSpins; i++)
|
|
|
|
|
{
|
2020-09-17 17:05:24 +09:00
|
|
|
|
cancellationToken.ThrowIfCancellationRequested();
|
|
|
|
|
|
2020-07-21 18:22:37 +09:00
|
|
|
|
double startTime = StartTime + (float)(i + 1) / totalSpins * Duration;
|
|
|
|
|
|
2023-09-12 20:51:22 +09:00
|
|
|
|
AddNested(i < SpinsRequiredForBonus
|
2023-01-19 20:53:35 +09:00
|
|
|
|
? new SpinnerTick { StartTime = startTime, SpinnerDuration = Duration }
|
2023-05-17 14:07:48 +09:00
|
|
|
|
: new SpinnerBonusTick { StartTime = startTime, SpinnerDuration = Duration, Samples = new[] { CreateHitSampleInfo("spinnerbonus") } });
|
2020-07-21 18:22:37 +09:00
|
|
|
|
}
|
2019-08-20 21:17:27 +03:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-06 11:50:18 +09:00
|
|
|
|
public override Judgement CreateJudgement() => new OsuJudgement();
|
2019-09-02 16:10:30 +09:00
|
|
|
|
|
2019-10-09 19:08:31 +09:00
|
|
|
|
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
2022-03-14 17:08:04 +09:00
|
|
|
|
|
|
|
|
|
public override IList<HitSampleInfo> AuxiliarySamples => CreateSpinningSamples();
|
|
|
|
|
|
|
|
|
|
public HitSampleInfo[] CreateSpinningSamples()
|
|
|
|
|
{
|
|
|
|
|
var referenceSample = Samples.FirstOrDefault();
|
|
|
|
|
|
|
|
|
|
if (referenceSample == null)
|
|
|
|
|
return Array.Empty<HitSampleInfo>();
|
|
|
|
|
|
|
|
|
|
return new[]
|
|
|
|
|
{
|
2023-04-26 13:55:39 +02:00
|
|
|
|
referenceSample.With("spinnerspin")
|
2022-03-14 17:08:04 +09:00
|
|
|
|
};
|
|
|
|
|
}
|
2016-09-02 18:35:49 +09:00
|
|
|
|
}
|
|
|
|
|
}
|