1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-30 23:23:18 +08:00

Remove generics from IApplicableToBeatmap

This commit is contained in:
smoogipoo 2019-08-01 12:35:17 +09:00
parent 3a2e0fbba5
commit 8a64ab0384
11 changed files with 28 additions and 45 deletions

View File

@ -11,7 +11,6 @@ using System.Collections.Generic;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Bindings; using osu.Framework.Input.Bindings;
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Catch.Replays; using osu.Game.Rulesets.Catch.Replays;
using osu.Game.Rulesets.Replays.Types; using osu.Game.Rulesets.Replays.Types;
using osu.Game.Beatmaps.Legacy; using osu.Game.Beatmaps.Legacy;
@ -108,7 +107,7 @@ namespace osu.Game.Rulesets.Catch
case ModType.Fun: case ModType.Fun:
return new Mod[] return new Mod[]
{ {
new MultiMod(new ModWindUp<CatchHitObject>(), new ModWindDown<CatchHitObject>()) new MultiMod(new ModWindUp(), new ModWindDown())
}; };
default: default:

View File

@ -13,7 +13,6 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Bindings; using osu.Framework.Input.Bindings;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Mania.Replays; using osu.Game.Rulesets.Mania.Replays;
using osu.Game.Rulesets.Replays.Types; using osu.Game.Rulesets.Replays.Types;
using osu.Game.Beatmaps.Legacy; using osu.Game.Beatmaps.Legacy;
@ -154,7 +153,7 @@ namespace osu.Game.Rulesets.Mania
case ModType.Fun: case ModType.Fun:
return new Mod[] return new Mod[]
{ {
new MultiMod(new ModWindUp<ManiaHitObject>(), new ModWindDown<ManiaHitObject>()) new MultiMod(new ModWindUp(), new ModWindDown())
}; };
default: default:

View File

@ -10,7 +10,7 @@ using osu.Game.Rulesets.Mania.Beatmaps;
namespace osu.Game.Rulesets.Mania.Mods 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 Name => "Mirror";
public override string Acronym => "MR"; public override string Acronym => "MR";
@ -18,7 +18,7 @@ namespace osu.Game.Rulesets.Mania.Mods
public override double ScoreMultiplier => 1; public override double ScoreMultiplier => 1;
public override bool Ranked => true; public override bool Ranked => true;
public void ApplyToBeatmap(Beatmap<ManiaHitObject> beatmap) public void ApplyToBeatmap(IBeatmap beatmap)
{ {
var availableColumns = ((ManiaBeatmap)beatmap).TotalColumns; var availableColumns = ((ManiaBeatmap)beatmap).TotalColumns;

View File

@ -13,7 +13,7 @@ using osu.Game.Rulesets.Mods;
namespace osu.Game.Rulesets.Mania.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 Name => "Random";
public override string Acronym => "RD"; 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 string Description => @"Shuffle around the keys!";
public override double ScoreMultiplier => 1; public override double ScoreMultiplier => 1;
public void ApplyToBeatmap(Beatmap<ManiaHitObject> beatmap) public void ApplyToBeatmap(IBeatmap beatmap)
{ {
var availableColumns = ((ManiaBeatmap)beatmap).TotalColumns; var availableColumns = ((ManiaBeatmap)beatmap).TotalColumns;
var shuffledColumns = Enumerable.Range(0, availableColumns).OrderBy(item => RNG.Next()).ToList(); var shuffledColumns = Enumerable.Range(0, availableColumns).OrderBy(item => RNG.Next()).ToList();

View File

@ -14,7 +14,6 @@ using osu.Game.Overlays.Settings;
using osu.Framework.Input.Bindings; using osu.Framework.Input.Bindings;
using osu.Game.Rulesets.Osu.Edit; using osu.Game.Rulesets.Osu.Edit;
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Rulesets.Osu.Replays; using osu.Game.Rulesets.Osu.Replays;
using osu.Game.Rulesets.Replays.Types; using osu.Game.Rulesets.Replays.Types;
using osu.Game.Beatmaps.Legacy; using osu.Game.Beatmaps.Legacy;
@ -136,7 +135,7 @@ namespace osu.Game.Rulesets.Osu
new OsuModWiggle(), new OsuModWiggle(),
new OsuModSpinIn(), new OsuModSpinIn(),
new MultiMod(new OsuModGrow(), new OsuModDeflate()), new MultiMod(new OsuModGrow(), new OsuModDeflate()),
new MultiMod(new ModWindUp<OsuHitObject>(), new ModWindDown<OsuHitObject>()), new MultiMod(new ModWindUp(), new ModWindDown()),
}; };
case ModType.System: case ModType.System:

View File

@ -12,7 +12,6 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Bindings; using osu.Framework.Input.Bindings;
using osu.Game.Rulesets.Replays.Types; using osu.Game.Rulesets.Replays.Types;
using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Rulesets.Taiko.Replays; using osu.Game.Rulesets.Taiko.Replays;
using osu.Game.Beatmaps.Legacy; using osu.Game.Beatmaps.Legacy;
using osu.Game.Rulesets.Difficulty; using osu.Game.Rulesets.Difficulty;
@ -107,7 +106,7 @@ namespace osu.Game.Rulesets.Taiko
case ModType.Fun: case ModType.Fun:
return new Mod[] return new Mod[]
{ {
new MultiMod(new ModWindUp<TaikoHitObject>(), new ModWindDown<TaikoHitObject>()) new MultiMod(new ModWindUp(), new ModWindDown())
}; };
default: default:

View File

@ -2,21 +2,18 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Rulesets.Objects;
namespace osu.Game.Rulesets.Mods namespace osu.Game.Rulesets.Mods
{ {
/// <summary> /// <summary>
/// Interface for a <see cref="Mod"/> that applies changes to a <see cref="Beatmap"/> /// Interface for a <see cref="Mod"/> that applies changes to a <see cref="Beatmap"/> after conversion and post-processing has completed.
/// after conversion and post-processing has completed.
/// </summary> /// </summary>
public interface IApplicableToBeatmap<TObject> : IApplicableMod public interface IApplicableToBeatmap : IApplicableMod
where TObject : HitObject
{ {
/// <summary> /// <summary>
/// Applies this <see cref="IApplicableToBeatmap{TObject}"/> to a <see cref="Beatmap{TObject}"/>. /// Applies this <see cref="IApplicableToBeatmap"/> to an <see cref="IBeatmap"/>.
/// </summary> /// </summary>
/// <param name="beatmap">The <see cref="Beatmap{TObject}"/> to apply to.</param> /// <param name="beatmap">The <see cref="IBeatmap"/> to apply to.</param>
void ApplyToBeatmap(Beatmap<TObject> beatmap); void ApplyToBeatmap(IBeatmap beatmap);
} }
} }

View File

@ -13,27 +13,21 @@ using osuTK;
namespace osu.Game.Rulesets.Mods 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> /// <summary>
/// The point in the beatmap at which the final ramping rate should be reached. /// The point in the beatmap at which the final ramping rate should be reached.
/// </summary> /// </summary>
private const double final_rate_progress = 0.75f; 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) public virtual void ApplyToClock(IAdjustableClock clock)
{ {
this.clock = clock; this.clock = clock;
@ -44,7 +38,7 @@ namespace osu.Game.Rulesets.Mods
applyAdjustment(1); applyAdjustment(1);
} }
public virtual void ApplyToBeatmap(Beatmap<T> beatmap) public virtual void ApplyToBeatmap(IBeatmap beatmap)
{ {
HitObject lastObject = beatmap.HitObjects.LastOrDefault(); HitObject lastObject = beatmap.HitObjects.LastOrDefault();

View File

@ -4,12 +4,10 @@
using System; using System;
using System.Linq; using System.Linq;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Game.Rulesets.Objects;
namespace osu.Game.Rulesets.Mods namespace osu.Game.Rulesets.Mods
{ {
public class ModWindDown<T> : ModTimeRamp<T> public class ModWindDown : ModTimeRamp
where T : HitObject
{ {
public override string Name => "Wind Down"; public override string Name => "Wind Down";
public override string Acronym => "WD"; public override string Acronym => "WD";
@ -19,6 +17,6 @@ namespace osu.Game.Rulesets.Mods
protected override double FinalRateAdjustment => -0.25; 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();
} }
} }

View File

@ -4,12 +4,10 @@
using System; using System;
using System.Linq; using System.Linq;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Game.Rulesets.Objects;
namespace osu.Game.Rulesets.Mods namespace osu.Game.Rulesets.Mods
{ {
public class ModWindUp<T> : ModTimeRamp<T> public class ModWindUp : ModTimeRamp
where T : HitObject
{ {
public override string Name => "Wind Up"; public override string Name => "Wind Up";
public override string Acronym => "WU"; public override string Acronym => "WU";
@ -19,6 +17,6 @@ namespace osu.Game.Rulesets.Mods
protected override double FinalRateAdjustment => 0.5; 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();
} }
} }

View File

@ -278,7 +278,7 @@ namespace osu.Game.Rulesets.UI
if (mods == null) if (mods == null)
return; return;
foreach (var mod in mods.OfType<IApplicableToBeatmap<TObject>>()) foreach (var mod in mods.OfType<IApplicableToBeatmap>())
mod.ApplyToBeatmap(Beatmap); mod.ApplyToBeatmap(Beatmap);
} }