From 23a37d06cf7ef515d8af336d12812c4fa089567a Mon Sep 17 00:00:00 2001 From: miterosan Date: Mon, 30 Jul 2018 11:34:20 +0200 Subject: [PATCH] Implement the arrange mod. --- osu.Game.Rulesets.Osu/Mods/OsuModArrange.cs | 56 +++++++++++++++++++++ osu.Game.Rulesets.Osu/OsuRuleset.cs | 1 + 2 files changed, 57 insertions(+) create mode 100644 osu.Game.Rulesets.Osu/Mods/OsuModArrange.cs diff --git a/osu.Game.Rulesets.Osu/Mods/OsuModArrange.cs b/osu.Game.Rulesets.Osu/Mods/OsuModArrange.cs new file mode 100644 index 0000000000..78f956416a --- /dev/null +++ b/osu.Game.Rulesets.Osu/Mods/OsuModArrange.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using osu.Framework.Extensions.IEnumerableExtensions; +using osu.Framework.Graphics; +using osu.Game.Graphics; +using osu.Game.Rulesets.Mods; +using osu.Game.Rulesets.Objects.Drawables; +using osu.Game.Rulesets.Osu.Objects; +using OpenTK; + +namespace osu.Game.Rulesets.Osu.Mods +{ + internal class OsuModArrange : Mod, IApplicableToDrawableHitObjects + { + public override string Name => "Arrange"; + public override string ShortenedName => "Arrange"; + public override FontAwesome Icon => FontAwesome.fa_arrows; + public override ModType Type => ModType.DifficultyIncrease; + public override string Description => "Everything rotates. EVERYTHING"; + public override bool Ranked => true; + public override double ScoreMultiplier => 1.05; + + public void ApplyToDrawableHitObjects(IEnumerable drawables) + { + drawables.ForEach(drawable => drawable.ApplyCustomUpdateState += drawableOnApplyCustomUpdateState); + } + + private float theta = 0; + + private void drawableOnApplyCustomUpdateState(DrawableHitObject drawable, ArmedState state) + { + var hitObject = (OsuHitObject) drawable.HitObject; + + Vector2 origPos; + + if (hitObject is RepeatPoint rp) + { + return; + } + else + { + origPos = drawable.Position; + } + + using (drawable.BeginAbsoluteSequence(hitObject.StartTime - hitObject.TimeFadeIn - 1000, true)) + { + drawable + .MoveToOffset(new Vector2((float)Math.Cos(theta), (float)Math.Sin(theta)) * 250) + .MoveTo(origPos, hitObject.TimeFadeIn + 1000, Easing.InOutSine); + } + + if (hitObject is HitCircle || hitObject is Slider) + theta += 0.4f; + } + } +} diff --git a/osu.Game.Rulesets.Osu/OsuRuleset.cs b/osu.Game.Rulesets.Osu/OsuRuleset.cs index b8ba1e2945..0d4d75d8d5 100644 --- a/osu.Game.Rulesets.Osu/OsuRuleset.cs +++ b/osu.Game.Rulesets.Osu/OsuRuleset.cs @@ -103,6 +103,7 @@ public override IEnumerable GetModsFor(ModType type) new MultiMod(new OsuModDoubleTime(), new OsuModNightcore()), new OsuModHidden(), new OsuModFlashlight(), + new OsuModArrange(), }; case ModType.Special: return new Mod[]