mirror of
https://github.com/ppy/osu.git
synced 2026-06-04 05:43:42 +08:00
4671d1fe74
- Part of https://github.com/ppy/osu-server-spectator/issues/405 <img width="1624" height="900" alt="Screenshot 2026-05-13 at 12 40 07" src="https://github.com/user-attachments/assets/a7f36d54-4cc6-49c9-8e89-ee0d049bb637" /> <img width="1624" height="900" alt="Screenshot 2026-05-13 at 12 31 40" src="https://github.com/user-attachments/assets/0c054dfd-addd-4d00-bbca-119b4c3ec3cb" /> Will not work until relevant server-side support is in. --- I was in two minds whether to PR this all at once or to PR only https://github.com/ppy/osu/commit/693e4ef4b095042f7a171672224e10f9c4f47c1c to begin with to unblock server-side implementation. In the end I opted for one PR because usage informs the model, so I find everything else relevant as part of review of the model design. If there are concerns about this making it into a release without server-side support and therefore things looking broken I will split the commit out on request. I put in some effort to add relevant logic in test multiplayer client to simulate the server side but I may well have missed something. --------- Co-authored-by: Dean Herbert <pe@ppy.sh>
81 lines
2.8 KiB
C#
81 lines
2.8 KiB
C#
// 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;
|
|
using osu.Game.Online.Rooms;
|
|
|
|
namespace osu.Game.Online.Multiplayer
|
|
{
|
|
[Serializable]
|
|
[MessagePackObject]
|
|
public class MultiplayerRoomSettings : IEquatable<MultiplayerRoomSettings>
|
|
{
|
|
[Key(0)]
|
|
public string Name { get; set; } = "Unnamed room";
|
|
|
|
[Key(1)]
|
|
public long PlaylistItemId { get; set; }
|
|
|
|
[Key(2)]
|
|
public string Password { get; set; } = string.Empty;
|
|
|
|
[Key(3)]
|
|
public MatchType MatchType { get; set; } = MatchType.HeadToHead;
|
|
|
|
[Key(4)]
|
|
public QueueMode QueueMode { get; set; } = QueueMode.HostOnly;
|
|
|
|
[Key(5)]
|
|
public TimeSpan AutoStartDuration { get; set; }
|
|
|
|
[Key(6)]
|
|
public bool AutoSkip { get; set; }
|
|
|
|
[Key(7)]
|
|
public byte? MaxParticipants { get; set; }
|
|
|
|
[IgnoreMember]
|
|
public bool AutoStartEnabled => AutoStartDuration != TimeSpan.Zero;
|
|
|
|
public MultiplayerRoomSettings()
|
|
{
|
|
}
|
|
|
|
public MultiplayerRoomSettings(Room room)
|
|
{
|
|
Name = room.Name;
|
|
Password = room.Password ?? string.Empty;
|
|
MatchType = room.Type;
|
|
QueueMode = room.QueueMode;
|
|
AutoStartDuration = room.AutoStartDuration;
|
|
AutoSkip = room.AutoSkip;
|
|
MaxParticipants = room.MaxParticipants;
|
|
}
|
|
|
|
public bool Equals(MultiplayerRoomSettings? other)
|
|
{
|
|
if (ReferenceEquals(this, other)) return true;
|
|
if (other == null) return false;
|
|
|
|
return Password.Equals(other.Password, StringComparison.Ordinal)
|
|
&& Name.Equals(other.Name, StringComparison.Ordinal)
|
|
&& PlaylistItemId == other.PlaylistItemId
|
|
&& MatchType == other.MatchType
|
|
&& QueueMode == other.QueueMode
|
|
&& AutoStartDuration == other.AutoStartDuration
|
|
&& AutoSkip == other.AutoSkip
|
|
&& MaxParticipants == other.MaxParticipants;
|
|
}
|
|
|
|
public override string ToString() => $"Name:{Name}"
|
|
+ $" Password:{(string.IsNullOrEmpty(Password) ? "no" : "yes")}"
|
|
+ $" Type:{MatchType}"
|
|
+ $" Item:{PlaylistItemId}"
|
|
+ $" Queue:{QueueMode}"
|
|
+ $" Start:{AutoStartDuration}"
|
|
+ $" AutoSkip:{AutoSkip}"
|
|
+ $" MaxParticipants:{MaxParticipants?.ToString() ?? "no limit"}";
|
|
}
|
|
}
|