mirror of
https://github.com/ppy/osu.git
synced 2024-11-14 14:27:25 +08:00
Instancing a Ruleset only when it's necessary to
This commit is contained in:
parent
dd3f4bcdab
commit
6e3bea938e
@ -6,6 +6,7 @@ using System.Linq;
|
|||||||
using Humanizer;
|
using Humanizer;
|
||||||
using Humanizer.Localisation;
|
using Humanizer.Localisation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Utils;
|
using osu.Game.Utils;
|
||||||
|
|
||||||
namespace osu.Game.Online.Rooms
|
namespace osu.Game.Online.Rooms
|
||||||
@ -45,8 +46,13 @@ namespace osu.Game.Online.Rooms
|
|||||||
public static string GetTotalDuration(this BindableList<PlaylistItem> playlist) =>
|
public static string GetTotalDuration(this BindableList<PlaylistItem> playlist) =>
|
||||||
playlist.Select(p =>
|
playlist.Select(p =>
|
||||||
{
|
{
|
||||||
var ruleset = p.Beatmap.Ruleset.CreateInstance();
|
IEnumerable<Mod> modList = [];
|
||||||
double rate = ModUtils.CalculateRateWithMods(p.RequiredMods.Select(mod => mod.ToMod(ruleset)));
|
if (p.RequiredMods.Length > 0)
|
||||||
|
{
|
||||||
|
var ruleset = p.Beatmap.Ruleset.CreateInstance();
|
||||||
|
modList = p.RequiredMods.Select(mod => mod.ToMod(ruleset));
|
||||||
|
}
|
||||||
|
double rate = ModUtils.CalculateRateWithMods(modList);
|
||||||
return p.Beatmap.Length / rate;
|
return p.Beatmap.Length / rate;
|
||||||
}).Sum().Milliseconds().Humanize(minUnit: TimeUnit.Second, maxUnit: TimeUnit.Hour, precision: 2);
|
}).Sum().Milliseconds().Humanize(minUnit: TimeUnit.Second, maxUnit: TimeUnit.Hour, precision: 2);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user