osu/osu.Game.Rulesets.Osu/Mods/OsuModArrange.cs

60 lines
2.2 KiB
C#
Raw Normal View History

2018-08-03 22:29:32 +00:00
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
2018-07-30 09:34:20 +00:00
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.Fun;
2018-07-30 09:34:20 +00:00
public override string Description => "Everything rotates. EVERYTHING";
public override double ScoreMultiplier => 1.05;
public void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables)
{
drawables.ForEach(drawable => drawable.ApplyCustomUpdateState += drawableOnApplyCustomUpdateState);
}
2018-08-03 22:36:59 +00:00
private float theta;
2018-07-30 09:34:20 +00:00
private void drawableOnApplyCustomUpdateState(DrawableHitObject drawable, ArmedState state)
{
var hitObject = (OsuHitObject) drawable.HitObject;
2018-07-30 09:39:21 +00:00
// repeat points get their position data from the slider.
if (hitObject is RepeatPoint)
2018-07-30 09:34:20 +00:00
return;
2018-07-30 09:39:21 +00:00
Vector2 originalPosition = drawable.Position;
// avoiding that the player can see the abroupt move.
const int pre_time_offset = 1000;
const float appearDistance = 250;
2018-07-30 09:39:21 +00:00
using (drawable.BeginAbsoluteSequence(hitObject.StartTime - hitObject.TimeFadeIn - pre_time_offset, true))
2018-07-30 09:34:20 +00:00
{
drawable
.MoveToOffset(new Vector2((float)Math.Cos(theta), (float)Math.Sin(theta)) * appearDistance)
2018-07-30 09:39:21 +00:00
.MoveTo(originalPosition, hitObject.TimeFadeIn + pre_time_offset, Easing.InOutSine);
2018-07-30 09:34:20 +00:00
}
2018-07-30 09:39:21 +00:00
// That way slider ticks come all from the same direction.
2018-07-30 09:34:20 +00:00
if (hitObject is HitCircle || hitObject is Slider)
theta += 0.4f;
}
}
}