Allow autoplay score generation to access mod list

This commit is contained in:
Bartłomiej Dach
2021-01-31 17:19:07 +01:00
parent dd4207cb4e
commit 68c20a2a37
12 changed files with 34 additions and 12 deletions

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using osu.Framework.Graphics.Sprites;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
@ -15,7 +16,11 @@ namespace osu.Game.Rulesets.Mods
public abstract class ModAutoplay<T> : ModAutoplay, IApplicableToDrawableRuleset<T>
where T : HitObject
{
public virtual void ApplyToDrawableRuleset(DrawableRuleset<T> drawableRuleset) => drawableRuleset.SetReplayScore(CreateReplayScore(drawableRuleset.Beatmap));
public virtual void ApplyToDrawableRuleset(DrawableRuleset<T> drawableRuleset)
{
var mods = (IReadOnlyList<Mod>)drawableRuleset.Dependencies.Get(typeof(IReadOnlyList<Mod>));
drawableRuleset.SetReplayScore(CreateReplayScore(drawableRuleset.Beatmap, mods));
}
}
public abstract class ModAutoplay : Mod, IApplicableFailOverride
@ -35,6 +40,11 @@ namespace osu.Game.Rulesets.Mods
public override bool HasImplementation => GetType().GenericTypeArguments.Length == 0;
[Obsolete("Use the mod-supporting override")] // can be removed 20210731
public virtual Score CreateReplayScore(IBeatmap beatmap) => new Score { Replay = new Replay() };
#pragma warning disable 618
public virtual Score CreateReplayScore(IBeatmap beatmap, IReadOnlyList<Mod> mods) => CreateReplayScore(beatmap);
#pragma warning restore 618
}
}