Ejemplo n.º 1
0
        private void updatePlaylist(MultiplayerRoomSettings settings, APIBeatmapSet onlineSet)
        {
            if (Room == null || !Room.Settings.Equals(settings))
            {
                return;
            }

            Debug.Assert(apiRoom != null);

            var beatmapSet = onlineSet.ToBeatmapSet(rulesets);
            var beatmap    = beatmapSet.Beatmaps.Single(b => b.OnlineBeatmapID == settings.BeatmapID);

            beatmap.MD5Hash = settings.BeatmapChecksum;

            var ruleset = rulesets.GetRuleset(settings.RulesetID).CreateInstance();
            var mods    = settings.Mods.Select(m => m.ToMod(ruleset));

            PlaylistItem playlistItem = new PlaylistItem
            {
                ID      = playlistItemId,
                Beatmap = { Value = beatmap },
                Ruleset = { Value = ruleset.RulesetInfo },
            };

            playlistItem.RequiredMods.AddRange(mods);

            apiRoom.Playlist.Clear(); // Clearing should be unnecessary, but here for sanity.
            apiRoom.Playlist.Add(playlistItem);
        }
Ejemplo n.º 2
0
        private void updateLocalRoomSettings(MultiplayerRoomSettings settings)
        {
            if (Room == null)
            {
                return;
            }

            // Update a few properties of the room instantaneously.
            Schedule(() =>
            {
                if (Room == null)
                {
                    return;
                }

                Debug.Assert(apiRoom != null);

                Room.Settings      = settings;
                apiRoom.Name.Value = Room.Settings.Name;

                // The playlist update is delayed until an online beatmap lookup (below) succeeds.
                // In-order for the client to not display an outdated beatmap, the playlist is forcefully cleared here.
                apiRoom.Playlist.Clear();

                RoomChanged?.Invoke();
            });

            var req = new GetBeatmapSetRequest(settings.BeatmapID, BeatmapSetLookupType.BeatmapId);

            req.Success += res => updatePlaylist(settings, res);

            api.Queue(req);
        }
Ejemplo n.º 3
0
 Task IMultiplayerClient.SettingsChanged(MultiplayerRoomSettings newSettings)
 {
     updateLocalRoomSettings(newSettings);
     return(Task.CompletedTask);
 }
Ejemplo n.º 4
0
 public abstract Task ChangeSettings(MultiplayerRoomSettings settings);