2019-07-29 00:00:41 +08:00
|
|
|
// 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.
|
2018-09-19 11:15:36 +08:00
|
|
|
|
2018-09-21 07:06:37 +08:00
|
|
|
using System;
|
2018-09-19 11:15:36 +08:00
|
|
|
using System.Collections.Generic;
|
2018-09-20 11:56:25 +08:00
|
|
|
using System.Linq;
|
2019-07-29 00:00:41 +08:00
|
|
|
using osu.Framework.Bindables;
|
2018-09-19 11:15:36 +08:00
|
|
|
using osu.Framework.Graphics;
|
2019-07-29 00:00:41 +08:00
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
using osu.Game.Configuration;
|
2018-09-19 11:15:36 +08:00
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
2019-07-29 00:00:41 +08:00
|
|
|
using osuTK;
|
2018-09-19 11:15:36 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Mods
|
|
|
|
{
|
2019-07-29 00:00:41 +08:00
|
|
|
public class OsuModSpinIn : Mod, IApplicableToDrawableHitObjects, IReadFromConfig
|
2018-09-19 11:15:36 +08:00
|
|
|
{
|
2018-09-21 07:06:37 +08:00
|
|
|
public override string Name => "Spin In";
|
2019-07-29 00:00:41 +08:00
|
|
|
public override string Acronym => "SI";
|
2020-01-14 21:22:00 +08:00
|
|
|
public override IconUsage? Icon => FontAwesome.Solid.Undo;
|
2018-09-19 11:15:36 +08:00
|
|
|
public override ModType Type => ModType.Fun;
|
2018-09-21 11:51:43 +08:00
|
|
|
public override string Description => "Circles spin in. No approach circles.";
|
2018-09-19 11:15:36 +08:00
|
|
|
public override double ScoreMultiplier => 1;
|
2019-07-29 00:15:54 +08:00
|
|
|
|
|
|
|
// todo: this mod should be able to be compatible with hidden with a bit of further implementation.
|
2019-12-26 14:25:41 +08:00
|
|
|
public override Type[] IncompatibleMods => new[] { typeof(OsuModObjectScaleTween), typeof(OsuModHidden), typeof(OsuModTraceable) };
|
2018-09-21 07:06:37 +08:00
|
|
|
|
|
|
|
private const int rotate_offset = 360;
|
2019-07-29 00:00:41 +08:00
|
|
|
private const float rotate_starting_width = 2;
|
2018-09-21 07:06:37 +08:00
|
|
|
|
2019-07-29 00:00:41 +08:00
|
|
|
private Bindable<bool> increaseFirstObjectVisibility = new Bindable<bool>();
|
|
|
|
|
|
|
|
public void ReadFromConfig(OsuConfigManager config)
|
|
|
|
{
|
|
|
|
increaseFirstObjectVisibility = config.GetBindable<bool>(OsuSetting.IncreaseFirstObjectVisibility);
|
|
|
|
}
|
2018-09-19 11:15:36 +08:00
|
|
|
|
|
|
|
public void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables)
|
|
|
|
{
|
2019-07-29 00:00:41 +08:00
|
|
|
foreach (var drawable in drawables.Skip(increaseFirstObjectVisibility.Value ? 1 : 0))
|
2018-09-19 11:15:36 +08:00
|
|
|
{
|
2019-07-29 00:00:41 +08:00
|
|
|
switch (drawable)
|
|
|
|
{
|
|
|
|
case DrawableSpinner _:
|
|
|
|
continue;
|
|
|
|
|
|
|
|
default:
|
|
|
|
drawable.ApplyCustomUpdateState += applyZoomState;
|
|
|
|
break;
|
|
|
|
}
|
2018-09-19 11:15:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-29 00:00:41 +08:00
|
|
|
private void applyZoomState(DrawableHitObject drawable, ArmedState state)
|
2018-09-19 11:15:36 +08:00
|
|
|
{
|
|
|
|
var h = (OsuHitObject)drawable.HitObject;
|
2018-09-21 11:51:43 +08:00
|
|
|
|
2018-09-20 11:56:25 +08:00
|
|
|
switch (drawable)
|
2018-09-19 11:15:36 +08:00
|
|
|
{
|
2018-09-20 11:56:25 +08:00
|
|
|
case DrawableHitCircle circle:
|
2019-07-29 00:00:41 +08:00
|
|
|
using (circle.BeginAbsoluteSequence(h.StartTime - h.TimePreempt, true))
|
2018-09-20 11:56:25 +08:00
|
|
|
{
|
2019-07-29 00:00:41 +08:00
|
|
|
circle.ApproachCircle.Hide();
|
2018-09-19 11:15:36 +08:00
|
|
|
|
2019-07-29 00:00:41 +08:00
|
|
|
circle.RotateTo(rotate_offset).Then().RotateTo(0, h.TimePreempt, Easing.InOutSine);
|
|
|
|
circle.ScaleTo(new Vector2(rotate_starting_width, 0)).Then().ScaleTo(1, h.TimePreempt, Easing.InOutSine);
|
2018-09-20 11:56:25 +08:00
|
|
|
|
2019-07-29 00:00:41 +08:00
|
|
|
// bypass fade in.
|
|
|
|
if (state == ArmedState.Idle)
|
|
|
|
circle.FadeIn();
|
2018-09-21 12:07:09 +08:00
|
|
|
}
|
2018-09-20 11:56:25 +08:00
|
|
|
|
|
|
|
break;
|
2018-09-19 11:15:36 +08:00
|
|
|
|
2018-09-20 11:56:25 +08:00
|
|
|
case DrawableSlider slider:
|
2019-07-29 00:00:41 +08:00
|
|
|
using (slider.BeginAbsoluteSequence(h.StartTime - h.TimePreempt))
|
2018-09-20 11:56:25 +08:00
|
|
|
{
|
2019-07-29 00:00:41 +08:00
|
|
|
slider.ScaleTo(0).Then().ScaleTo(1, h.TimePreempt, Easing.InOutSine);
|
2018-09-20 11:56:25 +08:00
|
|
|
|
2019-07-29 00:00:41 +08:00
|
|
|
// bypass fade in.
|
|
|
|
if (state == ArmedState.Idle)
|
|
|
|
slider.FadeIn();
|
2018-09-20 11:56:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2018-09-19 11:15:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|