Fix offsets not being mirrored

This commit is contained in:
Bartłomiej Dach 2021-08-10 21:42:41 +02:00
parent 30cb4280a4
commit 637e5cb6b7
No known key found for this signature in database
GPG Key ID: BCECCD4FA41F6497
2 changed files with 22 additions and 7 deletions

View File

@ -36,15 +36,13 @@ namespace osu.Game.Rulesets.Catch.Tests.Mods
beatmapProcessor.PreProcess();
foreach (var hitObject in beatmap.HitObjects)
{
hitObject.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
if (withMirrorMod)
mirrorMod.ApplyToHitObject(hitObject);
}
beatmapProcessor.PostProcess();
if (withMirrorMod)
mirrorMod.ApplyToBeatmap(beatmap);
return beatmap;
}

View File

@ -2,6 +2,8 @@
// See the LICENCE file in the repository root for full licence text.
using System.Linq;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Catch.Beatmaps;
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Catch.UI;
@ -10,11 +12,22 @@ using osuTK;
namespace osu.Game.Rulesets.Catch.Mods
{
public class CatchModMirror : ModMirror, IApplicableToHitObject
public class CatchModMirror : ModMirror, IApplicableToBeatmap
{
public override string Description => "Fruits are flipped horizontally.";
public void ApplyToHitObject(HitObject hitObject)
/// <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)
{
if (hitObject is BananaShower)
return;
@ -22,9 +35,13 @@ namespace osu.Game.Rulesets.Catch.Mods
var catchObject = (CatchHitObject)hitObject;
catchObject.OriginalX = CatchPlayfield.WIDTH - catchObject.OriginalX;
catchObject.XOffset = -catchObject.XOffset;
foreach (var nested in catchObject.NestedHitObjects.Cast<CatchHitObject>())
{
nested.OriginalX = CatchPlayfield.WIDTH - nested.OriginalX;
nested.XOffset = -nested.XOffset;
}
if (catchObject is JuiceStream juiceStream)
{