1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 19:22:54 +08:00

Make localUser a client property

This commit is contained in:
Bartłomiej Dach 2020-12-29 07:46:22 +01:00
parent f68e4fc88f
commit 903dca875e
2 changed files with 9 additions and 6 deletions

View File

@ -65,6 +65,11 @@ namespace osu.Game.Online.Multiplayer
/// </summary>
public readonly BindableList<int> CurrentMatchPlayingUserIds = new BindableList<int>();
/// <summary>
/// The <see cref="MultiplayerRoomUser"/> corresponding to the local player, if available.
/// </summary>
public MultiplayerRoomUser? LocalUser => Room?.Users.SingleOrDefault(u => u.User?.Id == api.LocalUser.Value.Id);
[Resolved]
private UserLookupCache userLookupCache { get; set; } = null!;

View File

@ -27,9 +27,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
[Resolved]
private IAPIProvider api { get; set; }
[CanBeNull]
private MultiplayerRoomUser localUser;
[Resolved]
private OsuColour colours { get; set; }
@ -67,14 +64,13 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
{
base.OnRoomUpdated();
// this method is called on leaving the room, so the local user may not exist in the room any more.
localUser = Room?.Users.SingleOrDefault(u => u.User?.Id == api.LocalUser.Value.Id);
updateState();
}
private void updateState()
{
var localUser = Client.LocalUser;
if (localUser == null)
return;
@ -142,6 +138,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
private void onClick()
{
var localUser = Client.LocalUser;
if (localUser == null)
return;