Update usages to use `IsPlayable` instead

This commit is contained in:
Salman Ahmed 2022-03-18 02:11:18 +03:00
parent 51e5dd7d0e
commit f2248ecc08
12 changed files with 19 additions and 16 deletions

View File

@ -31,7 +31,7 @@ public class ModAdaptiveSpeed : Mod, IApplicableToRate, IApplicableToDrawableHit
public override double ScoreMultiplier => 1;
public override bool PlayableInMultiplayer => false;
public override bool IsPlayable(ModUsage usage) => usage == ModUsage.Solo;
public override Type[] IncompatibleMods => new[] { typeof(ModRateAdjust), typeof(ModTimeRamp) };

View File

@ -24,7 +24,7 @@ public abstract class ModAutoplay : Mod, IApplicableFailOverride, ICreateReplay
public bool RestartOnFail => false;
public override bool UserPlayable => false;
public override bool IsPlayable(ModUsage usage) => false;
public override Type[] IncompatibleMods => new[] { typeof(ModRelax), typeof(ModFailCondition), typeof(ModNoFail) };

View File

@ -11,7 +11,7 @@ namespace osu.Game.Rulesets.Mods
{
public abstract class ModRateAdjust : Mod, IApplicableToRate
{
public override bool ValidFreeModInMultiplayer => false;
public override bool IsPlayable(ModUsage usage) => usage != ModUsage.MultiplayerFree;
public abstract BindableNumber<double> SpeedChange { get; }

View File

@ -30,7 +30,7 @@ public abstract class ModTimeRamp : Mod, IUpdatableByPlayfield, IApplicableToBea
[SettingSource("Adjust pitch", "Should pitch be adjusted with speed")]
public abstract BindableBool AdjustPitch { get; }
public override bool ValidFreeModInMultiplayer => false;
public override bool IsPlayable(ModUsage usage) => usage != ModUsage.MultiplayerFree;
public override Type[] IncompatibleMods => new[] { typeof(ModRateAdjust), typeof(ModAdaptiveSpeed) };

View File

@ -15,7 +15,7 @@ public class UnknownMod : Mod
public override string Description => "This mod could not be resolved by the game.";
public override double ScoreMultiplier => 0;
public override bool UserPlayable => false;
public override bool IsPlayable(ModUsage usage) => false;
public override ModType Type => ModType.System;

View File

@ -25,7 +25,7 @@ public class FreeModSelectOverlay : ModSelectOverlay
public new Func<Mod, bool> IsValidMod
{
get => base.IsValidMod;
set => base.IsValidMod = m => m.HasImplementation && m.UserPlayable && value(m);
set => base.IsValidMod = m => m.HasImplementation && m.IsPlayable(ModUsage.Solo) && value(m);
}
public FreeModSelectOverlay()

View File

@ -117,8 +117,8 @@ protected override void SelectItem(PlaylistItem item)
protected override BeatmapDetailArea CreateBeatmapDetailArea() => new PlayBeatmapDetailArea();
protected override bool IsValidMod(Mod mod) => base.IsValidMod(mod) && mod.PlayableInMultiplayer;
protected override bool IsValidMod(Mod mod) => base.IsValidMod(mod) && mod.IsPlayable(ModUsage.MultiplayerRequired);
protected override bool IsValidFreeMod(Mod mod) => base.IsValidFreeMod(mod) && mod.ValidFreeModInMultiplayer;
protected override bool IsValidFreeMod(Mod mod) => base.IsValidFreeMod(mod) && mod.IsPlayable(ModUsage.MultiplayerFree);
}
}

View File

@ -170,7 +170,7 @@ public override bool OnExiting(IScreen next)
/// </summary>
/// <param name="mod">The <see cref="Mod"/> to check.</param>
/// <returns>Whether <paramref name="mod"/> is a valid mod for online play.</returns>
protected virtual bool IsValidMod(Mod mod) => mod.HasImplementation && ModUtils.FlattenMod(mod).All(m => m.UserPlayable);
protected virtual bool IsValidMod(Mod mod) => mod.HasImplementation && ModUtils.FlattenMod(mod).All(m => m.IsPlayable(ModUsage.Solo));
/// <summary>
/// Checks whether a given <see cref="Mod"/> is valid for per-player free-mod selection.

View File

@ -20,6 +20,7 @@
using osu.Game.Graphics.Sprites;
using osu.Game.Localisation;
using osu.Game.Overlays.Settings;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
using osu.Game.Screens.Ranking.Statistics;
@ -187,7 +188,7 @@ private void scoreChanged(ValueChangedEvent<ScoreInfo> score)
if (score.NewValue == null)
return;
if (score.NewValue.Mods.Any(m => !m.UserPlayable))
if (score.NewValue.Mods.Any(m => !m.IsPlayable(ModUsage.Solo)))
return;
var hitEvents = score.NewValue.HitEvents;

View File

@ -11,6 +11,7 @@
using osu.Framework.Screens;
using osu.Game.Online.API;
using osu.Game.Online.Rooms;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
@ -47,7 +48,7 @@ private bool handleTokenRetrieval()
// Token request construction should happen post-load to allow derived classes to potentially prepare DI backings that are used to create the request.
var tcs = new TaskCompletionSource<bool>();
if (Mods.Value.Any(m => !m.UserPlayable))
if (Mods.Value.Any(m => !m.IsPlayable(ModUsage.Solo)))
{
handleTokenFailure(new InvalidOperationException("Non-user playable mod selected."));
return false;

View File

@ -18,6 +18,7 @@
using osu.Game.Graphics.UserInterface;
using osu.Game.Input.Bindings;
using osu.Game.Online.API;
using osu.Game.Rulesets.Mods;
using osu.Game.Scoring;
using osu.Game.Screens.Play;
using osu.Game.Screens.Ranking.Statistics;
@ -145,7 +146,7 @@ private void load()
if (Score != null)
{
// only show flair / animation when arriving after watching a play that isn't autoplay.
bool shouldFlair = player != null && Score.Mods.All(m => m.UserPlayable);
bool shouldFlair = player != null && Score.Mods.All(m => m.IsPlayable(ModUsage.Solo));
ScorePanelList.AddScore(Score, shouldFlair);
}

View File

@ -115,13 +115,13 @@ public static bool CheckValidForGameplay(IEnumerable<Mod> mods, [NotNullWhen(fal
=> checkValid(mods, m => m.Type != ModType.System && m.HasImplementation && !(m is MultiMod), out invalidMods);
/// <summary>
/// Check the provided combination of mods are valid for a multiplayer match session.
/// Check the provided combination of mods are valid as "required mods" in a multiplayer match session.
/// </summary>
/// <param name="mods">The mods to check.</param>
/// <param name="invalidMods">Invalid mods, if any were found. Will be null if all mods were valid.</param>
/// <returns>Whether the input mods were all valid. If false, <paramref name="invalidMods"/> will contain all invalid entries.</returns>
public static bool CheckValidForMultiplayer(IEnumerable<Mod> mods, [NotNullWhen(false)] out List<Mod>? invalidMods)
=> checkValid(mods, m => m.PlayableInMultiplayer, out invalidMods);
public static bool CheckValidRequiredModsForMultiplayer(IEnumerable<Mod> mods, [NotNullWhen(false)] out List<Mod>? invalidMods)
=> checkValid(mods, m => m.IsPlayable(ModUsage.MultiplayerRequired), out invalidMods);
/// <summary>
/// Check the provided combination of mods are valid as "free mods" in a multiplayer match session.
@ -130,7 +130,7 @@ public static bool CheckValidForMultiplayer(IEnumerable<Mod> mods, [NotNullWhen(
/// <param name="invalidMods">Invalid mods, if any were found. Will be null if all mods were valid.</param>
/// <returns>Whether the input mods were all valid. If false, <paramref name="invalidMods"/> will contain all invalid entries.</returns>
public static bool CheckValidFreeModsForMultiplayer(IEnumerable<Mod> mods, [NotNullWhen(false)] out List<Mod>? invalidMods)
=> checkValid(mods, m => m.ValidFreeModInMultiplayer, out invalidMods);
=> checkValid(mods, m => m.IsPlayable(ModUsage.MultiplayerFree), out invalidMods);
private static bool checkValid(IEnumerable<Mod> mods, Predicate<Mod> valid, [NotNullWhen(false)] out List<Mod>? invalidMods)
{