1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-29 02:03:22 +08:00

Avoid reconstructing ruleset for each frame bundle

This commit is contained in:
Dean Herbert 2020-10-28 16:33:52 +09:00
parent 5fcd39a43d
commit 730cc645fb

View File

@ -38,6 +38,8 @@ namespace osu.Game.Screens.Play
[Resolved] [Resolved]
private Bindable<RulesetInfo> ruleset { get; set; } private Bindable<RulesetInfo> ruleset { get; set; }
private Ruleset rulesetInstance;
[Resolved] [Resolved]
private Bindable<IReadOnlyList<Mod>> mods { get; set; } private Bindable<IReadOnlyList<Mod>> mods { get; set; }
@ -141,12 +143,10 @@ namespace osu.Game.Screens.Play
if (replay == null) if (replay == null)
return; return;
var rulesetInstance = ruleset.Value.CreateInstance();
foreach (var frame in data.Frames) foreach (var frame in data.Frames)
{ {
IConvertibleReplayFrame convertibleFrame = rulesetInstance.CreateConvertibleReplayFrame(); IConvertibleReplayFrame convertibleFrame = rulesetInstance.CreateConvertibleReplayFrame();
convertibleFrame.FromLegacy(frame, beatmap.Value.Beatmap, null); convertibleFrame.FromLegacy(frame, beatmap.Value.Beatmap);
var convertedFrame = (ReplayFrame)convertibleFrame; var convertedFrame = (ReplayFrame)convertibleFrame;
convertedFrame.Time = frame.Time; convertedFrame.Time = frame.Time;
@ -206,6 +206,8 @@ namespace osu.Game.Screens.Play
}; };
ruleset.Value = resolvedRuleset.RulesetInfo; ruleset.Value = resolvedRuleset.RulesetInfo;
rulesetInstance = resolvedRuleset;
beatmap.Value = beatmaps.GetWorkingBeatmap(resolvedBeatmap); beatmap.Value = beatmaps.GetWorkingBeatmap(resolvedBeatmap);
this.Push(new SpectatorPlayerLoader(new Score this.Push(new SpectatorPlayerLoader(new Score