private void onUserStateAdded(int userId, SpectatorState state) { if (state.RulesetID == null || state.BeatmapID == null) { return; } if (!userMap.ContainsKey(userId)) { return; } Schedule(() => OnUserStateChanged(userId, state)); updateGameplayState(userId); }
private void userFinishedPlaying(int userId, SpectatorState state) { if (userId != targetUser.Id) { return; } if (replay != null) { replay.HasReceivedAllFrames = true; replay = null; } Schedule(clearDisplay); }
private void userBeganPlaying(int userId, SpectatorState state) { if (userId != score.ScoreInfo.UserID) { return; } Schedule(() => { if (this.IsCurrentScreen()) { this.Exit(); } }); }
Task ISpectatorClient.UserBeganPlaying(int userId, SpectatorState state) { if (watchingUsers.Contains(userId)) { Console.WriteLine($"{connection.ConnectionId} received began playing for already watched user {userId}"); } else { Console.WriteLine($"{connection.ConnectionId} requesting watch other user {userId}"); WatchUser(userId); watchingUsers.Add(userId); } return(Task.CompletedTask); }
protected override void EndGameplay(int userId, SpectatorState state) { // Allowed passed/failed users to complete their remaining replay frames. // The failed state isn't really possible in multiplayer (yet?) but is added here just for safety in case it starts being used. if (state.State == SpectatedUserState.Passed || state.State == SpectatedUserState.Failed) { return; } RemoveUser(userId); var instance = instances.Single(i => i.UserId == userId); instance.FadeColour(colours.Gray4, 400, Easing.OutQuint); syncManager.RemovePlayerClock(instance.GameplayClock); }
private void showBeatmapPanel(SpectatorState state) { Debug.Assert(state.BeatmapID != null); onlineBeatmapRequest = new GetBeatmapSetRequest(state.BeatmapID.Value, BeatmapSetLookupType.BeatmapId); onlineBeatmapRequest.Success += beatmapSet => Schedule(() => { this.beatmapSet = beatmapSet; beatmapPanelContainer.Child = new BeatmapCard(this.beatmapSet) { Expanded = { Disabled = true } }; checkForAutomaticDownload(); }); api.Queue(onlineBeatmapRequest); }
private void onUserStateRemoved(int userId, SpectatorState state) { if (!userMap.ContainsKey(userId)) { return; } if (!gameplayStates.TryGetValue(userId, out var gameplayState)) { return; } gameplayState.Score.Replay.HasReceivedAllFrames = true; gameplayStates.Remove(userId); Schedule(() => EndGameplay(userId, state)); }
private void userBeganPlaying(int userId, SpectatorState state) { if (userId != targetUser.Id) { return; } this.state = state; if (this.IsCurrentScreen()) { Schedule(attemptStart); } else { newStatePending = true; } }
private void userFinishedPlaying(int userId, SpectatorState state) { if (userId != targetUser.Id) { return; } lock (scoreLock) { if (score != null) { score.Replay.HasReceivedAllFrames = true; score = null; } } Schedule(clearDisplay); }
private void userBeganPlaying(int userId, SpectatorState state) { if (state.RulesetID == null || state.BeatmapID == null) { return; } lock (stateLock) { if (!userMap.ContainsKey(userId)) { return; } spectatorStates[userId] = state; Schedule(() => OnUserStateChanged(userId, state)); updateGameplayState(userId); } }
private void showBeatmapPanel(SpectatorState state) { if (state?.BeatmapID == null) { onlineBeatmap = null; return; } var req = new GetBeatmapSetRequest(state.BeatmapID.Value, BeatmapSetLookupType.BeatmapId); req.Success += res => Schedule(() => { if (state != this.state) { return; } onlineBeatmap = res.ToBeatmapSet(rulesets); beatmapPanelContainer.Child = new GridBeatmapPanel(onlineBeatmap); checkForAutomaticDownload(); }); api.Queue(req); }
protected override void OnNewPlayingUserState(int userId, SpectatorState spectatorState) { }
protected override Task EndPlayingInternal(SpectatorState state) => ((ISpectatorClient)this).UserFinishedPlaying(api.LocalUser.Value.Id, state);
public Task EndPlaying(SpectatorState state) => connection.SendAsync(nameof(ISpectatorServer.EndPlaySession), state);
protected override void OnUserStateChanged(int userId, SpectatorState spectatorState) { }
protected override void OnUserStateChanged(int userId, SpectatorState spectatorState) { clearDisplay(); showBeatmapPanel(spectatorState); }
private async Task updateUserState(SpectatorState state) { await cache.SetStringAsync(GetStateId(currentContextUserId), JsonConvert.SerializeObject(state)); }
private async Task endPlaySession(int userId, SpectatorState state) { await Clients.All.UserFinishedPlaying(userId, state); }
protected abstract void OnNewPlayingUserState(int userId, [NotNull] SpectatorState spectatorState);
/// <summary> /// Invoked when a spectated user's state has changed. /// </summary> /// <param name="userId">The user whose state has changed.</param> /// <param name="spectatorState">The new state.</param> protected abstract void OnUserStateChanged(int userId, [NotNull] SpectatorState spectatorState);
protected abstract void EndGameplay(int userId, SpectatorState state);
protected override void OnNewPlayingUserState(int userId, SpectatorState spectatorState) { clearDisplay(); showBeatmapPanel(spectatorState); }
Task ISpectatorClient.UserFinishedPlaying(int userId, SpectatorState state) { Console.WriteLine($"{connection.ConnectionId} Received user finished event {state}"); return(Task.CompletedTask); }