mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:57:39 +08:00
Add room structure for countdown timers
This commit is contained in:
parent
efce471f0b
commit
3b938865a1
@ -0,0 +1,22 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
#nullable enable
|
||||
|
||||
using MessagePack;
|
||||
|
||||
namespace osu.Game.Online.Multiplayer.Countdown
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates a change to the <see cref="MultiplayerRoom"/>'s countdown.
|
||||
/// </summary>
|
||||
[MessagePackObject]
|
||||
public class CountdownChangedEvent : MatchServerEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// The new countdown.
|
||||
/// </summary>
|
||||
[Key(0)]
|
||||
public MultiplayerCountdown? Countdown { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using MessagePack;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace osu.Game.Online.Multiplayer.Countdown
|
||||
{
|
||||
/// <summary>
|
||||
/// A request for a countdown to start the match.
|
||||
/// </summary>
|
||||
[MessagePackObject]
|
||||
public class MatchStartCountdownRequest : MatchUserRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// How long the countdown should last.
|
||||
/// </summary>
|
||||
[Key(0)]
|
||||
public TimeSpan Delay { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
#nullable enable
|
||||
|
||||
using MessagePack;
|
||||
|
||||
namespace osu.Game.Online.Multiplayer.Countdown
|
||||
{
|
||||
/// <summary>
|
||||
/// Request to stop the current countdown.
|
||||
/// </summary>
|
||||
[MessagePackObject]
|
||||
public class StopCountdownRequest : MatchUserRequest
|
||||
{
|
||||
}
|
||||
}
|
@ -1,8 +1,11 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using MessagePack;
|
||||
using osu.Game.Online.Multiplayer.Countdown;
|
||||
|
||||
namespace osu.Game.Online.Multiplayer
|
||||
{
|
||||
@ -11,6 +14,8 @@ namespace osu.Game.Online.Multiplayer
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[MessagePackObject]
|
||||
// IMPORTANT: Add rules to SignalRUnionWorkaroundResolver for new derived types.
|
||||
[Union(0, typeof(CountdownChangedEvent))]
|
||||
public abstract class MatchServerEvent
|
||||
{
|
||||
}
|
||||
|
17
osu.Game/Online/Multiplayer/MatchStartCountdown.cs
Normal file
17
osu.Game/Online/Multiplayer/MatchStartCountdown.cs
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
#nullable enable
|
||||
|
||||
using MessagePack;
|
||||
|
||||
namespace osu.Game.Online.Multiplayer
|
||||
{
|
||||
/// <summary>
|
||||
/// A <see cref="MultiplayerCountdown"/> which will start the match after ending.
|
||||
/// </summary>
|
||||
[MessagePackObject]
|
||||
public class MatchStartCountdown : MultiplayerCountdown
|
||||
{
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ using MessagePack;
|
||||
|
||||
namespace osu.Game.Online.Multiplayer.MatchTypes.TeamVersus
|
||||
{
|
||||
[MessagePackObject]
|
||||
public class ChangeTeamRequest : MatchUserRequest
|
||||
{
|
||||
[Key(0)]
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using System;
|
||||
using MessagePack;
|
||||
using osu.Game.Online.Multiplayer.Countdown;
|
||||
using osu.Game.Online.Multiplayer.MatchTypes.TeamVersus;
|
||||
|
||||
namespace osu.Game.Online.Multiplayer
|
||||
@ -12,7 +13,10 @@ namespace osu.Game.Online.Multiplayer
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[MessagePackObject]
|
||||
[Union(0, typeof(ChangeTeamRequest))] // IMPORTANT: Add rules to SignalRUnionWorkaroundResolver for new derived types.
|
||||
// IMPORTANT: Add rules to SignalRUnionWorkaroundResolver for new derived types.
|
||||
[Union(0, typeof(ChangeTeamRequest))]
|
||||
[Union(1, typeof(MatchStartCountdownRequest))]
|
||||
[Union(2, typeof(StopCountdownRequest))]
|
||||
public abstract class MatchUserRequest
|
||||
{
|
||||
}
|
||||
|
24
osu.Game/Online/Multiplayer/MultiplayerCountdown.cs
Normal file
24
osu.Game/Online/Multiplayer/MultiplayerCountdown.cs
Normal file
@ -0,0 +1,24 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using MessagePack;
|
||||
|
||||
namespace osu.Game.Online.Multiplayer
|
||||
{
|
||||
/// <summary>
|
||||
/// Describes the current countdown in a <see cref="MultiplayerRoom"/>.
|
||||
/// </summary>
|
||||
[MessagePackObject]
|
||||
[Union(0, typeof(MatchStartCountdown))] // IMPORTANT: Add rules to SignalRUnionWorkaroundResolver for new derived types.
|
||||
public abstract class MultiplayerCountdown
|
||||
{
|
||||
/// <summary>
|
||||
/// The time at which the countdown will end.
|
||||
/// </summary>
|
||||
[Key(0)]
|
||||
public DateTimeOffset EndTime { get; set; }
|
||||
}
|
||||
}
|
@ -54,6 +54,12 @@ namespace osu.Game.Online.Multiplayer
|
||||
[Key(6)]
|
||||
public IList<MultiplayerPlaylistItem> Playlist { get; set; } = new List<MultiplayerPlaylistItem>();
|
||||
|
||||
/// <summary>
|
||||
/// The currently-running countdown.
|
||||
/// </summary>
|
||||
[Key(7)]
|
||||
public MultiplayerCountdown? Countdown { get; set; }
|
||||
|
||||
[JsonConstructor]
|
||||
[SerializationConstructor]
|
||||
public MultiplayerRoom(long roomId)
|
||||
|
@ -4,6 +4,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Online.Multiplayer.Countdown;
|
||||
using osu.Game.Online.Multiplayer.MatchTypes.TeamVersus;
|
||||
|
||||
namespace osu.Game.Online
|
||||
@ -18,8 +19,12 @@ namespace osu.Game.Online
|
||||
internal static readonly IReadOnlyList<(Type derivedType, Type baseType)> BASE_TYPE_MAPPING = new[]
|
||||
{
|
||||
(typeof(ChangeTeamRequest), typeof(MatchUserRequest)),
|
||||
(typeof(MatchStartCountdownRequest), typeof(MatchUserRequest)),
|
||||
(typeof(StopCountdownRequest), typeof(MatchUserRequest)),
|
||||
(typeof(CountdownChangedEvent), typeof(MatchServerEvent)),
|
||||
(typeof(TeamVersusRoomState), typeof(MatchRoomState)),
|
||||
(typeof(TeamVersusUserState), typeof(MatchUserState)),
|
||||
(typeof(MatchStartCountdown), typeof(MultiplayerCountdown))
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user