1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 05:12:54 +08:00

Update mod instantiaton utility method to no longer check for validity

This commit is contained in:
Salman Ahmed 2022-03-17 05:51:12 +03:00
parent 52d1c0cc15
commit 1a04260807

View File

@ -153,31 +153,17 @@ namespace osu.Game.Utils
}
/// <summary>
/// Verifies all proposed mods are valid for a given ruleset and returns instantiated <see cref="Mod"/>s for further processing.
/// Returns an instantiated list of all proposed mods on a given ruleset.
/// </summary>
/// <param name="ruleset">The ruleset to verify mods against.</param>
/// <param name="ruleset">The ruleset to instantiate mods.</param>
/// <param name="proposedMods">The proposed mods.</param>
/// <param name="valid">Mods instantiated from <paramref name="proposedMods"/> which were valid for the given <paramref name="ruleset"/>.</param>
/// <returns>Whether all <paramref name="proposedMods"/> were valid for the given <paramref name="ruleset"/>.</returns>
public static bool InstantiateValidModsForRuleset(Ruleset ruleset, IEnumerable<APIMod> proposedMods, out List<Mod> valid)
/// <param name="mods">Mods instantiated from <paramref name="proposedMods"/> on the given <paramref name="ruleset"/>.</param>
public static void InstantiateModsForRuleset(Ruleset ruleset, IEnumerable<APIMod> proposedMods, out List<Mod> mods)
{
valid = new List<Mod>();
bool proposedWereValid = true;
mods = new List<Mod>();
foreach (var apiMod in proposedMods)
{
try
{
// will throw if invalid
valid.Add(apiMod.ToMod(ruleset));
}
catch
{
proposedWereValid = false;
}
}
return proposedWereValid;
mods.Add(apiMod.ToMod(ruleset));
}
}
}