1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-06 04:13:11 +08:00

Add LoadAborted() event

This commit is contained in:
Dan Balasescu 2022-04-21 22:38:58 +09:00
parent 08d250fe58
commit 59622deb1f
3 changed files with 25 additions and 1 deletions

View File

@ -93,10 +93,15 @@ namespace osu.Game.Online.Multiplayer
Task UserModsChanged(int userId, IEnumerable<APIMod> mods); Task UserModsChanged(int userId, IEnumerable<APIMod> mods);
/// <summary> /// <summary>
/// Signals that a match is to be started. This will *only* be sent to clients which are to begin loading at this point. /// Signals that the match is starting and the loading of gameplay should be started. This will *only* be sent to clients which are to begin loading at this point.
/// </summary> /// </summary>
Task LoadRequested(); Task LoadRequested();
/// <summary>
/// Signals that loading of gameplay is to be aborted.
/// </summary>
Task LoadAborted();
/// <summary> /// <summary>
/// Signals that gameplay has started. /// Signals that gameplay has started.
/// All users in the <see cref="MultiplayerUserState.Loaded"/> or <see cref="MultiplayerUserState.ReadyForGameplay"/> states should begin gameplay as soon as possible. /// All users in the <see cref="MultiplayerUserState.Loaded"/> or <see cref="MultiplayerUserState.ReadyForGameplay"/> states should begin gameplay as soon as possible.

View File

@ -69,6 +69,11 @@ namespace osu.Game.Online.Multiplayer
/// </summary> /// </summary>
public virtual event Action? LoadRequested; public virtual event Action? LoadRequested;
/// <summary>
/// Invoked when the multiplayer server requests loading of play to be aborted.
/// </summary>
public event Action? LoadAborted;
/// <summary> /// <summary>
/// Invoked when the multiplayer server requests gameplay to be started. /// Invoked when the multiplayer server requests gameplay to be started.
/// </summary> /// </summary>
@ -604,6 +609,19 @@ namespace osu.Game.Online.Multiplayer
return Task.CompletedTask; return Task.CompletedTask;
} }
Task IMultiplayerClient.LoadAborted()
{
Scheduler.Add(() =>
{
if (Room == null)
return;
LoadAborted?.Invoke();
}, false);
return Task.CompletedTask;
}
Task IMultiplayerClient.GameplayStarted() Task IMultiplayerClient.GameplayStarted()
{ {
Scheduler.Add(() => Scheduler.Add(() =>

View File

@ -55,6 +55,7 @@ namespace osu.Game.Online.Multiplayer
connection.On<int, MultiplayerUserState>(nameof(IMultiplayerClient.UserStateChanged), ((IMultiplayerClient)this).UserStateChanged); connection.On<int, MultiplayerUserState>(nameof(IMultiplayerClient.UserStateChanged), ((IMultiplayerClient)this).UserStateChanged);
connection.On(nameof(IMultiplayerClient.LoadRequested), ((IMultiplayerClient)this).LoadRequested); connection.On(nameof(IMultiplayerClient.LoadRequested), ((IMultiplayerClient)this).LoadRequested);
connection.On(nameof(IMultiplayerClient.GameplayStarted), ((IMultiplayerClient)this).GameplayStarted); connection.On(nameof(IMultiplayerClient.GameplayStarted), ((IMultiplayerClient)this).GameplayStarted);
connection.On(nameof(IMultiplayerClient.LoadAborted), ((IMultiplayerClient)this).LoadAborted);
connection.On(nameof(IMultiplayerClient.ResultsReady), ((IMultiplayerClient)this).ResultsReady); connection.On(nameof(IMultiplayerClient.ResultsReady), ((IMultiplayerClient)this).ResultsReady);
connection.On<int, IEnumerable<APIMod>>(nameof(IMultiplayerClient.UserModsChanged), ((IMultiplayerClient)this).UserModsChanged); connection.On<int, IEnumerable<APIMod>>(nameof(IMultiplayerClient.UserModsChanged), ((IMultiplayerClient)this).UserModsChanged);
connection.On<int, BeatmapAvailability>(nameof(IMultiplayerClient.UserBeatmapAvailabilityChanged), ((IMultiplayerClient)this).UserBeatmapAvailabilityChanged); connection.On<int, BeatmapAvailability>(nameof(IMultiplayerClient.UserBeatmapAvailabilityChanged), ((IMultiplayerClient)this).UserBeatmapAvailabilityChanged);