mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 14:13:01 +08:00
Merge pull request #13628 from ekrctb/add-IApplicableToBeatmapProcessor
Add `IApplicableToBeatmapProcessor` mod interface
This commit is contained in:
commit
b6793aadb4
@ -8,7 +8,6 @@ using osu.Game.Beatmaps;
|
|||||||
using osu.Game.Rulesets.Catch.MathUtils;
|
using osu.Game.Rulesets.Catch.MathUtils;
|
||||||
using osu.Game.Rulesets.Catch.Objects;
|
using osu.Game.Rulesets.Catch.Objects;
|
||||||
using osu.Game.Rulesets.Catch.UI;
|
using osu.Game.Rulesets.Catch.UI;
|
||||||
using osu.Game.Rulesets.Mods;
|
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Beatmaps
|
namespace osu.Game.Rulesets.Catch.Beatmaps
|
||||||
@ -17,6 +16,8 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
|
|||||||
{
|
{
|
||||||
public const int RNG_SEED = 1337;
|
public const int RNG_SEED = 1337;
|
||||||
|
|
||||||
|
public bool HardRockOffsets { get; set; }
|
||||||
|
|
||||||
public CatchBeatmapProcessor(IBeatmap beatmap)
|
public CatchBeatmapProcessor(IBeatmap beatmap)
|
||||||
: base(beatmap)
|
: base(beatmap)
|
||||||
{
|
{
|
||||||
@ -43,11 +44,10 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ApplyPositionOffsets(IBeatmap beatmap, params Mod[] mods)
|
public void ApplyPositionOffsets(IBeatmap beatmap)
|
||||||
{
|
{
|
||||||
var rng = new FastRandom(RNG_SEED);
|
var rng = new FastRandom(RNG_SEED);
|
||||||
|
|
||||||
bool shouldApplyHardRockOffset = mods.Any(m => m is ModHardRock);
|
|
||||||
float? lastPosition = null;
|
float? lastPosition = null;
|
||||||
double lastStartTime = 0;
|
double lastStartTime = 0;
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
|
|||||||
switch (obj)
|
switch (obj)
|
||||||
{
|
{
|
||||||
case Fruit fruit:
|
case Fruit fruit:
|
||||||
if (shouldApplyHardRockOffset)
|
if (HardRockOffsets)
|
||||||
applyHardRockOffset(fruit, ref lastPosition, ref lastStartTime, rng);
|
applyHardRockOffset(fruit, ref lastPosition, ref lastStartTime, rng);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -7,10 +7,14 @@ using osu.Game.Rulesets.Catch.Beatmaps;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Mods
|
namespace osu.Game.Rulesets.Catch.Mods
|
||||||
{
|
{
|
||||||
public class CatchModHardRock : ModHardRock, IApplicableToBeatmap
|
public class CatchModHardRock : ModHardRock, IApplicableToBeatmapProcessor
|
||||||
{
|
{
|
||||||
public override double ScoreMultiplier => 1.12;
|
public override double ScoreMultiplier => 1.12;
|
||||||
|
|
||||||
public void ApplyToBeatmap(IBeatmap beatmap) => CatchBeatmapProcessor.ApplyPositionOffsets(beatmap, this);
|
public void ApplyToBeatmapProcessor(IBeatmapProcessor beatmapProcessor)
|
||||||
|
{
|
||||||
|
var catchProcessor = (CatchBeatmapProcessor)beatmapProcessor;
|
||||||
|
catchProcessor.HardRockOffsets = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,6 +133,9 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
IBeatmapProcessor processor = rulesetInstance.CreateBeatmapProcessor(converted);
|
IBeatmapProcessor processor = rulesetInstance.CreateBeatmapProcessor(converted);
|
||||||
|
|
||||||
|
foreach (var mod in mods.OfType<IApplicableToBeatmapProcessor>())
|
||||||
|
mod.ApplyToBeatmapProcessor(processor);
|
||||||
|
|
||||||
processor?.PreProcess();
|
processor?.PreProcess();
|
||||||
|
|
||||||
// Compute default values for hitobjects, including creating nested hitobjects in-case they're needed
|
// Compute default values for hitobjects, including creating nested hitobjects in-case they're needed
|
||||||
|
18
osu.Game/Rulesets/Mods/IApplicableToBeatmapProcessor.cs
Normal file
18
osu.Game/Rulesets/Mods/IApplicableToBeatmapProcessor.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// 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 osu.Game.Beatmaps;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Mods
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interface for a <see cref="Mod"/> that applies changes to a <see cref="BeatmapProcessor"/>.
|
||||||
|
/// </summary>
|
||||||
|
public interface IApplicableToBeatmapProcessor : IApplicableMod
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Applies this <see cref="Mod"/> to a <see cref="BeatmapProcessor"/>.
|
||||||
|
/// </summary>
|
||||||
|
void ApplyToBeatmapProcessor(IBeatmapProcessor beatmapProcessor);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user