2021-11-27 20:34:09 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2021-06-16 13:24:07 +08:00
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
2021-06-18 11:54:40 +08:00
|
|
|
using System;
|
2021-06-16 13:24:07 +08:00
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
using osu.Game.Configuration;
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Mods
|
|
|
|
{
|
2021-06-28 23:52:39 +08:00
|
|
|
public class OsuModApproachDifferent : Mod, IApplicableToDrawableHitObject, IRequiresApproachCircles
|
2021-06-16 13:24:07 +08:00
|
|
|
{
|
|
|
|
public override string Name => "Approach Different";
|
|
|
|
public override string Acronym => "AD";
|
|
|
|
public override string Description => "Never trust the approach circles...";
|
|
|
|
public override double ScoreMultiplier => 1;
|
|
|
|
public override IconUsage? Icon { get; } = FontAwesome.Regular.Circle;
|
|
|
|
|
2021-06-28 23:52:39 +08:00
|
|
|
public override Type[] IncompatibleMods => new[] { typeof(IHidesApproachCircles) };
|
2021-06-18 11:54:40 +08:00
|
|
|
|
2021-06-16 16:32:30 +08:00
|
|
|
[SettingSource("Initial size", "Change the initial size of the approach circle, relative to hit circles.", 0)]
|
|
|
|
public BindableFloat Scale { get; } = new BindableFloat(4)
|
2021-06-16 13:24:07 +08:00
|
|
|
{
|
|
|
|
Precision = 0.1f,
|
2021-11-25 17:24:00 +08:00
|
|
|
MinValue = 1.5f,
|
2021-06-16 13:24:07 +08:00
|
|
|
MaxValue = 10,
|
|
|
|
};
|
|
|
|
|
2021-06-16 16:32:30 +08:00
|
|
|
[SettingSource("Style", "Change the animation style of the approach circles.", 1)]
|
2021-11-28 05:59:09 +08:00
|
|
|
public Bindable<AnimationStyle> Style { get; } = new Bindable<AnimationStyle>(AnimationStyle.Gravity);
|
2021-06-16 16:32:30 +08:00
|
|
|
|
2021-06-16 21:05:23 +08:00
|
|
|
public void ApplyToDrawableHitObject(DrawableHitObject drawable)
|
2021-06-16 13:24:07 +08:00
|
|
|
{
|
2022-06-24 20:25:23 +08:00
|
|
|
drawable.ApplyCustomUpdateState += (drawableObject, _) =>
|
2021-06-16 13:24:07 +08:00
|
|
|
{
|
2021-06-16 21:05:23 +08:00
|
|
|
if (!(drawableObject is DrawableHitCircle drawableHitCircle)) return;
|
2021-06-16 13:24:07 +08:00
|
|
|
|
2021-06-16 21:05:23 +08:00
|
|
|
var hitCircle = drawableHitCircle.HitObject;
|
2021-06-16 13:24:07 +08:00
|
|
|
|
2021-06-16 21:05:23 +08:00
|
|
|
drawableHitCircle.ApproachCircle.ClearTransforms(targetMember: nameof(Scale));
|
2021-06-16 13:24:07 +08:00
|
|
|
|
2021-06-16 21:05:23 +08:00
|
|
|
using (drawableHitCircle.BeginAbsoluteSequence(hitCircle.StartTime - hitCircle.TimePreempt))
|
|
|
|
drawableHitCircle.ApproachCircle.ScaleTo(Scale.Value).ScaleTo(1f, hitCircle.TimePreempt, getEasing(Style.Value));
|
|
|
|
};
|
2021-06-16 13:24:07 +08:00
|
|
|
}
|
|
|
|
|
2021-06-16 16:27:52 +08:00
|
|
|
private Easing getEasing(AnimationStyle style)
|
2021-06-16 13:24:07 +08:00
|
|
|
{
|
2021-06-16 16:27:52 +08:00
|
|
|
switch (style)
|
2021-06-16 13:24:07 +08:00
|
|
|
{
|
2021-11-28 22:19:12 +08:00
|
|
|
case AnimationStyle.Linear:
|
2021-06-16 13:24:07 +08:00
|
|
|
return Easing.None;
|
|
|
|
|
2021-11-28 22:19:12 +08:00
|
|
|
case AnimationStyle.Gravity:
|
|
|
|
return Easing.InBack;
|
|
|
|
|
|
|
|
case AnimationStyle.InOut1:
|
|
|
|
return Easing.InOutCubic;
|
|
|
|
|
|
|
|
case AnimationStyle.InOut2:
|
|
|
|
return Easing.InOutQuint;
|
|
|
|
|
2021-06-16 14:15:12 +08:00
|
|
|
case AnimationStyle.Accelerate1:
|
2021-06-16 13:24:07 +08:00
|
|
|
return Easing.In;
|
|
|
|
|
2021-06-16 14:15:12 +08:00
|
|
|
case AnimationStyle.Accelerate2:
|
2021-06-16 13:24:07 +08:00
|
|
|
return Easing.InCubic;
|
|
|
|
|
2021-06-16 14:15:12 +08:00
|
|
|
case AnimationStyle.Accelerate3:
|
2021-06-16 13:24:07 +08:00
|
|
|
return Easing.InQuint;
|
|
|
|
|
2021-06-16 14:15:12 +08:00
|
|
|
case AnimationStyle.Decelerate1:
|
2021-06-16 13:24:07 +08:00
|
|
|
return Easing.Out;
|
|
|
|
|
2021-06-16 14:15:12 +08:00
|
|
|
case AnimationStyle.Decelerate2:
|
2021-06-16 13:24:07 +08:00
|
|
|
return Easing.OutCubic;
|
|
|
|
|
2021-06-16 14:15:12 +08:00
|
|
|
case AnimationStyle.Decelerate3:
|
2021-06-16 13:24:07 +08:00
|
|
|
return Easing.OutQuint;
|
|
|
|
|
2021-11-28 22:19:12 +08:00
|
|
|
default:
|
|
|
|
throw new ArgumentOutOfRangeException(nameof(style), style, @"Unsupported animation style");
|
2021-06-16 13:24:07 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-16 14:15:12 +08:00
|
|
|
public enum AnimationStyle
|
2021-06-16 13:24:07 +08:00
|
|
|
{
|
2021-11-27 20:34:09 +08:00
|
|
|
Linear,
|
2021-11-28 22:16:33 +08:00
|
|
|
Gravity,
|
2021-06-16 16:27:43 +08:00
|
|
|
InOut1,
|
|
|
|
InOut2,
|
2021-06-16 13:24:07 +08:00
|
|
|
Accelerate1,
|
|
|
|
Accelerate2,
|
|
|
|
Accelerate3,
|
|
|
|
Decelerate1,
|
|
|
|
Decelerate2,
|
|
|
|
Decelerate3,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|