osu/osu.Game.Rulesets.Osu/Mods/OsuModHidden.cs

95 lines
3.6 KiB
C#
Raw Normal View History

// 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;
2018-06-06 04:51:51 +00:00
using System.Collections.Generic;
using System.Linq;
2018-04-13 09:19:50 +00:00
using osu.Framework.Graphics;
using osu.Game.Rulesets.Mods;
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;
2018-04-13 09:19:50 +00:00
namespace osu.Game.Rulesets.Osu.Mods
{
2018-06-06 04:51:51 +00:00
public class OsuModHidden : ModHidden
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;
public override Type[] IncompatibleMods => new[] { typeof(OsuModTraceable), typeof(OsuModSpinIn) };
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;
protected override bool IsFirstHideableObject(DrawableHitObject hitObject) => !(hitObject is DrawableSpinner);
2018-06-06 04:51:51 +00:00
public override void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables)
{
2019-11-12 10:37:20 +00:00
static void adjustFadeIn(OsuHitObject h) => h.TimeFadeIn = h.TimePreempt * fade_in_duration_multiplier;
2018-06-06 04:51:51 +00:00
foreach (var d in drawables.OfType<DrawableOsuHitObject>())
{
adjustFadeIn(d.HitObject);
foreach (var h in d.HitObject.NestedHitObjects.OfType<OsuHitObject>())
adjustFadeIn(h);
}
base.ApplyToDrawableHitObjects(drawables);
}
2018-05-06 10:38:25 +00:00
protected override void ApplyHiddenState(DrawableHitObject drawable, ArmedState state)
2018-04-13 09:19:50 +00:00
{
if (!(drawable is DrawableOsuHitObject d))
return;
var h = d.HitObject;
var fadeOutStartTime = h.StartTime - h.TimePreempt + h.TimeFadeIn;
2018-04-13 09:19:50 +00:00
var fadeOutDuration = h.TimePreempt * fade_out_duration_multiplier;
// new duration from completed fade in to end (before fading out)
var longFadeDuration = h.GetEndTime() - fadeOutStartTime;
2018-04-13 09:19:50 +00:00
switch (drawable)
{
case DrawableHitCircle circle:
// we don't want to see the approach circle
using (circle.BeginAbsoluteSequence(h.StartTime - h.TimePreempt, true))
circle.ApproachCircle.Hide();
// fade out immediately after fade in.
using (drawable.BeginAbsoluteSequence(fadeOutStartTime, true))
circle.FadeOut(fadeOutDuration);
break;
2019-04-01 03:44:46 +00:00
2018-04-13 09:19:50 +00:00
case DrawableSlider slider:
using (slider.BeginAbsoluteSequence(fadeOutStartTime, true))
slider.Body.FadeOut(longFadeDuration, Easing.Out);
break;
2019-04-01 03:44:46 +00:00
2018-04-13 09:19:50 +00: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 03:44:46 +00:00
2018-04-13 09:19:50 +00:00
case DrawableSpinner spinner:
// hide elements we don't care about.
// todo: hide background
2018-04-13 09:19:50 +00:00
using (spinner.BeginAbsoluteSequence(fadeOutStartTime + longFadeDuration, true))
spinner.FadeOut(fadeOutDuration);
break;
}
}
}
}