1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-14 16:37:26 +08:00
osu-lazer/osu.Game.Rulesets.Osu/Mods/OsuModTransform.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

67 lines
2.7 KiB
C#
Raw Normal View History

// 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 osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
2022-08-11 04:09:11 +08:00
using osu.Framework.Localisation;
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;
using osu.Game.Rulesets.Osu.Objects.Drawables;
2018-11-20 15:51:59 +08:00
using osuTK;
2018-07-30 17:34:20 +08:00
namespace osu.Game.Rulesets.Osu.Mods
{
internal class OsuModTransform : ModWithVisibilityAdjustment
2018-07-30 17:34:20 +08:00
{
2018-08-23 03:17:18 +08:00
public override string Name => "Transform";
public override string Acronym => "TR";
2020-01-14 21:22:00 +08:00
public override IconUsage? Icon => FontAwesome.Solid.ArrowsAlt;
public override ModType Type => ModType.Fun;
2022-08-11 04:09:11 +08:00
public override LocalisableString Description => "Everything rotates. EVERYTHING.";
2018-08-05 21:16:25 +08:00
public override double ScoreMultiplier => 1;
2022-07-12 05:23:32 +08:00
public override Type[] IncompatibleMods => new[] { typeof(OsuModWiggle), typeof(OsuModMagnetised), typeof(OsuModRepel) };
private float theta;
protected override void ApplyIncreasedVisibilityState(DrawableHitObject hitObject, ArmedState state) => applyTransform(hitObject, state);
protected override void ApplyNormalVisibilityState(DrawableHitObject hitObject, ArmedState state) => applyTransform(hitObject, state);
private void applyTransform(DrawableHitObject drawable, ArmedState state)
2018-07-30 17:34:20 +08:00
{
switch (drawable)
{
2022-06-24 20:25:23 +08:00
case DrawableSliderHead:
case DrawableSliderTail:
case DrawableSliderTick:
case DrawableSliderRepeat:
return;
default:
var hitObject = (OsuHitObject)drawable.HitObject;
2018-07-30 17:34:20 +08:00
float appearDistance = (float)(hitObject.TimePreempt - hitObject.TimeFadeIn) / 2;
2018-07-30 17:34:20 +08:00
Vector2 originalPosition = drawable.Position;
Vector2 appearOffset = new Vector2(MathF.Cos(theta), MathF.Sin(theta)) * appearDistance;
2018-07-30 17:34:20 +08:00
2020-05-05 09:31:11 +08: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;
2021-07-05 23:52:39 +08:00
using (drawable.BeginAbsoluteSequence(appearTime))
{
drawable
.MoveToOffset(appearOffset)
.MoveTo(originalPosition, moveDuration, Easing.InOutSine);
}
2018-07-30 17:34:20 +08:00
theta += (float)hitObject.TimeFadeIn / 1000;
break;
}
}
2018-07-30 17:34:20 +08:00
}
}