2019-01-24 08:43:03 +00: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-03 22:29:32 +00:00
|
|
|
|
|
|
|
|
|
using System;
|
2018-07-30 09:34:20 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
2019-03-27 10:29:27 +00:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2018-07-30 09:34:20 +00:00
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
2020-02-16 02:58:41 +00:00
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
2018-11-20 07:51:59 +00:00
|
|
|
|
using osuTK;
|
2018-07-30 09:34:20 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Mods
|
|
|
|
|
{
|
2020-11-05 07:04:42 +00:00
|
|
|
|
internal class OsuModTransform : ModWithVisibilityAdjustment
|
2018-07-30 09:34:20 +00:00
|
|
|
|
{
|
2018-08-22 19:17:18 +00:00
|
|
|
|
public override string Name => "Transform";
|
2018-11-30 08:16:00 +00:00
|
|
|
|
public override string Acronym => "TR";
|
2020-01-14 13:22:00 +00:00
|
|
|
|
public override IconUsage? Icon => FontAwesome.Solid.ArrowsAlt;
|
2018-08-03 22:26:26 +00:00
|
|
|
|
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;
|
2018-09-15 12:55:29 +00:00
|
|
|
|
public override Type[] IncompatibleMods => new[] { typeof(OsuModWiggle) };
|
2018-09-15 12:43:22 +00:00
|
|
|
|
|
2018-08-24 20:23:27 +00:00
|
|
|
|
private float theta;
|
2018-08-22 19:16:45 +00:00
|
|
|
|
|
2020-11-05 07:04:42 +00:00
|
|
|
|
protected override void ApplyIncreasedVisibilityState(DrawableHitObject hitObject, ArmedState state) => applyTransform(hitObject, state);
|
|
|
|
|
|
|
|
|
|
protected override void ApplyNormalVisibilityState(DrawableHitObject hitObject, ArmedState state) => applyTransform(hitObject, state);
|
2020-02-16 02:58:41 +00:00
|
|
|
|
|
|
|
|
|
private void applyTransform(DrawableHitObject drawable, ArmedState state)
|
|
|
|
|
{
|
|
|
|
|
switch (drawable)
|
2018-08-24 20:23:27 +00:00
|
|
|
|
{
|
2020-02-16 02:58:41 +00:00
|
|
|
|
case DrawableSliderHead _:
|
|
|
|
|
case DrawableSliderTail _:
|
|
|
|
|
case DrawableSliderTick _:
|
2020-03-19 05:26:24 +00:00
|
|
|
|
case DrawableSliderRepeat _:
|
2020-02-16 02:58:41 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
var hitObject = (OsuHitObject)drawable.HitObject;
|
2018-07-30 09:34:20 +00:00
|
|
|
|
|
2020-02-16 02:58:41 +00:00
|
|
|
|
float appearDistance = (float)(hitObject.TimePreempt - hitObject.TimeFadeIn) / 2;
|
2018-07-30 09:34:20 +00:00
|
|
|
|
|
2020-02-16 02:58:41 +00:00
|
|
|
|
Vector2 originalPosition = drawable.Position;
|
|
|
|
|
Vector2 appearOffset = new Vector2(MathF.Cos(theta), MathF.Sin(theta)) * appearDistance;
|
2018-07-30 09:34:20 +00:00
|
|
|
|
|
2020-05-05 01:31:11 +00:00
|
|
|
|
// the - 1 and + 1 prevents the hit objects to appear in the wrong position.
|
2020-02-16 02:58:41 +00:00
|
|
|
|
double appearTime = hitObject.StartTime - hitObject.TimePreempt - 1;
|
|
|
|
|
double moveDuration = hitObject.TimePreempt + 1;
|
2018-08-22 19:16:45 +00:00
|
|
|
|
|
2021-07-05 15:52:39 +00:00
|
|
|
|
using (drawable.BeginAbsoluteSequence(appearTime))
|
2020-02-16 02:58:41 +00:00
|
|
|
|
{
|
|
|
|
|
drawable
|
|
|
|
|
.MoveToOffset(appearOffset)
|
|
|
|
|
.MoveTo(originalPosition, moveDuration, Easing.InOutSine);
|
|
|
|
|
}
|
2018-07-30 09:34:20 +00:00
|
|
|
|
|
2020-02-16 02:58:41 +00:00
|
|
|
|
theta += (float)hitObject.TimeFadeIn / 1000;
|
|
|
|
|
break;
|
2018-08-24 20:23:27 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-30 09:34:20 +00:00
|
|
|
|
}
|
|
|
|
|
}
|