Simplify method of marking players as playing in test scenes

This commit is contained in:
Dean Herbert
2021-08-09 19:18:13 +09:00
parent 359b6ec174
commit ea6e441dec
5 changed files with 29 additions and 14 deletions

View File

@ -62,7 +62,9 @@ namespace osu.Game.Online.Multiplayer
/// <summary>
/// The users in the joined <see cref="Room"/> which are participating in the current gameplay loop.
/// </summary>
public readonly BindableList<int> CurrentMatchPlayingUserIds = new BindableList<int>();
public IBindableList<int> CurrentMatchPlayingUserIds => PlayingUserIds;
protected readonly BindableList<int> PlayingUserIds = new BindableList<int>();
public readonly Bindable<PlaylistItem?> CurrentMatchPlayingItem = new Bindable<PlaylistItem?>();
@ -179,7 +181,7 @@ namespace osu.Game.Online.Multiplayer
{
APIRoom = null;
Room = null;
CurrentMatchPlayingUserIds.Clear();
PlayingUserIds.Clear();
RoomUpdated?.Invoke();
});
@ -376,7 +378,7 @@ namespace osu.Game.Online.Multiplayer
return;
Room.Users.Remove(user);
CurrentMatchPlayingUserIds.Remove(user.UserID);
PlayingUserIds.Remove(user.UserID);
RoomUpdated?.Invoke();
}, false);
@ -659,16 +661,16 @@ namespace osu.Game.Online.Multiplayer
/// <param name="state">The new state of the user.</param>
private void updateUserPlayingState(int userId, MultiplayerUserState state)
{
bool wasPlaying = CurrentMatchPlayingUserIds.Contains(userId);
bool wasPlaying = PlayingUserIds.Contains(userId);
bool isPlaying = state >= MultiplayerUserState.WaitingForLoad && state <= MultiplayerUserState.FinishedPlay;
if (isPlaying == wasPlaying)
return;
if (isPlaying)
CurrentMatchPlayingUserIds.Add(userId);
PlayingUserIds.Add(userId);
else
CurrentMatchPlayingUserIds.Remove(userId);
PlayingUserIds.Remove(userId);
}
private Task scheduleAsync(Action action, CancellationToken cancellationToken = default)