mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Improve validity methods to include system, non-implemented, and multi mods
This commit is contained in:
@ -115,12 +115,15 @@ namespace osu.Game.Utils
|
|||||||
{
|
{
|
||||||
mods = mods.ToArray();
|
mods = mods.ToArray();
|
||||||
|
|
||||||
// exclude multi mods from compatibility checks.
|
// checking compatibility of multi mods would try to flatten them and return incompatible mods.
|
||||||
// the loop below automatically marks all multi mods as not valid for gameplay anyway.
|
// in gameplay context, we never want MultiMod selected in the first place, therefore check against it first.
|
||||||
if (!CheckCompatibleSet(mods.Where(m => !(m is MultiMod)), out invalidMods))
|
if (!checkValid(mods, m => !(m is MultiMod), out invalidMods))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return checkValid(mods, m => m.Type != ModType.System && m.HasImplementation && !(m is MultiMod), out invalidMods);
|
if (!CheckCompatibleSet(mods, out invalidMods))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return checkValid(mods, m => m.Type != ModType.System && m.HasImplementation, out invalidMods);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -133,10 +136,15 @@ namespace osu.Game.Utils
|
|||||||
{
|
{
|
||||||
mods = mods.ToArray();
|
mods = mods.ToArray();
|
||||||
|
|
||||||
|
// checking compatibility of multi mods would try to flatten them and return incompatible mods.
|
||||||
|
// in gameplay context, we never want MultiMod selected in the first place, therefore check against it first.
|
||||||
|
if (!checkValid(mods, m => !(m is MultiMod), out invalidMods))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (!CheckCompatibleSet(mods, out invalidMods))
|
if (!CheckCompatibleSet(mods, out invalidMods))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return checkValid(mods, m => m.IsPlayable(ModUsage.MultiplayerGlobal), out invalidMods);
|
return checkValid(mods, m => m.Type != ModType.System && m.HasImplementation && m.IsPlayable(ModUsage.MultiplayerGlobal), out invalidMods);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -146,7 +154,7 @@ namespace osu.Game.Utils
|
|||||||
/// <param name="invalidMods">Invalid mods, if any were found. Will be null if all mods were valid.</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>
|
/// <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)
|
public static bool CheckValidFreeModsForMultiplayer(IEnumerable<Mod> mods, [NotNullWhen(false)] out List<Mod>? invalidMods)
|
||||||
=> checkValid(mods, m => m.IsPlayable(ModUsage.MultiplayerLocal), out invalidMods);
|
=> checkValid(mods, m => m.Type != ModType.System && m.HasImplementation && m.IsPlayable(ModUsage.MultiplayerLocal) && !(m is MultiMod), out invalidMods);
|
||||||
|
|
||||||
private static bool checkValid(IEnumerable<Mod> mods, Predicate<Mod> valid, [NotNullWhen(false)] out List<Mod>? invalidMods)
|
private static bool checkValid(IEnumerable<Mod> mods, Predicate<Mod> valid, [NotNullWhen(false)] out List<Mod>? invalidMods)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user