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

54 lines
2.0 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.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
{
2018-08-22 19:19:28 +00:00
internal class OsuModTransform : Mod, IApplicableToDrawableHitObjects
2018-07-30 09:34:20 +00:00
{
2018-08-22 19:17:18 +00:00
public override string Name => "Transform";
public override string ShortenedName => "TR";
2018-07-30 09:34:20 +00:00
public override FontAwesome Icon => FontAwesome.fa_arrows;
public override ModType Type => ModType.Fun;
2018-08-05 13:16:10 +00:00
public override string Description => "Everything rotates. EVERYTHING.";
2018-08-05 13:16:25 +00:00
public override double ScoreMultiplier => 1;
public override Type[] IncompatibleMods => new[] { typeof(OsuModWiggle) };
private float theta;
2018-07-30 09:34:20 +00:00
public void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables)
{
foreach (var drawable in drawables)
{
var hitObject = (OsuHitObject) drawable.HitObject;
2018-07-30 09:34:20 +00:00
float appearDistance = (float)(hitObject.TimePreempt - hitObject.TimeFadeIn) / 2;
2018-07-30 09:34:20 +00:00
Vector2 originalPosition = drawable.Position;
Vector2 appearOffset = new Vector2((float)Math.Cos(theta), (float)Math.Sin(theta)) * appearDistance;
2018-07-30 09:34:20 +00:00
//the - 1 and + 1 prevents the hit objects to appear in the wrong position.
double appearTime = hitObject.StartTime - hitObject.TimePreempt - 1;
double moveDuration = hitObject.TimePreempt + 1;
using (drawable.BeginAbsoluteSequence(appearTime, true))
{
drawable
.MoveToOffset(appearOffset)
.MoveTo(originalPosition, moveDuration, Easing.InOutSine);
}
2018-07-30 09:34:20 +00:00
theta += (float) hitObject.TimeFadeIn / 1000;
}
}
2018-07-30 09:34:20 +00:00
}
}