mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 18:23:04 +08:00
Give MultiplayerRoom a playlist, remove RequestAllPlaylistItems()
This commit is contained in:
parent
f0593115b2
commit
9076519710
@ -77,11 +77,6 @@ namespace osu.Game.Online.Multiplayer
|
||||
/// <exception cref="InvalidStateException">If an attempt to start the game occurs when the game's (or users') state disallows it.</exception>
|
||||
Task StartMatch();
|
||||
|
||||
/// <summary>
|
||||
/// Requests for all playlist items of the room to be sent to the client.
|
||||
/// </summary>
|
||||
Task RequestAllPlaylistItems();
|
||||
|
||||
/// <summary>
|
||||
/// Adds an item to the playlist.
|
||||
/// </summary>
|
||||
|
@ -139,6 +139,9 @@ namespace osu.Game.Online.Multiplayer
|
||||
var joinedRoom = await JoinRoom(room.RoomID.Value.Value, password ?? room.Password.Value).ConfigureAwait(false);
|
||||
Debug.Assert(joinedRoom != null);
|
||||
|
||||
// Populate playlist items.
|
||||
var playlistItems = await Task.WhenAll(joinedRoom.Playlist.Select(createPlaylistItem)).ConfigureAwait(false);
|
||||
|
||||
// Populate users.
|
||||
Debug.Assert(joinedRoom.Users != null);
|
||||
await Task.WhenAll(joinedRoom.Users.Select(PopulateUser)).ConfigureAwait(false);
|
||||
@ -149,6 +152,9 @@ namespace osu.Game.Online.Multiplayer
|
||||
Room = joinedRoom;
|
||||
APIRoom = room;
|
||||
|
||||
APIRoom.Playlist.Clear();
|
||||
APIRoom.Playlist.AddRange(playlistItems);
|
||||
|
||||
Debug.Assert(LocalUser != null);
|
||||
addUserToAPIRoom(LocalUser);
|
||||
|
||||
@ -158,8 +164,6 @@ namespace osu.Game.Online.Multiplayer
|
||||
OnRoomJoined();
|
||||
}, cancellationSource.Token).ConfigureAwait(false);
|
||||
|
||||
await RequestAllPlaylistItems().ConfigureAwait(false);
|
||||
|
||||
// Update room settings.
|
||||
await updateLocalRoomSettings(joinedRoom.Settings, cancellationSource.Token).ConfigureAwait(false);
|
||||
}, cancellationSource.Token).ConfigureAwait(false);
|
||||
@ -307,8 +311,6 @@ namespace osu.Game.Online.Multiplayer
|
||||
|
||||
public abstract Task StartMatch();
|
||||
|
||||
public abstract Task RequestAllPlaylistItems();
|
||||
|
||||
public abstract Task AddPlaylistItem(MultiplayerPlaylistItem item);
|
||||
|
||||
Task IMultiplayerClient.RoomStateChanged(MultiplayerRoomState state)
|
||||
|
@ -7,6 +7,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Game.Online.Rooms;
|
||||
|
||||
namespace osu.Game.Online.Multiplayer
|
||||
{
|
||||
@ -50,6 +51,9 @@ namespace osu.Game.Online.Multiplayer
|
||||
[Key(5)]
|
||||
public MatchRoomState? MatchState { get; set; }
|
||||
|
||||
[Key(6)]
|
||||
public IList<MultiplayerPlaylistItem> Playlist { get; set; } = new List<MultiplayerPlaylistItem>();
|
||||
|
||||
[JsonConstructor]
|
||||
[SerializationConstructor]
|
||||
public MultiplayerRoom(long roomId)
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@ -152,14 +151,6 @@ namespace osu.Game.Online.Multiplayer
|
||||
return connection.InvokeAsync(nameof(IMultiplayerServer.StartMatch));
|
||||
}
|
||||
|
||||
public override Task RequestAllPlaylistItems()
|
||||
{
|
||||
if (!IsConnected.Value)
|
||||
return Task.FromResult(Array.Empty<MultiplayerPlaylistItem>());
|
||||
|
||||
return connection.InvokeAsync<MultiplayerPlaylistItem[]>(nameof(IMultiplayerServer.RequestAllPlaylistItems));
|
||||
}
|
||||
|
||||
public override Task AddPlaylistItem(MultiplayerPlaylistItem item)
|
||||
{
|
||||
if (!IsConnected.Value)
|
||||
|
@ -294,12 +294,6 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
return ((IMultiplayerClient)this).LoadRequested();
|
||||
}
|
||||
|
||||
public override async Task RequestAllPlaylistItems()
|
||||
{
|
||||
foreach (var item in playlistItems)
|
||||
await ((IMultiplayerClient)this).PlaylistItemAdded(item).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
public override async Task AddPlaylistItem(MultiplayerPlaylistItem item)
|
||||
{
|
||||
Debug.Assert(Room != null);
|
||||
|
Loading…
Reference in New Issue
Block a user