forked from ppy/osu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMultiplayerRoomSettings.cs
More file actions
80 lines (65 loc) · 2.78 KB
/
Copy pathMultiplayerRoomSettings.cs
File metadata and controls
80 lines (65 loc) · 2.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// 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"}";
}
}