1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-14 16:37:26 +08:00
osu-lazer/osu.Game.Rulesets.Osu/Mods/OsuModObjectScaleTween.cs

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

71 lines
2.5 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.
using System;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Objects.Drawables;
namespace osu.Game.Rulesets.Osu.Mods
{
/// <summary>
/// Adjusts the size of hit objects during their fade in animation.
/// </summary>
public abstract class OsuModObjectScaleTween : ModWithVisibilityAdjustment, IHidesApproachCircles
{
public override ModType Type => ModType.Fun;
public override double ScoreMultiplier => 1;
2020-07-17 22:12:01 +08:00
public abstract BindableNumber<float> StartScale { get; }
protected virtual float EndScale => 1;
public override Type[] IncompatibleMods => new[] { typeof(IRequiresApproachCircles), typeof(OsuModSpinIn), typeof(OsuModObjectScaleTween) };
2020-11-05 15:03:10 +08:00
protected override void ApplyIncreasedVisibilityState(DrawableHitObject hitObject, ArmedState state)
{
}
2020-11-05 15:03:10 +08:00
protected override void ApplyNormalVisibilityState(DrawableHitObject hitObject, ArmedState state) => applyCustomState(hitObject, state);
2020-11-05 14:52:06 +08:00
private void applyCustomState(DrawableHitObject drawable, ArmedState state)
{
2020-11-05 14:52:06 +08:00
if (drawable is DrawableSpinner)
return;
var h = (OsuHitObject)drawable.HitObject;
// apply grow effect
switch (drawable)
{
2022-06-24 20:25:23 +08:00
case DrawableSliderHead:
case DrawableSliderTail:
// special cases we should *not* be scaling.
break;
2022-06-24 20:25:23 +08:00
case DrawableSlider:
case DrawableHitCircle:
{
using (drawable.BeginAbsoluteSequence(h.StartTime - h.TimePreempt))
2020-07-17 22:12:01 +08:00
drawable.ScaleTo(StartScale.Value).Then().ScaleTo(EndScale, h.TimePreempt, Easing.OutSine);
break;
}
}
// remove approach circles
switch (drawable)
{
case DrawableHitCircle circle:
// we don't want to see the approach circle
using (circle.BeginAbsoluteSequence(h.StartTime - h.TimePreempt))
circle.ApproachCircle.Hide();
break;
}
}
}
}