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-03-14 16:08:04 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2020-09-17 16:05:24 +08:00
|
|
|
|
using System.Threading;
|
2022-03-14 16:08:04 +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;
|
2018-08-02 19:36:38 +08:00
|
|
|
|
using osu.Game.Rulesets.Judgements;
|
2020-07-21 17:22:37 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
2018-08-02 19:36:38 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu.Judgements;
|
2019-09-06 14:24:00 +08:00
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2021-10-25 09:15:40 +08:00
|
|
|
|
using osuTK;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-04-18 15:05:58 +08:00
|
|
|
|
namespace osu.Game.Rulesets.Osu.Objects
|
2016-09-02 17:35:49 +08:00
|
|
|
|
{
|
2020-05-27 11:38:39 +08:00
|
|
|
|
public class Spinner : OsuHitObject, IHasDuration
|
2016-09-02 17:35:49 +08:00
|
|
|
|
{
|
2020-02-07 18:08:37 +08:00
|
|
|
|
public double EndTime
|
|
|
|
|
{
|
|
|
|
|
get => StartTime + Duration;
|
|
|
|
|
set => Duration = value - StartTime;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public double Duration { get; set; }
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-05-14 11:45:35 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Number of spins required to finish the spinner without miss.
|
|
|
|
|
/// </summary>
|
2017-05-14 14:36:09 +08:00
|
|
|
|
public int SpinsRequired { get; protected set; } = 1;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-07-24 18:34:13 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Number of spins available to give bonus, beyond <see cref="SpinsRequired"/>.
|
|
|
|
|
/// </summary>
|
2020-07-24 20:03:55 +08:00
|
|
|
|
public int MaximumBonusSpins { get; protected set; } = 1;
|
2020-07-21 17:22:37 +08:00
|
|
|
|
|
2021-10-26 08:15:43 +08:00
|
|
|
|
public override Vector2 StackOffset => Vector2.Zero;
|
2021-10-25 09:15:40 +08:00
|
|
|
|
|
2021-10-01 13:56:42 +08:00
|
|
|
|
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, IBeatmapDifficultyInfo difficulty)
|
2017-05-14 11:45:35 +08:00
|
|
|
|
{
|
2017-12-22 20:42:54 +08:00
|
|
|
|
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-05-24 21:08:14 +08:00
|
|
|
|
// spinning doesn't match 1:1 with stable, so let's fudge them easier for the time being.
|
2020-07-24 21:09:25 +08:00
|
|
|
|
const double stable_matching_fudge = 0.6;
|
|
|
|
|
|
|
|
|
|
// close to 477rpm
|
|
|
|
|
const double maximum_rotations_per_second = 8;
|
|
|
|
|
|
|
|
|
|
double secondsDuration = Duration / 1000;
|
2020-07-24 20:03:55 +08:00
|
|
|
|
|
2021-10-01 13:56:42 +08:00
|
|
|
|
double minimumRotationsPerSecond = stable_matching_fudge * IBeatmapDifficultyInfo.DifficultyRange(difficulty.OverallDifficulty, 3, 5, 7.5);
|
2020-07-24 20:03:55 +08:00
|
|
|
|
|
2020-08-05 17:44:34 +08:00
|
|
|
|
SpinsRequired = (int)(secondsDuration * minimumRotationsPerSecond);
|
2020-07-24 21:09:25 +08:00
|
|
|
|
MaximumBonusSpins = (int)((maximum_rotations_per_second - minimumRotationsPerSecond) * secondsDuration);
|
2017-05-14 11:45:35 +08:00
|
|
|
|
}
|
2018-08-02 19:36:38 +08:00
|
|
|
|
|
2020-09-17 16:05:24 +08:00
|
|
|
|
protected override void CreateNestedHitObjects(CancellationToken cancellationToken)
|
2019-08-21 02:17:27 +08:00
|
|
|
|
{
|
2020-09-17 16:05:24 +08:00
|
|
|
|
base.CreateNestedHitObjects(cancellationToken);
|
2019-08-21 02:17:27 +08:00
|
|
|
|
|
2020-07-21 17:22:37 +08:00
|
|
|
|
int totalSpins = MaximumBonusSpins + SpinsRequired;
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < totalSpins; i++)
|
|
|
|
|
{
|
2020-09-17 16:05:24 +08:00
|
|
|
|
cancellationToken.ThrowIfCancellationRequested();
|
|
|
|
|
|
2020-07-21 17:22:37 +08:00
|
|
|
|
double startTime = StartTime + (float)(i + 1) / totalSpins * Duration;
|
|
|
|
|
|
|
|
|
|
AddNested(i < SpinsRequired
|
2023-01-19 19:53:35 +08:00
|
|
|
|
? new SpinnerTick { StartTime = startTime, SpinnerDuration = Duration }
|
2023-05-17 13:07:48 +08:00
|
|
|
|
: new SpinnerBonusTick { StartTime = startTime, SpinnerDuration = Duration, Samples = new[] { CreateHitSampleInfo("spinnerbonus") } });
|
2020-07-21 17:22:37 +08:00
|
|
|
|
}
|
2019-08-21 02:17:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-06 10:50:18 +08:00
|
|
|
|
public override Judgement CreateJudgement() => new OsuJudgement();
|
2019-09-02 15:10:30 +08:00
|
|
|
|
|
2019-10-09 18:08:31 +08:00
|
|
|
|
protected override HitWindows CreateHitWindows() => HitWindows.Empty;
|
2022-03-14 16:08:04 +08: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 19:55:39 +08:00
|
|
|
|
referenceSample.With("spinnerspin")
|
2022-03-14 16:08:04 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
2016-09-02 17:35:49 +08:00
|
|
|
|
}
|
|
|
|
|
}
|