From 0219815a46455f2e87527d5fc283c662ba19ed70 Mon Sep 17 00:00:00 2001 From: cdwcgt Date: Tue, 21 Nov 2023 07:58:46 +0900 Subject: [PATCH] add TaikoModColorBind --- .../Mods/TestSceneTaikoModColorBind.cs | 19 +++++ .../Mods/TaikoModColorBind.cs | 72 +++++++++++++++++++ .../Mods/TaikoModHidden.cs | 4 ++ osu.Game.Rulesets.Taiko/TaikoRuleset.cs | 1 + 4 files changed, 96 insertions(+) create mode 100644 osu.Game.Rulesets.Taiko.Tests/Mods/TestSceneTaikoModColorBind.cs create mode 100644 osu.Game.Rulesets.Taiko/Mods/TaikoModColorBind.cs diff --git a/osu.Game.Rulesets.Taiko.Tests/Mods/TestSceneTaikoModColorBind.cs b/osu.Game.Rulesets.Taiko.Tests/Mods/TestSceneTaikoModColorBind.cs new file mode 100644 index 0000000000..ac787fad45 --- /dev/null +++ b/osu.Game.Rulesets.Taiko.Tests/Mods/TestSceneTaikoModColorBind.cs @@ -0,0 +1,19 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using NUnit.Framework; +using osu.Game.Rulesets.Taiko.Mods; + +namespace osu.Game.Rulesets.Taiko.Tests.Mods +{ + public partial class TestSceneTaikoModColorBind : TaikoModTestScene + { + [Test] + public void TestColorBind() => CreateModTest(new ModTestData + { + Mod = new TaikoModColorBind(), + Autoplay = true, + PassCondition = () => true, + }); + } +} diff --git a/osu.Game.Rulesets.Taiko/Mods/TaikoModColorBind.cs b/osu.Game.Rulesets.Taiko/Mods/TaikoModColorBind.cs new file mode 100644 index 0000000000..f52f40d9e1 --- /dev/null +++ b/osu.Game.Rulesets.Taiko/Mods/TaikoModColorBind.cs @@ -0,0 +1,72 @@ +// 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 osu.Framework.Graphics; +using osu.Framework.Localisation; +using osu.Game.Rulesets.Mods; +using osu.Game.Rulesets.Objects.Drawables; +using osu.Game.Rulesets.Taiko.Objects; +using osu.Game.Rulesets.Taiko.Objects.Drawables; +using osu.Game.Rulesets.Taiko.UI; +using osu.Game.Rulesets.UI; +using osuTK.Graphics; + +namespace osu.Game.Rulesets.Taiko.Mods +{ + public class TaikoModColorBind : ModWithVisibilityAdjustment, IApplicableToDrawableRuleset + { + public override string Name => "ColorBind"; + public override string Acronym => "CB"; + + public override LocalisableString Description => @"What these notes color?"; + + public override double ScoreMultiplier => 1.03; + + public override ModType Type => ModType.DifficultyIncrease; + + public override Type[] IncompatibleMods => new[] { typeof(TaikoModHidden) }; + + /// + /// How far away from the hit target should hitobjects start to lose color. + /// Range: [0, 1] + /// + private const float fade_out_start_time = 1f; + + /// + /// How long hitobjects take to lose color, in terms of the scrolling length. + /// Range: [0, 1] + /// + private const float fade_out_duration = 0.375f; + + private DrawableTaikoRuleset drawableRuleset = null!; + + public void ApplyToDrawableRuleset(DrawableRuleset drawableRuleset) + { + this.drawableRuleset = (DrawableTaikoRuleset)drawableRuleset; + } + + protected override void ApplyIncreasedVisibilityState(DrawableHitObject hitObject, ArmedState state) + { + ApplyNormalVisibilityState(hitObject, state); + } + + protected override void ApplyNormalVisibilityState(DrawableHitObject hitObject, ArmedState state) + { + switch (hitObject) + { + case DrawableHit: + double preempt = drawableRuleset.TimeRange.Value / drawableRuleset.ControlPointAt(hitObject.HitObject.StartTime).Multiplier; + double start = hitObject.HitObject.StartTime - preempt * fade_out_start_time; + double duration = preempt * fade_out_duration; + + using (hitObject.BeginAbsoluteSequence(start)) + { + hitObject.TransformBindableTo(hitObject.AccentColour, Color4.Gray, duration); + } + + break; + } + } + } +} diff --git a/osu.Game.Rulesets.Taiko/Mods/TaikoModHidden.cs b/osu.Game.Rulesets.Taiko/Mods/TaikoModHidden.cs index 2c3b4a8d18..8afd8d2696 100644 --- a/osu.Game.Rulesets.Taiko/Mods/TaikoModHidden.cs +++ b/osu.Game.Rulesets.Taiko/Mods/TaikoModHidden.cs @@ -1,6 +1,8 @@ // 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.Linq; using osu.Framework.Graphics; using osu.Framework.Localisation; using osu.Game.Rulesets.Mods; @@ -19,6 +21,8 @@ namespace osu.Game.Rulesets.Taiko.Mods public override LocalisableString Description => @"Beats fade out before you hit them!"; public override double ScoreMultiplier => UsesDefaultConfiguration ? 1.06 : 1; + public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(TaikoModColorBind)).ToArray(); + /// /// How far away from the hit target should hitobjects start to fade out. /// Range: [0, 1] diff --git a/osu.Game.Rulesets.Taiko/TaikoRuleset.cs b/osu.Game.Rulesets.Taiko/TaikoRuleset.cs index 072653dcbf..6427e57856 100644 --- a/osu.Game.Rulesets.Taiko/TaikoRuleset.cs +++ b/osu.Game.Rulesets.Taiko/TaikoRuleset.cs @@ -152,6 +152,7 @@ namespace osu.Game.Rulesets.Taiko new MultiMod(new TaikoModDoubleTime(), new TaikoModNightcore()), new TaikoModHidden(), new TaikoModFlashlight(), + new TaikoModColorBind(), new ModAccuracyChallenge(), };