From 2ce487bdacf8dc105d12a63f6613535585bb4823 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 16 Jun 2021 14:24:07 +0900 Subject: [PATCH] Rename mod and fix easing mappings / naming --- .../Mods/OsuModApproachCircle.cs | 73 ------------ .../Mods/OsuModDifferentApproach.cs | 110 ++++++++++++++++++ osu.Game.Rulesets.Osu/OsuRuleset.cs | 2 +- 3 files changed, 111 insertions(+), 74 deletions(-) delete mode 100644 osu.Game.Rulesets.Osu/Mods/OsuModApproachCircle.cs create mode 100644 osu.Game.Rulesets.Osu/Mods/OsuModDifferentApproach.cs diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModApproachCircle.cs b/osu.Game.Rulesets.Osu/Mods/OsuModApproachCircle.cs deleted file mode 100644 index 8e0175b5a3..0000000000 --- a/osu.Game.Rulesets.Osu/Mods/OsuModApproachCircle.cs +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. -// See the LICENCE file in the repository root for full licence text. - -using System; -using System.Collections.Generic; -using osu.Framework.Bindables; -using osu.Framework.Extensions.IEnumerableExtensions; -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 -{ - internal class OsuModApproachCircle : Mod, IApplicableToDrawableHitObjects - { - public override string Name => "Approach Circle"; - public override string Acronym => "AC"; - public override string Description => "Never trust the approach circles..."; - public override double ScoreMultiplier => 1; - public override IconUsage? Icon { get; } = FontAwesome.Regular.Circle; - - [SettingSource("Easing", "Change the easing type of the approach circles.", 0)] - public Bindable BindableEasing { get; } = new Bindable(); - - [SettingSource("Scale the size", "Change the factor of the approach circle scale.", 1)] - public BindableFloat Scale { get; } = new BindableFloat - { - Precision = 0.1f, - MinValue = 2, - MaxValue = 10, - Default = 4, - Value = 4 - }; - - public void ApplyToDrawableHitObjects(IEnumerable drawables) - { - drawables.ForEach(drawable => - { - drawable.ApplyCustomUpdateState += (drawableHitObj, state) => - { - if (!(drawableHitObj is DrawableHitCircle hitCircle)) return; - - var obj = hitCircle.HitObject; - - hitCircle.BeginAbsoluteSequence(obj.StartTime - obj.TimePreempt, true); - hitCircle.ApproachCircle.ScaleTo(Scale.Value); - - hitCircle.ApproachCircle.FadeIn(Math.Min(obj.TimeFadeIn, obj.TimePreempt)); - - hitCircle.ApproachCircle.ScaleTo(1f, obj.TimePreempt, (Easing)BindableEasing.Value); - - hitCircle.ApproachCircle.Expire(true); - }; - }); - } - - internal enum ReadableEasing - { - Accelerate = 2, - Accelerate2 = 6, - Accelerate3 = 12, - AccelerateInAfterDeceleraingeOut = 29, - CasualBounces = 32, - CasualBouncesWhileAccelerating = 24, - Decelerate = 1, - DecelerateAfterAccelerating = 8, - Default = 0, - } - } -} diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModDifferentApproach.cs b/osu.Game.Rulesets.Osu/Mods/OsuModDifferentApproach.cs new file mode 100644 index 0000000000..db612b6269 --- /dev/null +++ b/osu.Game.Rulesets.Osu/Mods/OsuModDifferentApproach.cs @@ -0,0 +1,110 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using System.Collections.Generic; +using osu.Framework.Bindables; +using osu.Framework.Extensions.IEnumerableExtensions; +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 +{ + internal class OsuModDifferentApproach : Mod, IApplicableToDrawableHitObjects + { + 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; + + [SettingSource("Easing", "Change the animation curve of the approach circles.", 0)] + public Bindable BindableEasing { get; } = new Bindable(); + + [SettingSource("Initial size", "Change the initial size of the approach circle, relative to hit circles.", 1)] + public BindableFloat Scale { get; } = new BindableFloat + { + Precision = 0.1f, + MinValue = 2, + MaxValue = 10, + Default = 4, + Value = 4 + }; + + public void ApplyToDrawableHitObjects(IEnumerable drawables) + { + drawables.ForEach(drawable => + { + drawable.ApplyCustomUpdateState += (drawableHitObj, state) => + { + if (!(drawableHitObj is DrawableHitCircle hitCircle)) return; + + var obj = hitCircle.HitObject; + + hitCircle.BeginAbsoluteSequence(obj.StartTime - obj.TimePreempt, true); + hitCircle.ApproachCircle.ScaleTo(Scale.Value); + + hitCircle.ApproachCircle.FadeIn(Math.Min(obj.TimeFadeIn, obj.TimePreempt)); + + hitCircle.ApproachCircle.ScaleTo(1f, obj.TimePreempt, getEasing(BindableEasing.Value)); + + hitCircle.ApproachCircle.Expire(true); + }; + }); + } + + private Easing getEasing(ApproachCircleEasing approachEasing) + { + switch (approachEasing) + { + default: + return Easing.None; + + case ApproachCircleEasing.Accelerate1: + return Easing.In; + + case ApproachCircleEasing.Accelerate2: + return Easing.InCubic; + + case ApproachCircleEasing.Accelerate3: + return Easing.InQuint; + + case ApproachCircleEasing.Gravity: + return Easing.InBack; + + case ApproachCircleEasing.Decelerate1: + return Easing.Out; + + case ApproachCircleEasing.Decelerate2: + return Easing.OutCubic; + + case ApproachCircleEasing.Decelerate3: + return Easing.OutQuint; + + case ApproachCircleEasing.InOut1: + return Easing.InOutCubic; + + case ApproachCircleEasing.InOut2: + return Easing.InOutQuint; + } + } + + public enum ApproachCircleEasing + { + Default, + Accelerate1, + Accelerate2, + Accelerate3, + Gravity, + Decelerate1, + Decelerate2, + Decelerate3, + InOut1, + InOut2, + } + } +} diff --git a/osu.Game.Rulesets.Osu/OsuRuleset.cs b/osu.Game.Rulesets.Osu/OsuRuleset.cs index 0f7ee6ade2..217803ee7b 100644 --- a/osu.Game.Rulesets.Osu/OsuRuleset.cs +++ b/osu.Game.Rulesets.Osu/OsuRuleset.cs @@ -187,7 +187,7 @@ namespace osu.Game.Rulesets.Osu new MultiMod(new ModWindUp(), new ModWindDown()), new OsuModTraceable(), new OsuModBarrelRoll(), - new OsuModApproachCircle(), + new OsuModDifferentApproach(), }; case ModType.System: