2018-08-04 06:29:32 +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
|
|
|
|
|
|
|
|
|
|
using System;
|
2018-07-30 17:34:20 +08: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;
|
2018-08-04 06:26:26 +08:00
|
|
|
|
public override ModType Type => ModType.Fun;
|
2018-08-05 21:16:10 +08:00
|
|
|
|
public override string Description => "Everything rotates. EVERYTHING.";
|
2018-08-05 21:16:25 +08:00
|
|
|
|
public override double ScoreMultiplier => 1;
|
2018-07-30 17:34:20 +08:00
|
|
|
|
|
|
|
|
|
public void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables)
|
|
|
|
|
{
|
2018-08-23 02:46:03 +08:00
|
|
|
|
drawables.Where(drawable => (
|
|
|
|
|
drawable is DrawableHitCircle ||
|
|
|
|
|
drawable is DrawableSlider ||
|
|
|
|
|
drawable is DrawableSpinner
|
|
|
|
|
)).ForEach(drawable =>
|
|
|
|
|
drawable.ApplyCustomUpdateState += drawableOnApplyCustomUpdateState
|
|
|
|
|
);
|
2018-07-30 17:34:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-04 06:36:59 +08:00
|
|
|
|
private float theta;
|
2018-07-30 17:34:20 +08:00
|
|
|
|
|
|
|
|
|
private void drawableOnApplyCustomUpdateState(DrawableHitObject drawable, ArmedState state)
|
|
|
|
|
{
|
|
|
|
|
var hitObject = (OsuHitObject) drawable.HitObject;
|
|
|
|
|
|
2018-08-23 02:46:03 +08:00
|
|
|
|
float appear_distance = (float)hitObject.TimePreempt * 0.5f;
|
2018-07-30 17:34:20 +08:00
|
|
|
|
|
2018-07-30 17:39:21 +08:00
|
|
|
|
Vector2 originalPosition = drawable.Position;
|
2018-08-23 02:46:03 +08:00
|
|
|
|
Vector2 appearOffset = new Vector2((float)Math.Cos(theta), (float)Math.Sin(theta)) * appear_distance;
|
2018-08-05 21:39:12 +08:00
|
|
|
|
|
|
|
|
|
//the - 1 and + 1 prevents the hit explosion to appear in the wrong position.
|
2018-08-05 21:38:27 +08:00
|
|
|
|
double appearTime = hitObject.StartTime - hitObject.TimePreempt - 1;
|
|
|
|
|
double moveDuration = hitObject.TimePreempt + 1;
|
2018-07-30 17:39:21 +08:00
|
|
|
|
|
2018-08-05 21:38:27 +08:00
|
|
|
|
using (drawable.BeginAbsoluteSequence(appearTime, true))
|
2018-07-30 17:34:20 +08:00
|
|
|
|
{
|
|
|
|
|
drawable
|
2018-08-23 02:46:03 +08:00
|
|
|
|
.MoveToOffset(appearOffset)
|
2018-08-05 21:38:27 +08:00
|
|
|
|
.MoveTo(originalPosition, moveDuration, Easing.InOutSine);
|
2018-07-30 17:34:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-23 02:46:03 +08:00
|
|
|
|
theta += 0.4f;
|
2018-07-30 17:34:20 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|