1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-16 16:57:48 +08:00
osu-lazer/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsPlayer.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

72 lines
2.4 KiB
C#
Raw Normal View History

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2022-06-17 15:37:17 +08:00
#nullable disable
2018-12-27 20:12:32 +08:00
using System;
using System.Diagnostics;
2019-02-28 13:58:44 +08:00
using System.Linq;
2018-12-14 20:09:17 +08:00
using osu.Framework.Allocation;
2019-02-21 18:04:31 +08:00
using osu.Framework.Bindables;
2019-01-23 19:52:00 +08:00
using osu.Framework.Screens;
using osu.Game.Extensions;
2020-12-25 12:38:11 +08:00
using osu.Game.Online.Rooms;
using osu.Game.Rulesets;
2018-12-14 20:09:17 +08:00
using osu.Game.Scoring;
using osu.Game.Screens.Play;
using osu.Game.Screens.Ranking;
using osu.Game.Users;
namespace osu.Game.Screens.OnlinePlay.Playlists
{
public partial class PlaylistsPlayer : RoomSubmittingPlayer
{
2019-01-23 19:52:00 +08:00
public Action Exited;
protected override UserActivity InitialActivity => new UserActivity.InPlaylistGame(Beatmap.Value.BeatmapInfo, Ruleset.Value);
public PlaylistsPlayer(Room room, PlaylistItem playlistItem, PlayerConfiguration configuration = null)
: base(room, playlistItem, configuration)
2018-12-14 20:09:17 +08:00
{
}
[BackgroundDependencyLoader]
private void load(IBindable<RulesetInfo> ruleset)
2018-12-14 20:09:17 +08:00
{
2020-12-25 12:11:21 +08:00
// Sanity checks to ensure that PlaylistsPlayer matches the settings for the current PlaylistItem
if (!Beatmap.Value.BeatmapInfo.MatchesOnlineID(PlaylistItem.Beatmap))
throw new InvalidOperationException("Current Beatmap does not match PlaylistItem's Beatmap");
if (ruleset.Value.OnlineID != PlaylistItem.RulesetID)
throw new InvalidOperationException("Current Ruleset does not match PlaylistItem's Ruleset");
var requiredLocalMods = PlaylistItem.RequiredMods.Select(m => m.ToMod(GameplayState.Ruleset));
if (!requiredLocalMods.All(m => Mods.Value.Any(m.Equals)))
throw new InvalidOperationException("Current Mods do not match PlaylistItem's RequiredMods");
}
public override bool OnExiting(ScreenExitEvent e)
2019-01-23 19:52:00 +08:00
{
if (base.OnExiting(e))
2019-01-23 19:52:00 +08:00
return true;
Exited?.Invoke();
return false;
}
protected override ResultsScreen CreateResults(ScoreInfo score)
{
Debug.Assert(Room.RoomID.Value != null);
return new PlaylistsResultsScreen(score, Room.RoomID.Value.Value, PlaylistItem, true);
}
2019-01-23 19:52:00 +08:00
protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
Exited = null;
}
2018-12-14 20:09:17 +08:00
}
}