2018-09-19 11:15:36 +08:00
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
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;
|
2018-09-21 07:06:37 +08:00
|
|
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
2018-09-19 11:15:36 +08:00
|
|
|
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;
|
2018-09-21 07:06:37 +08:00
|
|
|
using OpenTK;
|
2018-09-19 11:15:36 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Mods
|
|
|
|
{
|
2018-09-21 07:06:37 +08:00
|
|
|
public class OsuModSpinIn : Mod, IApplicableToDrawableHitObjects
|
2018-09-19 11:15:36 +08:00
|
|
|
{
|
2018-09-21 07:06:37 +08:00
|
|
|
public override string Name => "Spin In";
|
|
|
|
public override string ShortenedName => "SI";
|
|
|
|
public override FontAwesome Icon => FontAwesome.fa_rotate_right;
|
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;
|
2018-09-21 07:06:37 +08:00
|
|
|
public override Type[] IncompatibleMods => new[] { typeof(OsuModHidden) };
|
|
|
|
|
|
|
|
private const int rotate_offset = 360;
|
2018-09-22 08:26:01 +08:00
|
|
|
private const float rotate_starting_width = 2.0f;
|
2018-09-21 07:06:37 +08:00
|
|
|
|
2018-09-19 11:15:36 +08:00
|
|
|
|
|
|
|
public void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables)
|
|
|
|
{
|
|
|
|
foreach (var drawable in drawables)
|
|
|
|
{
|
2018-09-21 11:51:43 +08:00
|
|
|
// Need to add custom update in order to disable fade
|
2018-09-21 07:06:37 +08:00
|
|
|
drawable.ApplyCustomUpdateState += ApplyZoomState;
|
2018-09-19 11:15:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-21 07:06:37 +08:00
|
|
|
protected void ApplyZoomState(DrawableHitObject drawable, ArmedState state)
|
2018-09-19 11:15:36 +08:00
|
|
|
{
|
2018-09-20 11:56:25 +08:00
|
|
|
if (!(drawable is DrawableOsuHitObject)) return;
|
|
|
|
if (state != ArmedState.Idle) return;
|
2018-09-19 11:15:36 +08:00
|
|
|
|
|
|
|
var h = (OsuHitObject)drawable.HitObject;
|
2018-09-21 11:51:43 +08:00
|
|
|
|
|
|
|
var appearTime = h.StartTime - h.TimePreempt + 1;
|
|
|
|
var moveDuration = h.TimePreempt - 1;
|
2018-09-19 11:15:36 +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:
|
2018-09-21 07:06:37 +08:00
|
|
|
// Disable Fade
|
|
|
|
circle.Transforms
|
|
|
|
.Where(t => t.TargetMember == "Alpha")
|
|
|
|
.ForEach(t => circle.RemoveTransform(t));
|
|
|
|
|
2018-09-20 11:56:25 +08:00
|
|
|
using (circle.BeginAbsoluteSequence(appearTime, true))
|
|
|
|
{
|
|
|
|
var origScale = drawable.Scale;
|
2018-09-21 07:06:37 +08:00
|
|
|
var origRotate = circle.Rotation;
|
2018-09-19 11:15:36 +08:00
|
|
|
|
2018-09-20 11:56:25 +08:00
|
|
|
circle
|
2018-09-21 07:06:37 +08:00
|
|
|
.RotateTo(origRotate+rotate_offset)
|
2018-09-22 08:26:01 +08:00
|
|
|
.RotateTo(origRotate, moveDuration, Easing.InOutSine)
|
2018-09-21 07:06:37 +08:00
|
|
|
.ScaleTo(origScale * new Vector2(rotate_starting_width, 0))
|
2018-09-22 08:26:01 +08:00
|
|
|
.ScaleTo(origScale, moveDuration, Easing.InOutSine)
|
2018-09-20 11:56:25 +08:00
|
|
|
.FadeTo(1);
|
|
|
|
}
|
|
|
|
|
2018-09-21 12:07:09 +08:00
|
|
|
using (circle.ApproachCircle.BeginAbsoluteSequence(appearTime, true))
|
|
|
|
{
|
|
|
|
circle.ApproachCircle.Hide();
|
|
|
|
}
|
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:
|
2018-09-21 07:06:37 +08:00
|
|
|
// Disable fade
|
|
|
|
slider.Transforms
|
|
|
|
.Where(t => t.TargetMember == "Alpha")
|
|
|
|
.ForEach(t => slider.RemoveTransform(t));
|
2018-09-20 11:56:25 +08:00
|
|
|
|
|
|
|
using (slider.BeginAbsoluteSequence(appearTime, true))
|
|
|
|
{
|
|
|
|
var origScale = slider.Scale;
|
|
|
|
|
|
|
|
slider
|
|
|
|
.ScaleTo(0)
|
2018-09-22 08:26:01 +08:00
|
|
|
.ScaleTo(origScale, moveDuration, Easing.InOutSine)
|
2018-09-20 11:56:25 +08:00
|
|
|
.FadeTo(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2018-09-19 11:15:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|