mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 07:33:55 +09:00
Setup all multiplayer model classes for MessagePack support
This commit is contained in:
@ -5,6 +5,7 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace osu.Game.Online.Multiplayer
|
||||
@ -13,35 +14,42 @@ namespace osu.Game.Online.Multiplayer
|
||||
/// A multiplayer room.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
[MessagePackObject]
|
||||
public class MultiplayerRoom
|
||||
{
|
||||
/// <summary>
|
||||
/// The ID of the room, used for database persistence.
|
||||
/// </summary>
|
||||
[Key(0)]
|
||||
public readonly long RoomID;
|
||||
|
||||
/// <summary>
|
||||
/// The current state of the room (ie. whether it is in progress or otherwise).
|
||||
/// </summary>
|
||||
[Key(1)]
|
||||
public MultiplayerRoomState State { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// All currently enforced game settings for this room.
|
||||
/// </summary>
|
||||
[Key(2)]
|
||||
public MultiplayerRoomSettings Settings { get; set; } = new MultiplayerRoomSettings();
|
||||
|
||||
/// <summary>
|
||||
/// All users currently in this room.
|
||||
/// </summary>
|
||||
[Key(3)]
|
||||
public List<MultiplayerRoomUser> Users { get; set; } = new List<MultiplayerRoomUser>();
|
||||
|
||||
/// <summary>
|
||||
/// The host of this room, in control of changing room settings.
|
||||
/// </summary>
|
||||
[Key(4)]
|
||||
public MultiplayerRoomUser? Host { get; set; }
|
||||
|
||||
[JsonConstructor]
|
||||
public MultiplayerRoom(in long roomId)
|
||||
[SerializationConstructor]
|
||||
public MultiplayerRoom(long roomId)
|
||||
{
|
||||
RoomID = roomId;
|
||||
}
|
||||
|
@ -7,22 +7,29 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using MessagePack;
|
||||
using osu.Game.Online.API;
|
||||
|
||||
namespace osu.Game.Online.Multiplayer
|
||||
{
|
||||
[Serializable]
|
||||
[MessagePackObject]
|
||||
public class MultiplayerRoomSettings : IEquatable<MultiplayerRoomSettings>
|
||||
{
|
||||
[Key(0)]
|
||||
public int BeatmapID { get; set; }
|
||||
|
||||
[Key(1)]
|
||||
public int RulesetID { get; set; }
|
||||
|
||||
[Key(2)]
|
||||
public string BeatmapChecksum { get; set; } = string.Empty;
|
||||
|
||||
[Key(3)]
|
||||
public string Name { get; set; } = "Unnamed room";
|
||||
|
||||
[NotNull]
|
||||
[Key(4)]
|
||||
public IEnumerable<APIMod> Mods { get; set; } = Enumerable.Empty<APIMod>();
|
||||
|
||||
public bool Equals(MultiplayerRoomSettings other)
|
||||
|
@ -4,6 +4,7 @@
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using MessagePack;
|
||||
using Newtonsoft.Json;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Users;
|
||||
@ -11,21 +12,26 @@ using osu.Game.Users;
|
||||
namespace osu.Game.Online.Multiplayer
|
||||
{
|
||||
[Serializable]
|
||||
[MessagePackObject]
|
||||
public class MultiplayerRoomUser : IEquatable<MultiplayerRoomUser>
|
||||
{
|
||||
[Key(0)]
|
||||
public readonly int UserID;
|
||||
|
||||
[Key(1)]
|
||||
public MultiplayerUserState State { get; set; } = MultiplayerUserState.Idle;
|
||||
|
||||
/// <summary>
|
||||
/// The availability state of the current beatmap.
|
||||
/// </summary>
|
||||
[Key(2)]
|
||||
public BeatmapAvailability BeatmapAvailability { get; set; } = BeatmapAvailability.LocallyAvailable();
|
||||
|
||||
[IgnoreMember]
|
||||
public User? User { get; set; }
|
||||
|
||||
[JsonConstructor]
|
||||
public MultiplayerRoomUser(in int userId)
|
||||
public MultiplayerRoomUser(int userId)
|
||||
{
|
||||
UserID = userId;
|
||||
}
|
||||
|
Reference in New Issue
Block a user