add grow mod

This commit is contained in:
LeNitrous 2019-01-31 17:03:43 +08:00
parent 7d8c274bae
commit 902be0d059
3 changed files with 55 additions and 1 deletions

@ -1 +1 @@
Subproject commit 677897728f4332fa1200e0280ca02c4b987c6c47
Subproject commit 9880089b4e8fcd78d68f30c8a40d43bf8dccca86

View File

@ -0,0 +1,53 @@
// 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.Collections.Generic;
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 osu.Game.Rulesets.Osu.Objects.Drawables;
using osuTK;
namespace osu.Game.Rulesets.Osu.Mods
{
internal class OsuModGrow : Mod, IApplicableToDrawableHitObjects
{
public override string Name => "Grow";
public override string Acronym => "GR";
public override FontAwesome Icon => FontAwesome.fa_arrows_v;
public override ModType Type => ModType.Fun;
public override string Description => "Hit them at the right size!";
public override double ScoreMultiplier => 1;
public void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables)
{
foreach (var drawable in drawables)
{
if (drawable is DrawableSpinner spinner)
return;
drawable.ApplyCustomUpdateState += applyCustomState;
}
}
protected virtual void applyCustomState(DrawableHitObject drawable, ArmedState state)
{
var hitObject = (OsuHitObject) drawable.HitObject;
double appearTime = hitObject.StartTime - hitObject.TimePreempt - 1;
double scaleDuration = hitObject.TimePreempt + 1;
var originalScale = drawable.Scale;
drawable.Scale /= 2;
using (drawable.BeginAbsoluteSequence(appearTime, true))
drawable.ScaleTo(originalScale, scaleDuration, Easing.OutSine);
if (drawable is DrawableHitCircle circle)
using (circle.BeginAbsoluteSequence(hitObject.StartTime - hitObject.TimePreempt))
circle.ApproachCircle.Hide();
}
}
}

View File

@ -124,6 +124,7 @@ public override IEnumerable<Mod> GetModsFor(ModType type)
return new Mod[] {
new OsuModTransform(),
new OsuModWiggle(),
new OsuModGrow()
};
default:
return new Mod[] { };