2019-01-24 16:43:03 +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-08-04 06:29:32 +08:00
|
|
|
|
|
|
|
|
|
using System;
|
2018-07-30 17:34:20 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using osu.Framework.Graphics;
|
2019-03-27 18:29:27 +08:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2018-07-30 17:34:20 +08:00
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
2018-11-20 15:51:59 +08:00
|
|
|
|
using osuTK;
|
2018-07-30 17:34:20 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Mods
|
|
|
|
|
{
|
2018-08-23 03:19:28 +08:00
|
|
|
|
internal class OsuModTransform : Mod, IApplicableToDrawableHitObjects
|
2018-07-30 17:34:20 +08:00
|
|
|
|
{
|
2018-08-23 03:17:18 +08:00
|
|
|
|
public override string Name => "Transform";
|
2018-11-30 16:16:00 +08:00
|
|
|
|
public override string Acronym => "TR";
|
2019-04-02 18:55:24 +08:00
|
|
|
|
public override IconUsage Icon => FontAwesome.Solid.ArrowsAlt;
|
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-09-15 20:55:29 +08:00
|
|
|
|
public override Type[] IncompatibleMods => new[] { typeof(OsuModWiggle) };
|
2018-09-15 20:43:22 +08:00
|
|
|
|
|
2018-08-25 04:23:27 +08:00
|
|
|
|
private float theta;
|
2018-08-23 03:16:45 +08:00
|
|
|
|
|
2018-07-30 17:34:20 +08:00
|
|
|
|
public void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables)
|
|
|
|
|
{
|
2018-08-25 04:23:27 +08:00
|
|
|
|
foreach (var drawable in drawables)
|
|
|
|
|
{
|
2019-02-28 12:31:40 +08:00
|
|
|
|
var hitObject = (OsuHitObject)drawable.HitObject;
|
2018-07-30 17:34:20 +08:00
|
|
|
|
|
2018-08-25 04:23:27 +08:00
|
|
|
|
float appearDistance = (float)(hitObject.TimePreempt - hitObject.TimeFadeIn) / 2;
|
2018-07-30 17:34:20 +08:00
|
|
|
|
|
2018-08-25 04:23:27 +08:00
|
|
|
|
Vector2 originalPosition = drawable.Position;
|
2019-11-25 07:45:42 +08:00
|
|
|
|
Vector2 appearOffset = new Vector2(MathF.Cos(theta), MathF.Sin(theta)) * appearDistance;
|
2018-07-30 17:34:20 +08:00
|
|
|
|
|
2018-09-06 03:09:09 +08:00
|
|
|
|
//the - 1 and + 1 prevents the hit objects to appear in the wrong position.
|
2018-08-25 04:23:27 +08:00
|
|
|
|
double appearTime = hitObject.StartTime - hitObject.TimePreempt - 1;
|
|
|
|
|
double moveDuration = hitObject.TimePreempt + 1;
|
2018-08-23 03:16:45 +08:00
|
|
|
|
|
2018-08-25 04:23:27 +08:00
|
|
|
|
using (drawable.BeginAbsoluteSequence(appearTime, true))
|
|
|
|
|
{
|
|
|
|
|
drawable
|
|
|
|
|
.MoveToOffset(appearOffset)
|
|
|
|
|
.MoveTo(originalPosition, moveDuration, Easing.InOutSine);
|
|
|
|
|
}
|
2018-07-30 17:34:20 +08:00
|
|
|
|
|
2019-02-28 12:31:40 +08:00
|
|
|
|
theta += (float)hitObject.TimeFadeIn / 1000;
|
2018-08-25 04:23:27 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-30 17:34:20 +08:00
|
|
|
|
}
|
|
|
|
|
}
|