2021-08-08 17:45:13 +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.
|
|
|
|
|
|
|
|
using System.Linq;
|
2021-08-10 19:42:41 +00:00
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Rulesets.Catch.Beatmaps;
|
2021-08-08 17:45:13 +00:00
|
|
|
using osu.Game.Rulesets.Catch.Objects;
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
using osu.Game.Rulesets.Catch.UI;
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.Mods
|
|
|
|
{
|
2021-08-10 19:42:41 +00:00
|
|
|
public class CatchModMirror : ModMirror, IApplicableToBeatmap
|
2021-08-08 17:45:13 +00:00
|
|
|
{
|
|
|
|
public override string Description => "Fruits are flipped horizontally.";
|
2021-08-08 18:27:48 +00:00
|
|
|
|
2021-08-10 19:42:41 +00:00
|
|
|
/// <remarks>
|
|
|
|
/// <see cref="IApplicableToBeatmap"/> is used instead of <see cref="IApplicableToHitObject"/>,
|
|
|
|
/// as <see cref="CatchBeatmapProcessor"/> applies offsets in <see cref="CatchBeatmapProcessor.PostProcess"/>.
|
|
|
|
/// <see cref="IApplicableToBeatmap"/> runs after post-processing, while <see cref="IApplicableToHitObject"/> runs before it.
|
|
|
|
/// </remarks>
|
|
|
|
public void ApplyToBeatmap(IBeatmap beatmap)
|
|
|
|
{
|
|
|
|
foreach (var hitObject in beatmap.HitObjects)
|
|
|
|
applyToHitObject(hitObject);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void applyToHitObject(HitObject hitObject)
|
2021-08-08 17:45:13 +00:00
|
|
|
{
|
2021-08-09 06:57:18 +00:00
|
|
|
if (hitObject is BananaShower)
|
2021-08-08 17:45:13 +00:00
|
|
|
return;
|
|
|
|
|
2021-08-09 06:57:18 +00:00
|
|
|
var catchObject = (CatchHitObject)hitObject;
|
|
|
|
|
2021-08-08 17:45:13 +00:00
|
|
|
catchObject.OriginalX = CatchPlayfield.WIDTH - catchObject.OriginalX;
|
2021-08-10 19:42:41 +00:00
|
|
|
catchObject.XOffset = -catchObject.XOffset;
|
2021-08-08 17:45:13 +00:00
|
|
|
|
|
|
|
foreach (var nested in catchObject.NestedHitObjects.Cast<CatchHitObject>())
|
2021-08-10 19:42:41 +00:00
|
|
|
{
|
2021-08-08 17:45:13 +00:00
|
|
|
nested.OriginalX = CatchPlayfield.WIDTH - nested.OriginalX;
|
2021-08-10 19:42:41 +00:00
|
|
|
nested.XOffset = -nested.XOffset;
|
|
|
|
}
|
2021-08-08 17:45:13 +00:00
|
|
|
|
2021-08-09 06:57:18 +00:00
|
|
|
if (catchObject is JuiceStream juiceStream)
|
|
|
|
{
|
|
|
|
var controlPoints = juiceStream.Path.ControlPoints.Select(p => new PathControlPoint(p.Position.Value, p.Type.Value)).ToArray();
|
|
|
|
foreach (var point in controlPoints)
|
|
|
|
point.Position.Value = new Vector2(-point.Position.Value.X, point.Position.Value.Y);
|
2021-08-08 17:45:13 +00:00
|
|
|
|
2021-08-09 06:57:18 +00:00
|
|
|
juiceStream.Path = new SliderPath(controlPoints, juiceStream.Path.ExpectedDistance.Value);
|
|
|
|
}
|
2021-08-08 17:45:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|