mirror of
https://github.com/osukey/osukey.git
synced 2025-05-21 21:47:31 +09:00
Handle completion user state updates during spectating
This commit is contained in:
parent
7e5086c8d7
commit
2fa8b61f3c
@ -115,13 +115,13 @@ namespace osu.Game.Screens.Spectate
|
|||||||
{
|
{
|
||||||
case NotifyDictionaryChangedAction.Add:
|
case NotifyDictionaryChangedAction.Add:
|
||||||
case NotifyDictionaryChangedAction.Replace:
|
case NotifyDictionaryChangedAction.Replace:
|
||||||
foreach ((int userId, var state) in e.NewItems.AsNonNull())
|
foreach ((int userId, SpectatorState state) in e.NewItems.AsNonNull())
|
||||||
onUserStateChanged(userId, state);
|
onUserStateChanged(userId, state);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NotifyDictionaryChangedAction.Remove:
|
case NotifyDictionaryChangedAction.Remove:
|
||||||
foreach ((int userId, SpectatorState state) in e.OldItems.AsNonNull())
|
foreach ((int userId, SpectatorState state) in e.OldItems.AsNonNull())
|
||||||
onUserStateRemoved(userId, state);
|
onUserStateChanged(userId, state);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -136,33 +136,19 @@ namespace osu.Game.Screens.Spectate
|
|||||||
|
|
||||||
switch (newState.State)
|
switch (newState.State)
|
||||||
{
|
{
|
||||||
case SpectatedUserState.Passed:
|
|
||||||
// Make sure that gameplay completes to the end.
|
|
||||||
if (gameplayStates.TryGetValue(userId, out var gameplayState))
|
|
||||||
gameplayState.Score.Replay.HasReceivedAllFrames = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SpectatedUserState.Playing:
|
case SpectatedUserState.Playing:
|
||||||
Schedule(() => OnNewPlayingUserState(userId, newState));
|
Schedule(() => OnNewPlayingUserState(userId, newState));
|
||||||
startGameplay(userId);
|
startGameplay(userId);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SpectatedUserState.Passed:
|
||||||
|
case SpectatedUserState.Failed:
|
||||||
|
case SpectatedUserState.Quit:
|
||||||
|
endGameplay(userId, newState);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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 startGameplay(int userId)
|
private void startGameplay(int userId)
|
||||||
{
|
{
|
||||||
Debug.Assert(userMap.ContainsKey(userId));
|
Debug.Assert(userMap.ContainsKey(userId));
|
||||||
@ -196,6 +182,20 @@ namespace osu.Game.Screens.Spectate
|
|||||||
Schedule(() => StartGameplay(userId, gameplayState));
|
Schedule(() => StartGameplay(userId, gameplayState));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void endGameplay(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));
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Invoked when a spectated user's state has changed to a new state indicating the player is currently playing.
|
/// Invoked when a spectated user's state has changed to a new state indicating the player is currently playing.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -226,7 +226,7 @@ namespace osu.Game.Screens.Spectate
|
|||||||
if (!userStates.TryGetValue(userId, out var state))
|
if (!userStates.TryGetValue(userId, out var state))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
onUserStateRemoved(userId, state);
|
endGameplay(userId, state);
|
||||||
|
|
||||||
users.Remove(userId);
|
users.Remove(userId);
|
||||||
userMap.Remove(userId);
|
userMap.Remove(userId);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user