mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 21:07:33 +08:00
Merge pull request #5553 from smoogipoo/simplify-generics
Remove generics from IApplicableToBeatmap
This commit is contained in:
commit
54b89114b1
@ -11,7 +11,6 @@ using System.Collections.Generic;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Game.Rulesets.Catch.Objects;
|
||||
using osu.Game.Rulesets.Catch.Replays;
|
||||
using osu.Game.Rulesets.Replays.Types;
|
||||
using osu.Game.Beatmaps.Legacy;
|
||||
@ -108,7 +107,7 @@ namespace osu.Game.Rulesets.Catch
|
||||
case ModType.Fun:
|
||||
return new Mod[]
|
||||
{
|
||||
new MultiMod(new ModWindUp<CatchHitObject>(), new ModWindDown<CatchHitObject>())
|
||||
new MultiMod(new ModWindUp(), new ModWindDown())
|
||||
};
|
||||
|
||||
default:
|
||||
|
@ -13,7 +13,6 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Mania.Objects;
|
||||
using osu.Game.Rulesets.Mania.Replays;
|
||||
using osu.Game.Rulesets.Replays.Types;
|
||||
using osu.Game.Beatmaps.Legacy;
|
||||
@ -154,7 +153,7 @@ namespace osu.Game.Rulesets.Mania
|
||||
case ModType.Fun:
|
||||
return new Mod[]
|
||||
{
|
||||
new MultiMod(new ModWindUp<ManiaHitObject>(), new ModWindDown<ManiaHitObject>())
|
||||
new MultiMod(new ModWindUp(), new ModWindDown())
|
||||
};
|
||||
|
||||
default:
|
||||
|
@ -10,7 +10,7 @@ using osu.Game.Rulesets.Mania.Beatmaps;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Mods
|
||||
{
|
||||
public class ManiaModMirror : Mod, IApplicableToBeatmap<ManiaHitObject>
|
||||
public class ManiaModMirror : Mod, IApplicableToBeatmap
|
||||
{
|
||||
public override string Name => "Mirror";
|
||||
public override string Acronym => "MR";
|
||||
@ -18,7 +18,7 @@ namespace osu.Game.Rulesets.Mania.Mods
|
||||
public override double ScoreMultiplier => 1;
|
||||
public override bool Ranked => true;
|
||||
|
||||
public void ApplyToBeatmap(Beatmap<ManiaHitObject> beatmap)
|
||||
public void ApplyToBeatmap(IBeatmap beatmap)
|
||||
{
|
||||
var availableColumns = ((ManiaBeatmap)beatmap).TotalColumns;
|
||||
|
||||
|
@ -13,7 +13,7 @@ using osu.Game.Rulesets.Mods;
|
||||
|
||||
namespace osu.Game.Rulesets.Mania.Mods
|
||||
{
|
||||
public class ManiaModRandom : Mod, IApplicableToBeatmap<ManiaHitObject>
|
||||
public class ManiaModRandom : Mod, IApplicableToBeatmap
|
||||
{
|
||||
public override string Name => "Random";
|
||||
public override string Acronym => "RD";
|
||||
@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Mania.Mods
|
||||
public override string Description => @"Shuffle around the keys!";
|
||||
public override double ScoreMultiplier => 1;
|
||||
|
||||
public void ApplyToBeatmap(Beatmap<ManiaHitObject> beatmap)
|
||||
public void ApplyToBeatmap(IBeatmap beatmap)
|
||||
{
|
||||
var availableColumns = ((ManiaBeatmap)beatmap).TotalColumns;
|
||||
var shuffledColumns = Enumerable.Range(0, availableColumns).OrderBy(item => RNG.Next()).ToList();
|
||||
|
@ -14,7 +14,6 @@ using osu.Game.Overlays.Settings;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Game.Rulesets.Osu.Edit;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Osu.Objects;
|
||||
using osu.Game.Rulesets.Osu.Replays;
|
||||
using osu.Game.Rulesets.Replays.Types;
|
||||
using osu.Game.Beatmaps.Legacy;
|
||||
@ -136,7 +135,7 @@ namespace osu.Game.Rulesets.Osu
|
||||
new OsuModWiggle(),
|
||||
new OsuModSpinIn(),
|
||||
new MultiMod(new OsuModGrow(), new OsuModDeflate()),
|
||||
new MultiMod(new ModWindUp<OsuHitObject>(), new ModWindDown<OsuHitObject>()),
|
||||
new MultiMod(new ModWindUp(), new ModWindDown()),
|
||||
};
|
||||
|
||||
case ModType.System:
|
||||
|
@ -12,7 +12,6 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Game.Rulesets.Replays.Types;
|
||||
using osu.Game.Rulesets.Taiko.Objects;
|
||||
using osu.Game.Rulesets.Taiko.Replays;
|
||||
using osu.Game.Beatmaps.Legacy;
|
||||
using osu.Game.Rulesets.Difficulty;
|
||||
@ -107,7 +106,7 @@ namespace osu.Game.Rulesets.Taiko
|
||||
case ModType.Fun:
|
||||
return new Mod[]
|
||||
{
|
||||
new MultiMod(new ModWindUp<TaikoHitObject>(), new ModWindDown<TaikoHitObject>())
|
||||
new MultiMod(new ModWindUp(), new ModWindDown())
|
||||
};
|
||||
|
||||
default:
|
||||
|
@ -2,21 +2,18 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
|
||||
namespace osu.Game.Rulesets.Mods
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface for a <see cref="Mod"/> that applies changes to a <see cref="Beatmap"/>
|
||||
/// after conversion and post-processing has completed.
|
||||
/// Interface for a <see cref="Mod"/> that applies changes to a <see cref="Beatmap"/> after conversion and post-processing has completed.
|
||||
/// </summary>
|
||||
public interface IApplicableToBeatmap<TObject> : IApplicableMod
|
||||
where TObject : HitObject
|
||||
public interface IApplicableToBeatmap : IApplicableMod
|
||||
{
|
||||
/// <summary>
|
||||
/// Applies this <see cref="IApplicableToBeatmap{TObject}"/> to a <see cref="Beatmap{TObject}"/>.
|
||||
/// Applies this <see cref="IApplicableToBeatmap"/> to an <see cref="IBeatmap"/>.
|
||||
/// </summary>
|
||||
/// <param name="beatmap">The <see cref="Beatmap{TObject}"/> to apply to.</param>
|
||||
void ApplyToBeatmap(Beatmap<TObject> beatmap);
|
||||
/// <param name="beatmap">The <see cref="IBeatmap"/> to apply to.</param>
|
||||
void ApplyToBeatmap(IBeatmap beatmap);
|
||||
}
|
||||
}
|
||||
|
@ -13,27 +13,21 @@ using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Mods
|
||||
{
|
||||
public abstract class ModTimeRamp : Mod
|
||||
public abstract class ModTimeRamp : Mod, IUpdatableByPlayfield, IApplicableToClock, IApplicableToBeatmap
|
||||
{
|
||||
public override Type[] IncompatibleMods => new[] { typeof(ModTimeAdjust) };
|
||||
|
||||
protected abstract double FinalRateAdjustment { get; }
|
||||
}
|
||||
|
||||
public abstract class ModTimeRamp<T> : ModTimeRamp, IUpdatableByPlayfield, IApplicableToClock, IApplicableToBeatmap<T>
|
||||
where T : HitObject
|
||||
{
|
||||
private double finalRateTime;
|
||||
|
||||
private double beginRampTime;
|
||||
|
||||
private IAdjustableClock clock;
|
||||
|
||||
/// <summary>
|
||||
/// The point in the beatmap at which the final ramping rate should be reached.
|
||||
/// </summary>
|
||||
private const double final_rate_progress = 0.75f;
|
||||
|
||||
public override Type[] IncompatibleMods => new[] { typeof(ModTimeAdjust) };
|
||||
|
||||
protected abstract double FinalRateAdjustment { get; }
|
||||
|
||||
private double finalRateTime;
|
||||
private double beginRampTime;
|
||||
private IAdjustableClock clock;
|
||||
|
||||
public virtual void ApplyToClock(IAdjustableClock clock)
|
||||
{
|
||||
this.clock = clock;
|
||||
@ -44,7 +38,7 @@ namespace osu.Game.Rulesets.Mods
|
||||
applyAdjustment(1);
|
||||
}
|
||||
|
||||
public virtual void ApplyToBeatmap(Beatmap<T> beatmap)
|
||||
public virtual void ApplyToBeatmap(IBeatmap beatmap)
|
||||
{
|
||||
HitObject lastObject = beatmap.HitObjects.LastOrDefault();
|
||||
|
||||
|
@ -4,12 +4,10 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
|
||||
namespace osu.Game.Rulesets.Mods
|
||||
{
|
||||
public class ModWindDown<T> : ModTimeRamp<T>
|
||||
where T : HitObject
|
||||
public class ModWindDown : ModTimeRamp
|
||||
{
|
||||
public override string Name => "Wind Down";
|
||||
public override string Acronym => "WD";
|
||||
@ -19,6 +17,6 @@ namespace osu.Game.Rulesets.Mods
|
||||
|
||||
protected override double FinalRateAdjustment => -0.25;
|
||||
|
||||
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(ModWindUp<T>)).ToArray();
|
||||
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(ModWindUp)).ToArray();
|
||||
}
|
||||
}
|
||||
|
@ -4,12 +4,10 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
|
||||
namespace osu.Game.Rulesets.Mods
|
||||
{
|
||||
public class ModWindUp<T> : ModTimeRamp<T>
|
||||
where T : HitObject
|
||||
public class ModWindUp : ModTimeRamp
|
||||
{
|
||||
public override string Name => "Wind Up";
|
||||
public override string Acronym => "WU";
|
||||
@ -19,6 +17,6 @@ namespace osu.Game.Rulesets.Mods
|
||||
|
||||
protected override double FinalRateAdjustment => 0.5;
|
||||
|
||||
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(ModWindDown<T>)).ToArray();
|
||||
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(ModWindDown)).ToArray();
|
||||
}
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ namespace osu.Game.Rulesets.UI
|
||||
if (mods == null)
|
||||
return;
|
||||
|
||||
foreach (var mod in mods.OfType<IApplicableToBeatmap<TObject>>())
|
||||
foreach (var mod in mods.OfType<IApplicableToBeatmap>())
|
||||
mod.ApplyToBeatmap(Beatmap);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user