mirror of
https://github.com/ppy/osu.git
synced 2025-02-05 04:13:03 +08:00
Shortened GetAllMods() using LINQ
This commit is contained in:
parent
920710e7d0
commit
5ed717ef86
@ -4,14 +4,14 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Overlays.Settings;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
|
using osu.Game.Rulesets.Scoring;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Game.Rulesets.Scoring;
|
|
||||||
using osu.Game.Overlays.Settings;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets
|
namespace osu.Game.Rulesets
|
||||||
{
|
{
|
||||||
@ -23,10 +23,9 @@ namespace osu.Game.Rulesets
|
|||||||
|
|
||||||
public IEnumerable<Mod> GetAllMods()
|
public IEnumerable<Mod> GetAllMods()
|
||||||
{
|
{
|
||||||
List<Mod> modList = new List<Mod>();
|
return Enum.GetValues(typeof(ModType)).Cast<ModType>().SelectMany(type =>
|
||||||
|
{
|
||||||
foreach (ModType type in Enum.GetValues(typeof(ModType)))
|
return GetModsFor(type).Where(mod => mod != null).SelectMany(mod =>
|
||||||
modList.AddRange(GetModsFor(type).Where(mod => mod != null).SelectMany(mod =>
|
|
||||||
{
|
{
|
||||||
var multiMod = mod as MultiMod;
|
var multiMod = mod as MultiMod;
|
||||||
|
|
||||||
@ -34,9 +33,8 @@ namespace osu.Game.Rulesets
|
|||||||
return multiMod.Mods;
|
return multiMod.Mods;
|
||||||
|
|
||||||
return new[] { mod };
|
return new[] { mod };
|
||||||
}));
|
});
|
||||||
|
});
|
||||||
return modList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract IEnumerable<Mod> GetModsFor(ModType type);
|
public abstract IEnumerable<Mod> GetModsFor(ModType type);
|
||||||
|
Loading…
Reference in New Issue
Block a user