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
|
|
|
|
|
|
|
|
|
using System;
|
2018-06-06 12:51:51 +08:00
|
|
|
|
using System.Collections.Generic;
|
2020-11-12 04:46:58 +08:00
|
|
|
|
using System.Linq;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Game.Rulesets.Mods;
|
2019-11-25 18:01:24 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
2018-06-06 12:51:51 +08:00
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Mods
|
|
|
|
|
{
|
2018-06-06 12:51:51 +08:00
|
|
|
|
public class OsuModHidden : ModHidden
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
public override string Description => @"Play with no approach circles and fading circles/sliders.";
|
|
|
|
|
public override double ScoreMultiplier => 1.06;
|
2019-09-18 18:36:07 +08:00
|
|
|
|
|
|
|
|
|
public override Type[] IncompatibleMods => new[] { typeof(OsuModTraceable), typeof(OsuModSpinIn) };
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
private const double fade_in_duration_multiplier = 0.4;
|
|
|
|
|
private const double fade_out_duration_multiplier = 0.3;
|
2018-04-25 16:15:53 +08:00
|
|
|
|
|
2020-11-05 14:36:44 +08:00
|
|
|
|
protected override bool IsFirstAdjustableObject(HitObject hitObject) => !(hitObject is Spinner);
|
2020-04-16 13:11:38 +08:00
|
|
|
|
|
2018-06-06 12:51:51 +08:00
|
|
|
|
public override void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables)
|
|
|
|
|
{
|
2020-11-05 15:12:55 +08:00
|
|
|
|
foreach (var d in drawables)
|
2020-11-11 15:35:48 +08:00
|
|
|
|
d.HitObjectApplied += applyFadeInAdjustment;
|
2018-06-06 12:51:51 +08:00
|
|
|
|
|
|
|
|
|
base.ApplyToDrawableHitObjects(drawables);
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-11 15:35:48 +08:00
|
|
|
|
private void applyFadeInAdjustment(DrawableHitObject hitObject)
|
2020-11-05 15:12:55 +08:00
|
|
|
|
{
|
|
|
|
|
if (!(hitObject is DrawableOsuHitObject d))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
d.HitObject.TimeFadeIn = d.HitObject.TimePreempt * fade_in_duration_multiplier;
|
2020-11-11 15:35:48 +08:00
|
|
|
|
|
|
|
|
|
foreach (var nested in d.NestedHitObjects)
|
|
|
|
|
applyFadeInAdjustment(nested);
|
2020-11-05 15:12:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-05 14:36:44 +08:00
|
|
|
|
protected override void ApplyIncreasedVisibilityState(DrawableHitObject hitObject, ArmedState state)
|
|
|
|
|
{
|
|
|
|
|
base.ApplyIncreasedVisibilityState(hitObject, state);
|
|
|
|
|
applyState(hitObject, true);
|
|
|
|
|
}
|
2020-10-09 02:07:01 +08:00
|
|
|
|
|
2020-11-05 14:36:44 +08:00
|
|
|
|
protected override void ApplyNormalVisibilityState(DrawableHitObject hitObject, ArmedState state)
|
|
|
|
|
{
|
|
|
|
|
base.ApplyNormalVisibilityState(hitObject, state);
|
|
|
|
|
applyState(hitObject, false);
|
|
|
|
|
}
|
2020-10-09 02:07:01 +08:00
|
|
|
|
|
|
|
|
|
private void applyState(DrawableHitObject drawable, bool increaseVisibility)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
if (!(drawable is DrawableOsuHitObject d))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var h = d.HitObject;
|
|
|
|
|
|
2018-07-05 10:32:09 +08:00
|
|
|
|
var fadeOutStartTime = h.StartTime - h.TimePreempt + h.TimeFadeIn;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
var fadeOutDuration = h.TimePreempt * fade_out_duration_multiplier;
|
|
|
|
|
|
|
|
|
|
// new duration from completed fade in to end (before fading out)
|
2019-11-25 18:01:24 +08:00
|
|
|
|
var longFadeDuration = h.GetEndTime() - fadeOutStartTime;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
switch (drawable)
|
|
|
|
|
{
|
2020-10-02 17:41:28 +08:00
|
|
|
|
case DrawableSliderTail sliderTail:
|
|
|
|
|
// use stored values from head circle to achieve same fade sequence.
|
2020-11-12 04:46:58 +08:00
|
|
|
|
var tailFadeOutParameters = getFadeOutParametersFromSliderHead(h);
|
2020-10-02 17:41:28 +08:00
|
|
|
|
|
2020-11-12 04:46:58 +08:00
|
|
|
|
using (drawable.BeginAbsoluteSequence(tailFadeOutParameters.startTime, true))
|
|
|
|
|
sliderTail.FadeOut(tailFadeOutParameters.duration);
|
2020-10-02 17:41:28 +08:00
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case DrawableSliderRepeat sliderRepeat:
|
|
|
|
|
// use stored values from head circle to achieve same fade sequence.
|
2020-11-12 04:46:58 +08:00
|
|
|
|
var repeatFadeOutParameters = getFadeOutParametersFromSliderHead(h);
|
2020-10-02 17:41:28 +08:00
|
|
|
|
|
2020-11-12 04:46:58 +08:00
|
|
|
|
using (drawable.BeginAbsoluteSequence(repeatFadeOutParameters.startTime, true))
|
2020-10-02 17:41:28 +08:00
|
|
|
|
// only apply to circle piece – reverse arrow is not affected by hidden.
|
2020-11-12 04:46:58 +08:00
|
|
|
|
sliderRepeat.CirclePiece.FadeOut(repeatFadeOutParameters.duration);
|
2020-10-02 17:41:28 +08:00
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
case DrawableHitCircle circle:
|
2020-10-09 17:43:16 +08: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-09 02:07:01 +08:00
|
|
|
|
{
|
|
|
|
|
// we don't want to see the approach circle
|
|
|
|
|
using (circle.BeginAbsoluteSequence(h.StartTime - h.TimePreempt, true))
|
|
|
|
|
circle.ApproachCircle.Hide();
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
// fade out immediately after fade in.
|
|
|
|
|
using (drawable.BeginAbsoluteSequence(fadeOutStartTime, true))
|
2020-10-09 17:43:16 +08:00
|
|
|
|
fadeTarget.FadeOut(fadeOutDuration);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
break;
|
2019-04-01 11:44:46 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
case DrawableSlider slider:
|
2020-11-12 04:46:58 +08:00
|
|
|
|
associateNestedSliderCirclesWithHead(slider.HitObject);
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using (slider.BeginAbsoluteSequence(fadeOutStartTime, true))
|
|
|
|
|
slider.Body.FadeOut(longFadeDuration, Easing.Out);
|
|
|
|
|
|
|
|
|
|
break;
|
2019-04-01 11:44:46 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
case DrawableSliderTick sliderTick:
|
|
|
|
|
// slider ticks fade out over up to one second
|
|
|
|
|
var tickFadeOutDuration = Math.Min(sliderTick.HitObject.TimePreempt - DrawableSliderTick.ANIM_DURATION, 1000);
|
|
|
|
|
|
|
|
|
|
using (sliderTick.BeginAbsoluteSequence(sliderTick.HitObject.StartTime - tickFadeOutDuration, true))
|
|
|
|
|
sliderTick.FadeOut(tickFadeOutDuration);
|
|
|
|
|
|
|
|
|
|
break;
|
2019-04-01 11:44:46 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
case DrawableSpinner spinner:
|
|
|
|
|
// hide elements we don't care about.
|
2020-07-29 19:01:01 +08:00
|
|
|
|
// todo: hide background
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
using (spinner.BeginAbsoluteSequence(fadeOutStartTime + longFadeDuration, true))
|
|
|
|
|
spinner.FadeOut(fadeOutDuration);
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-11-12 04:46:58 +08:00
|
|
|
|
|
|
|
|
|
private readonly Dictionary<HitObject, SliderHeadCircle> correspondingSliderHeadForObject = new Dictionary<HitObject, SliderHeadCircle>();
|
|
|
|
|
|
|
|
|
|
private void associateNestedSliderCirclesWithHead(Slider slider)
|
|
|
|
|
{
|
|
|
|
|
var sliderHead = slider.NestedHitObjects.Single(obj => obj is SliderHeadCircle);
|
|
|
|
|
|
|
|
|
|
foreach (var nested in slider.NestedHitObjects)
|
|
|
|
|
{
|
|
|
|
|
if ((nested is SliderRepeat || nested is SliderEndCircle) && !correspondingSliderHeadForObject.ContainsKey(nested))
|
|
|
|
|
correspondingSliderHeadForObject[nested] = (SliderHeadCircle)sliderHead;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private (double startTime, double duration) getFadeOutParametersFromSliderHead(OsuHitObject h)
|
|
|
|
|
{
|
|
|
|
|
var sliderHead = correspondingSliderHeadForObject[h];
|
|
|
|
|
return (sliderHead.StartTime - sliderHead.TimePreempt + sliderHead.TimeFadeIn, sliderHead.TimePreempt * fade_out_duration_multiplier);
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|