2019-01-24 08:43:03 +00: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 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
using System;
|
2020-12-03 05:28:37 +00:00
|
|
|
|
using System.Diagnostics;
|
2020-11-11 20:46:58 +00:00
|
|
|
|
using System.Linq;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
2020-12-03 05:28:37 +00:00
|
|
|
|
using osu.Game.Beatmaps;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Game.Rulesets.Mods;
|
2019-11-25 10:01:24 +00:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
2018-06-06 04:51:51 +00:00
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
2021-06-19 17:06:28 +00:00
|
|
|
|
using osu.Game.Rulesets.Osu.Skinning;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Mods
|
|
|
|
|
{
|
2021-06-28 15:54:21 +00:00
|
|
|
|
public class OsuModHidden : ModHidden, IHidesApproachCircles
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
public override string Description => @"Play with no approach circles and fading circles/sliders.";
|
|
|
|
|
public override double ScoreMultiplier => 1.06;
|
2019-09-18 10:36:07 +00:00
|
|
|
|
|
2021-06-28 15:55:24 +00:00
|
|
|
|
public override Type[] IncompatibleMods => new[] { typeof(IRequiresApproachCircles), typeof(OsuModSpinIn) };
|
2019-09-18 10:36:07 +00:00
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
private const double fade_in_duration_multiplier = 0.4;
|
|
|
|
|
private const double fade_out_duration_multiplier = 0.3;
|
2018-04-25 08:15:53 +00:00
|
|
|
|
|
2020-12-03 21:40:30 +00:00
|
|
|
|
protected override bool IsFirstAdjustableObject(HitObject hitObject) => !(hitObject is Spinner || hitObject is SpinnerTick);
|
2020-04-16 05:11:38 +00:00
|
|
|
|
|
2020-12-03 05:28:37 +00:00
|
|
|
|
public override void ApplyToBeatmap(IBeatmap beatmap)
|
2018-06-06 04:51:51 +00:00
|
|
|
|
{
|
2020-12-03 05:28:37 +00:00
|
|
|
|
base.ApplyToBeatmap(beatmap);
|
2018-06-06 04:51:51 +00:00
|
|
|
|
|
2020-12-03 05:28:37 +00:00
|
|
|
|
foreach (var obj in beatmap.HitObjects.OfType<OsuHitObject>())
|
|
|
|
|
applyFadeInAdjustment(obj);
|
2020-11-11 07:35:48 +00:00
|
|
|
|
|
2020-12-03 05:28:37 +00:00
|
|
|
|
static void applyFadeInAdjustment(OsuHitObject osuObject)
|
|
|
|
|
{
|
|
|
|
|
osuObject.TimeFadeIn = osuObject.TimePreempt * fade_in_duration_multiplier;
|
|
|
|
|
foreach (var nested in osuObject.NestedHitObjects.OfType<OsuHitObject>())
|
|
|
|
|
applyFadeInAdjustment(nested);
|
|
|
|
|
}
|
2020-11-05 07:12:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-05 06:36:44 +00:00
|
|
|
|
protected override void ApplyIncreasedVisibilityState(DrawableHitObject hitObject, ArmedState state)
|
|
|
|
|
{
|
|
|
|
|
applyState(hitObject, true);
|
|
|
|
|
}
|
2020-10-08 18:07:01 +00:00
|
|
|
|
|
2020-11-05 06:36:44 +00:00
|
|
|
|
protected override void ApplyNormalVisibilityState(DrawableHitObject hitObject, ArmedState state)
|
|
|
|
|
{
|
|
|
|
|
applyState(hitObject, false);
|
|
|
|
|
}
|
2020-10-08 18:07:01 +00:00
|
|
|
|
|
2020-12-03 05:28:37 +00:00
|
|
|
|
private void applyState(DrawableHitObject drawableObject, bool increaseVisibility)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2020-12-03 05:28:37 +00:00
|
|
|
|
if (!(drawableObject is DrawableOsuHitObject drawableOsuObject))
|
2018-04-13 09:19:50 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2020-12-03 05:28:37 +00:00
|
|
|
|
OsuHitObject hitObject = drawableOsuObject.HitObject;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2021-05-14 13:56:13 +00:00
|
|
|
|
(double fadeStartTime, double fadeDuration) = getFadeOutParameters(drawableOsuObject);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2020-12-03 05:28:37 +00:00
|
|
|
|
switch (drawableObject)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2020-12-03 05:28:37 +00:00
|
|
|
|
case DrawableSliderTail _:
|
2021-05-14 13:56:13 +00:00
|
|
|
|
using (drawableObject.BeginAbsoluteSequence(fadeStartTime))
|
2021-05-14 13:30:58 +00:00
|
|
|
|
drawableObject.FadeOut(fadeDuration);
|
2020-10-02 09:41:28 +00:00
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case DrawableSliderRepeat sliderRepeat:
|
2021-05-14 13:56:13 +00:00
|
|
|
|
using (drawableObject.BeginAbsoluteSequence(fadeStartTime))
|
2020-10-02 09:41:28 +00:00
|
|
|
|
// only apply to circle piece – reverse arrow is not affected by hidden.
|
2021-05-14 13:30:58 +00:00
|
|
|
|
sliderRepeat.CirclePiece.FadeOut(fadeDuration);
|
2020-10-02 09:41:28 +00:00
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
case DrawableHitCircle circle:
|
2020-10-09 09:43:16 +00:00
|
|
|
|
Drawable fadeTarget = circle;
|
|
|
|
|
|
|
|
|
|
if (increaseVisibility)
|
|
|
|
|
{
|
|
|
|
|
// only fade the circle piece (not the approach circle) for the increased visibility object.
|
|
|
|
|
fadeTarget = circle.CirclePiece;
|
|
|
|
|
}
|
|
|
|
|
else
|
2020-10-08 18:07:01 +00:00
|
|
|
|
{
|
|
|
|
|
// we don't want to see the approach circle
|
2021-05-14 13:23:56 +00:00
|
|
|
|
using (circle.BeginAbsoluteSequence(hitObject.StartTime - hitObject.TimePreempt))
|
2020-10-08 18:07:01 +00:00
|
|
|
|
circle.ApproachCircle.Hide();
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2021-05-14 13:56:13 +00:00
|
|
|
|
using (drawableObject.BeginAbsoluteSequence(fadeStartTime))
|
2021-05-14 13:30:58 +00:00
|
|
|
|
fadeTarget.FadeOut(fadeDuration);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
break;
|
2019-04-01 03:44:46 +00:00
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
case DrawableSlider slider:
|
2021-05-14 13:56:13 +00:00
|
|
|
|
using (slider.BeginAbsoluteSequence(fadeStartTime))
|
2021-05-14 13:30:58 +00:00
|
|
|
|
slider.Body.FadeOut(fadeDuration, Easing.Out);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
break;
|
2019-04-01 03:44:46 +00:00
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
case DrawableSliderTick sliderTick:
|
2021-05-14 13:56:13 +00:00
|
|
|
|
using (sliderTick.BeginAbsoluteSequence(fadeStartTime))
|
2021-05-14 13:30:58 +00:00
|
|
|
|
sliderTick.FadeOut(fadeDuration);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
break;
|
2019-04-01 03:44:46 +00:00
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
case DrawableSpinner spinner:
|
|
|
|
|
// hide elements we don't care about.
|
2020-07-29 11:01:01 +00:00
|
|
|
|
// todo: hide background
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2021-06-19 17:06:28 +00:00
|
|
|
|
spinner.Body.OnSkinChanged += () => hideSpinnerApproachCircle(spinner);
|
|
|
|
|
hideSpinnerApproachCircle(spinner);
|
2021-06-17 01:57:29 +00:00
|
|
|
|
|
2021-05-14 13:56:13 +00:00
|
|
|
|
using (spinner.BeginAbsoluteSequence(fadeStartTime))
|
2021-05-14 13:30:58 +00:00
|
|
|
|
spinner.FadeOut(fadeDuration);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-11-11 20:46:58 +00:00
|
|
|
|
|
2021-05-15 03:26:16 +00:00
|
|
|
|
private (double fadeStartTime, double fadeDuration) getFadeOutParameters(DrawableOsuHitObject drawableObject)
|
2020-11-11 20:46:58 +00:00
|
|
|
|
{
|
2020-12-03 05:28:37 +00:00
|
|
|
|
switch (drawableObject)
|
2020-11-11 20:46:58 +00:00
|
|
|
|
{
|
2020-12-03 05:28:37 +00:00
|
|
|
|
case DrawableSliderTail tail:
|
|
|
|
|
// Use the same fade sequence as the slider head.
|
|
|
|
|
Debug.Assert(tail.Slider != null);
|
|
|
|
|
return getParameters(tail.Slider.HeadCircle);
|
|
|
|
|
|
|
|
|
|
case DrawableSliderRepeat repeat:
|
|
|
|
|
// Use the same fade sequence as the slider head.
|
|
|
|
|
Debug.Assert(repeat.Slider != null);
|
|
|
|
|
return getParameters(repeat.Slider.HeadCircle);
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return getParameters(drawableObject.HitObject);
|
2020-11-11 20:46:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-05-15 03:26:16 +00:00
|
|
|
|
static (double fadeStartTime, double fadeDuration) getParameters(OsuHitObject hitObject)
|
2020-12-03 05:28:37 +00:00
|
|
|
|
{
|
|
|
|
|
var fadeOutStartTime = hitObject.StartTime - hitObject.TimePreempt + hitObject.TimeFadeIn;
|
|
|
|
|
var fadeOutDuration = hitObject.TimePreempt * fade_out_duration_multiplier;
|
|
|
|
|
|
|
|
|
|
// new duration from completed fade in to end (before fading out)
|
|
|
|
|
var longFadeDuration = hitObject.GetEndTime() - fadeOutStartTime;
|
|
|
|
|
|
|
|
|
|
switch (hitObject)
|
|
|
|
|
{
|
|
|
|
|
case Slider _:
|
|
|
|
|
return (fadeOutStartTime, longFadeDuration);
|
|
|
|
|
|
|
|
|
|
case SliderTick _:
|
|
|
|
|
var tickFadeOutDuration = Math.Min(hitObject.TimePreempt - DrawableSliderTick.ANIM_DURATION, 1000);
|
|
|
|
|
return (hitObject.StartTime - tickFadeOutDuration, tickFadeOutDuration);
|
|
|
|
|
|
|
|
|
|
case Spinner _:
|
|
|
|
|
return (fadeOutStartTime + longFadeDuration, fadeOutDuration);
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return (fadeOutStartTime, fadeOutDuration);
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-11-11 20:46:58 +00:00
|
|
|
|
}
|
2021-06-19 17:06:28 +00:00
|
|
|
|
|
|
|
|
|
private static void hideSpinnerApproachCircle(DrawableSpinner spinner)
|
|
|
|
|
{
|
2021-06-21 00:43:11 +00:00
|
|
|
|
var approachCircle = (spinner.Body.Drawable as IHasApproachCircle)?.ApproachCircle;
|
2021-06-19 17:06:28 +00:00
|
|
|
|
if (approachCircle == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
using (spinner.BeginAbsoluteSequence(spinner.HitObject.StartTime - spinner.HitObject.TimePreempt))
|
|
|
|
|
approachCircle.Hide();
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|