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
|
|
|
|
|
2018-01-09 13:41:57 +09:00
|
|
|
|
using System;
|
2020-02-10 14:14:04 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2019-03-27 19:29:27 +09:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2020-03-04 13:51:12 +08:00
|
|
|
|
using osu.Framework.Utils;
|
2018-01-09 13:41:57 +09:00
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Rulesets.Mods;
|
2020-02-08 08:59:35 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
2018-04-13 18:19:50 +09:00
|
|
|
|
|
2018-01-09 13:41:57 +09:00
|
|
|
|
namespace osu.Game.Rulesets.Osu.Mods
|
|
|
|
|
{
|
2021-06-16 18:52:01 +09:00
|
|
|
|
public class OsuModSpunOut : Mod, IApplicableToDrawableHitObject
|
2018-01-09 13:41:57 +09:00
|
|
|
|
{
|
|
|
|
|
public override string Name => "Spun Out";
|
2018-11-30 17:16:00 +09:00
|
|
|
|
public override string Acronym => "SO";
|
2021-12-09 21:15:00 -08:00
|
|
|
|
public override IconUsage? Icon => OsuIcon.ModSpunOut;
|
2020-02-09 13:33:43 +08:00
|
|
|
|
public override ModType Type => ModType.Automation;
|
2018-03-13 20:07:03 -07:00
|
|
|
|
public override string Description => @"Spinners will be automatically completed.";
|
2018-01-09 13:41:57 +09:00
|
|
|
|
public override double ScoreMultiplier => 0.9;
|
2022-04-28 05:15:04 +02:00
|
|
|
|
public override Type[] IncompatibleMods => new[] { typeof(ModAutoplay), typeof(OsuModAutopilot), typeof(OsuModTarget) };
|
2020-02-08 08:59:35 +08:00
|
|
|
|
|
2021-06-16 18:52:01 +09:00
|
|
|
|
public void ApplyToDrawableHitObject(DrawableHitObject hitObject)
|
2020-02-08 08:59:35 +08:00
|
|
|
|
{
|
2021-06-16 18:52:01 +09:00
|
|
|
|
if (hitObject is DrawableSpinner spinner)
|
2020-02-08 08:59:35 +08:00
|
|
|
|
{
|
2021-06-16 18:52:01 +09:00
|
|
|
|
spinner.HandleUserInput = false;
|
|
|
|
|
spinner.OnUpdate += onSpinnerUpdate;
|
2020-02-08 08:59:35 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-02-10 21:42:34 +01:00
|
|
|
|
|
2020-03-29 14:31:03 +09:00
|
|
|
|
private void onSpinnerUpdate(Drawable drawable)
|
2020-02-10 21:42:34 +01:00
|
|
|
|
{
|
2020-03-29 14:31:03 +09:00
|
|
|
|
var spinner = (DrawableSpinner)drawable;
|
|
|
|
|
|
2020-07-29 20:01:01 +09:00
|
|
|
|
spinner.RotationTracker.Tracking = true;
|
2020-08-11 22:04:18 +02:00
|
|
|
|
|
2020-08-11 22:34:46 +02:00
|
|
|
|
// early-return if we were paused to avoid division-by-zero in the subsequent calculations.
|
|
|
|
|
if (Precision.AlmostEquals(spinner.Clock.Rate, 0))
|
|
|
|
|
return;
|
|
|
|
|
|
2020-08-11 22:04:18 +02:00
|
|
|
|
// because the spinner is under the gameplay clock, it is affected by rate adjustments on the track;
|
|
|
|
|
// for that reason using ElapsedFrameTime directly leads to fewer SPM with Half Time and more SPM with Double Time.
|
|
|
|
|
// for spinners we want the real (wall clock) elapsed time; to achieve that, unapply the clock rate locally here.
|
2021-10-27 13:04:41 +09:00
|
|
|
|
double rateIndependentElapsedTime = spinner.Clock.ElapsedFrameTime / spinner.Clock.Rate;
|
2022-02-13 14:28:40 -05:00
|
|
|
|
|
|
|
|
|
// multiply the SPM by 1.01 to ensure that the spinner is completed. if the calculation is left exact,
|
|
|
|
|
// some spinners may not complete due to very minor decimal loss during calculation
|
|
|
|
|
float rotationSpeed = (float)(1.01 * spinner.HitObject.SpinsRequired / spinner.HitObject.Duration);
|
2022-02-13 02:16:06 -05:00
|
|
|
|
spinner.RotationTracker.AddRotation(MathUtils.RadiansToDegrees((float)rateIndependentElapsedTime * rotationSpeed * MathF.PI * 2.0f));
|
2020-02-10 21:42:34 +01:00
|
|
|
|
}
|
2018-01-09 13:41:57 +09:00
|
|
|
|
}
|
|
|
|
|
}
|