osu/osu.Game.Rulesets.Catch/Mods/CatchModHidden.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

64 lines
2.4 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
2019-06-28 08:34:04 +00:00
using System.Linq;
using osu.Framework.Graphics;
2022-08-10 20:09:11 +00:00
using osu.Framework.Localisation;
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Catch.Objects.Drawables;
using osu.Game.Rulesets.Catch.UI;
using osu.Game.Rulesets.Mods;
2019-06-28 08:34:04 +00:00
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.UI;
2018-04-13 09:19:50 +00:00
namespace osu.Game.Rulesets.Catch.Mods
{
public class CatchModHidden : ModHidden, IApplicableToDrawableRuleset<CatchHitObject>
{
2022-08-10 20:09:11 +00:00
public override LocalisableString Description => @"Play with fading fruits.";
public override double ScoreMultiplier => UsesDefaultConfiguration ? 1.06 : 1;
2019-06-28 08:34:04 +00:00
private const double fade_out_offset_multiplier = 0.6;
private const double fade_out_duration_multiplier = 0.44;
public void ApplyToDrawableRuleset(DrawableRuleset<CatchHitObject> drawableRuleset)
{
var drawableCatchRuleset = (DrawableCatchRuleset)drawableRuleset;
var catchPlayfield = (CatchPlayfield)drawableCatchRuleset.Playfield;
catchPlayfield.Catcher.CatchFruitOnPlate = false;
}
2021-05-15 03:51:39 +00:00
protected override void ApplyIncreasedVisibilityState(DrawableHitObject hitObject, ArmedState state)
=> ApplyNormalVisibilityState(hitObject, state);
2020-11-05 06:36:44 +00:00
2021-05-15 03:51:39 +00:00
protected override void ApplyNormalVisibilityState(DrawableHitObject hitObject, ArmedState state)
{
2020-11-05 06:36:44 +00:00
if (!(hitObject is DrawableCatchHitObject catchDrawable))
2019-06-28 08:34:04 +00:00
return;
if (catchDrawable.NestedHitObjects.Any())
{
foreach (var nestedDrawable in catchDrawable.NestedHitObjects)
{
if (nestedDrawable is DrawableCatchHitObject nestedCatchDrawable)
fadeOutHitObject(nestedCatchDrawable);
}
}
else
fadeOutHitObject(catchDrawable);
}
private void fadeOutHitObject(DrawableCatchHitObject drawable)
{
var hitObject = drawable.HitObject;
double offset = hitObject.TimePreempt * fade_out_offset_multiplier;
double duration = offset - hitObject.TimePreempt * fade_out_duration_multiplier;
2019-06-28 08:34:04 +00:00
2021-05-14 13:23:56 +00:00
using (drawable.BeginAbsoluteSequence(hitObject.StartTime - offset))
2019-06-28 08:34:04 +00:00
drawable.FadeOut(duration);
}
}
}