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

Store MultiplayerRoomUser as part of tracked data

This commit is contained in:
Dean Herbert 2021-08-06 20:06:57 +09:00
parent 54ffb8dc4e
commit 0fa1f085df
2 changed files with 11 additions and 7 deletions

View File

@ -4,6 +4,7 @@
using System;
using JetBrains.Annotations;
using osu.Framework.Timing;
using osu.Game.Online.Multiplayer;
using osu.Game.Rulesets.Scoring;
using osu.Game.Screens.Play.HUD;
@ -32,7 +33,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
((SpectatingTrackedUserData)data).Clock = null;
}
protected override TrackedUserData CreateUserData(int userId, ScoreProcessor scoreProcessor) => new SpectatingTrackedUserData(userId, scoreProcessor);
protected override TrackedUserData CreateUserData(MultiplayerRoomUser user, ScoreProcessor scoreProcessor) => new SpectatingTrackedUserData(user, scoreProcessor);
protected override void Update()
{
@ -47,8 +48,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Spectate
[CanBeNull]
public IClock Clock;
public SpectatingTrackedUserData(int userId, ScoreProcessor scoreProcessor)
: base(userId, scoreProcessor)
public SpectatingTrackedUserData(MultiplayerRoomUser user, ScoreProcessor scoreProcessor)
: base(user, scoreProcessor)
{
}

View File

@ -11,6 +11,7 @@ using osu.Game.Configuration;
using osu.Game.Database;
using osu.Game.Online.API;
using osu.Game.Online.Multiplayer;
using osu.Game.Online.Rooms;
using osu.Game.Online.Spectator;
using osu.Game.Rulesets.Scoring;
@ -55,7 +56,9 @@ namespace osu.Game.Screens.Play.HUD
foreach (var userId in playingUsers)
{
var trackedUser = CreateUserData(userId, scoreProcessor);
var user = multiplayerClient.Room?.Users.FirstOrDefault(u => u.UserID == userId);
var trackedUser = CreateUserData(user, scoreProcessor);
trackedUser.ScoringMode.BindTo(scoringMode);
UserScores[userId] = trackedUser;
}
@ -145,7 +148,7 @@ namespace osu.Game.Screens.Play.HUD
protected class TrackedUserData
{
public readonly int UserId;
public readonly MultiplayerRoomUser User;
public readonly ScoreProcessor ScoreProcessor;
public readonly BindableDouble Score = new BindableDouble();
@ -157,9 +160,9 @@ namespace osu.Game.Screens.Play.HUD
public readonly List<TimedFrame> Frames = new List<TimedFrame>();
public TrackedUserData(int userId, ScoreProcessor scoreProcessor)
public TrackedUserData(MultiplayerRoomUser user, ScoreProcessor scoreProcessor)
{
UserId = userId;
User = user;
ScoreProcessor = scoreProcessor;
ScoringMode.BindValueChanged(_ => UpdateScore());