mirror of
https://github.com/ppy/osu
synced 2025-01-24 14:53:18 +00:00
Reuse existing method
This commit is contained in:
parent
5881b8be96
commit
052cf1abae
@ -88,40 +88,22 @@ namespace osu.Game.Utils
|
||||
/// <param name="mods">The mods to check.</param>
|
||||
/// <param name="invalidMods">Invalid mods, if any were found. Can 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 CheckValidForGameplay(IEnumerable<Mod> mods, out Mod[]? invalidMods)
|
||||
public static bool CheckValidForGameplay(IEnumerable<Mod> mods, out List<Mod>? invalidMods)
|
||||
{
|
||||
mods = mods.ToArray();
|
||||
|
||||
List<Mod>? foundInvalid = null;
|
||||
|
||||
void addInvalid(Mod mod)
|
||||
{
|
||||
foundInvalid ??= new List<Mod>();
|
||||
foundInvalid.Add(mod);
|
||||
}
|
||||
CheckCompatibleSet(mods, out invalidMods);
|
||||
|
||||
foreach (var mod in mods)
|
||||
{
|
||||
bool valid = mod.Type != ModType.System
|
||||
&& mod.HasImplementation
|
||||
&& !(mod is MultiMod);
|
||||
|
||||
if (!valid)
|
||||
if (mod.Type == ModType.System || !mod.HasImplementation || mod is MultiMod)
|
||||
{
|
||||
// if this mod was found as invalid, we can exclude it before potentially excluding more incompatible types.
|
||||
addInvalid(mod);
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (var type in mod.IncompatibleMods)
|
||||
{
|
||||
foreach (var invalid in mods.Where(m => type.IsInstanceOfType(m)))
|
||||
addInvalid(invalid);
|
||||
invalidMods ??= new List<Mod>();
|
||||
invalidMods.Add(mod);
|
||||
}
|
||||
}
|
||||
|
||||
invalidMods = foundInvalid?.ToArray();
|
||||
return foundInvalid == null;
|
||||
return invalidMods == null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
Loading…
Reference in New Issue
Block a user