mirror of
https://github.com/ppy/osu.git
synced 2025-02-05 02:43:16 +08: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="mods">The mods to check.</param>
|
||||||
/// <param name="invalidMods">Invalid mods, if any were found. Can be null if all mods were valid.</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>
|
/// <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();
|
mods = mods.ToArray();
|
||||||
|
|
||||||
List<Mod>? foundInvalid = null;
|
CheckCompatibleSet(mods, out invalidMods);
|
||||||
|
|
||||||
void addInvalid(Mod mod)
|
|
||||||
{
|
|
||||||
foundInvalid ??= new List<Mod>();
|
|
||||||
foundInvalid.Add(mod);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var mod in mods)
|
foreach (var mod in mods)
|
||||||
{
|
{
|
||||||
bool valid = mod.Type != ModType.System
|
if (mod.Type == ModType.System || !mod.HasImplementation || mod is MultiMod)
|
||||||
&& mod.HasImplementation
|
|
||||||
&& !(mod is MultiMod);
|
|
||||||
|
|
||||||
if (!valid)
|
|
||||||
{
|
{
|
||||||
// if this mod was found as invalid, we can exclude it before potentially excluding more incompatible types.
|
invalidMods ??= new List<Mod>();
|
||||||
addInvalid(mod);
|
invalidMods.Add(mod);
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var type in mod.IncompatibleMods)
|
|
||||||
{
|
|
||||||
foreach (var invalid in mods.Where(m => type.IsInstanceOfType(m)))
|
|
||||||
addInvalid(invalid);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
invalidMods = foundInvalid?.ToArray();
|
return invalidMods == null;
|
||||||
return foundInvalid == null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user