2020-12-04 06:34:31 +00:00
|
|
|
// 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;
|
2020-12-07 09:50:02 +00:00
|
|
|
using System.Collections.Generic;
|
2021-01-26 07:26:03 +00:00
|
|
|
using MessagePack;
|
2020-12-09 06:05:57 +00:00
|
|
|
using Newtonsoft.Json;
|
2021-11-16 04:49:06 +00:00
|
|
|
using osu.Game.Online.Rooms;
|
2020-12-04 06:34:31 +00:00
|
|
|
|
2020-12-25 04:38:11 +00:00
|
|
|
namespace osu.Game.Online.Multiplayer
|
2020-12-04 06:34:31 +00:00
|
|
|
{
|
2020-12-08 07:02:35 +00:00
|
|
|
/// <summary>
|
|
|
|
/// A multiplayer room.
|
|
|
|
/// </summary>
|
2020-12-04 06:34:31 +00:00
|
|
|
[Serializable]
|
2021-01-26 07:26:03 +00:00
|
|
|
[MessagePackObject]
|
2020-12-04 06:34:31 +00:00
|
|
|
public class MultiplayerRoom
|
|
|
|
{
|
2020-12-08 06:54:52 +00:00
|
|
|
/// <summary>
|
|
|
|
/// The ID of the room, used for database persistence.
|
|
|
|
/// </summary>
|
2021-01-26 07:26:03 +00:00
|
|
|
[Key(0)]
|
2020-12-08 07:44:47 +00:00
|
|
|
public readonly long RoomID;
|
2020-12-04 06:34:31 +00:00
|
|
|
|
2020-12-08 06:54:52 +00:00
|
|
|
/// <summary>
|
|
|
|
/// The current state of the room (ie. whether it is in progress or otherwise).
|
|
|
|
/// </summary>
|
2021-01-26 07:26:03 +00:00
|
|
|
[Key(1)]
|
2020-12-04 06:34:31 +00:00
|
|
|
public MultiplayerRoomState State { get; set; }
|
2020-12-07 09:50:02 +00:00
|
|
|
|
2020-12-08 06:54:52 +00:00
|
|
|
/// <summary>
|
|
|
|
/// All currently enforced game settings for this room.
|
|
|
|
/// </summary>
|
2021-01-26 07:26:03 +00:00
|
|
|
[Key(2)]
|
2020-12-09 03:12:03 +00:00
|
|
|
public MultiplayerRoomSettings Settings { get; set; } = new MultiplayerRoomSettings();
|
2020-12-08 05:33:38 +00:00
|
|
|
|
2020-12-08 06:54:52 +00:00
|
|
|
/// <summary>
|
2020-12-08 07:02:35 +00:00
|
|
|
/// All users currently in this room.
|
2020-12-08 06:54:52 +00:00
|
|
|
/// </summary>
|
2021-01-26 07:26:03 +00:00
|
|
|
[Key(3)]
|
2021-07-23 09:16:53 +00:00
|
|
|
public IList<MultiplayerRoomUser> Users { get; set; } = new List<MultiplayerRoomUser>();
|
2020-12-08 06:46:11 +00:00
|
|
|
|
2020-12-08 07:15:51 +00:00
|
|
|
/// <summary>
|
|
|
|
/// The host of this room, in control of changing room settings.
|
|
|
|
/// </summary>
|
2021-01-26 07:26:03 +00:00
|
|
|
[Key(4)]
|
2020-12-08 07:15:51 +00:00
|
|
|
public MultiplayerRoomUser? Host { get; set; }
|
|
|
|
|
2021-07-21 09:59:02 +00:00
|
|
|
[Key(5)]
|
2021-08-03 06:43:04 +00:00
|
|
|
public MatchRoomState? MatchState { get; set; }
|
2021-07-21 09:59:02 +00:00
|
|
|
|
2021-11-16 04:49:06 +00:00
|
|
|
[Key(6)]
|
|
|
|
public IList<MultiplayerPlaylistItem> Playlist { get; set; } = new List<MultiplayerPlaylistItem>();
|
|
|
|
|
2022-03-17 10:14:46 +00:00
|
|
|
/// <summary>
|
2022-09-01 09:53:35 +00:00
|
|
|
/// The currently running countdowns.
|
2022-03-17 10:14:46 +00:00
|
|
|
/// </summary>
|
|
|
|
[Key(7)]
|
2022-09-01 09:53:35 +00:00
|
|
|
public IList<MultiplayerCountdown> ActiveCountdowns { get; set; } = new List<MultiplayerCountdown>();
|
2022-03-17 10:14:46 +00:00
|
|
|
|
2020-12-09 06:05:57 +00:00
|
|
|
[JsonConstructor]
|
2021-01-26 07:26:03 +00:00
|
|
|
[SerializationConstructor]
|
|
|
|
public MultiplayerRoom(long roomId)
|
2020-12-08 07:44:47 +00:00
|
|
|
{
|
|
|
|
RoomID = roomId;
|
|
|
|
}
|
|
|
|
|
2020-12-09 05:47:26 +00:00
|
|
|
public override string ToString() => $"RoomID:{RoomID} Host:{Host?.UserID} Users:{Users.Count} State:{State} Settings: [{Settings}]";
|
2020-12-04 06:34:31 +00:00
|
|
|
}
|
|
|
|
}
|