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-08-22 19:19:28 +00:00
|
|
|
|
using System.Linq;
|
2018-07-30 09:34:20 +00: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
|
|
|
|
|
{
|
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;
|
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-07-30 09:34:20 +00:00
|
|
|
|
|
2018-08-22 19:39:59 +00:00
|
|
|
|
private readonly IReadOnlyList<Type> targetHitObjectTypes = new List<Type> {
|
2018-08-22 19:16:45 +00:00
|
|
|
|
typeof(HitCircle),
|
|
|
|
|
typeof(Slider),
|
|
|
|
|
typeof(Spinner),
|
|
|
|
|
};
|
|
|
|
|
|
2018-07-30 09:34:20 +00:00
|
|
|
|
public void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables)
|
|
|
|
|
{
|
2018-08-22 19:27:20 +00:00
|
|
|
|
drawables.ForEach(drawable =>
|
2018-08-22 18:46:03 +00:00
|
|
|
|
drawable.ApplyCustomUpdateState += drawableOnApplyCustomUpdateState
|
|
|
|
|
);
|
2018-07-30 09:34:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-03 22:36:59 +00:00
|
|
|
|
private float theta;
|
2018-07-30 09:34:20 +00:00
|
|
|
|
|
|
|
|
|
private void drawableOnApplyCustomUpdateState(DrawableHitObject drawable, ArmedState state)
|
|
|
|
|
{
|
|
|
|
|
var hitObject = (OsuHitObject) drawable.HitObject;
|
|
|
|
|
|
2018-08-22 19:27:20 +00:00
|
|
|
|
if (!targetHitObjectTypes.Contains(hitObject.GetType()))
|
2018-08-22 19:16:45 +00:00
|
|
|
|
return;
|
|
|
|
|
|
2018-08-22 19:27:20 +00:00
|
|
|
|
float appearDistance = (float)hitObject.TimePreempt * 0.5f;
|
2018-07-30 09:34:20 +00:00
|
|
|
|
|
2018-07-30 09:39:21 +00:00
|
|
|
|
Vector2 originalPosition = drawable.Position;
|
2018-08-22 19:27:20 +00:00
|
|
|
|
Vector2 appearOffset = new Vector2((float)Math.Cos(theta), (float)Math.Sin(theta)) * appearDistance;
|
2018-08-05 13:39:12 +00:00
|
|
|
|
|
|
|
|
|
//the - 1 and + 1 prevents the hit explosion to appear in the wrong position.
|
2018-08-05 13:38:27 +00:00
|
|
|
|
double appearTime = hitObject.StartTime - hitObject.TimePreempt - 1;
|
|
|
|
|
double moveDuration = hitObject.TimePreempt + 1;
|
2018-07-30 09:39:21 +00:00
|
|
|
|
|
2018-08-05 13:38:27 +00:00
|
|
|
|
using (drawable.BeginAbsoluteSequence(appearTime, true))
|
2018-07-30 09:34:20 +00:00
|
|
|
|
{
|
|
|
|
|
drawable
|
2018-08-22 18:46:03 +00:00
|
|
|
|
.MoveToOffset(appearOffset)
|
2018-08-05 13:38:27 +00:00
|
|
|
|
.MoveTo(originalPosition, moveDuration, Easing.InOutSine);
|
2018-07-30 09:34:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-08-22 18:46:03 +00:00
|
|
|
|
theta += 0.4f;
|
2018-07-30 09:34:20 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|