2020-12-07 09:50:02 +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.
|
|
|
|
|
2020-12-08 07:15:51 +00:00
|
|
|
#nullable enable
|
|
|
|
|
2020-12-08 05:33:47 +00:00
|
|
|
using System;
|
2021-01-26 07:26:03 +00:00
|
|
|
using MessagePack;
|
2020-12-09 06:05:57 +00:00
|
|
|
using Newtonsoft.Json;
|
2021-01-03 01:25:06 +00:00
|
|
|
using osu.Game.Online.Rooms;
|
2020-12-07 09:50:02 +00:00
|
|
|
using osu.Game.Users;
|
|
|
|
|
2020-12-25 04:38:11 +00:00
|
|
|
namespace osu.Game.Online.Multiplayer
|
2020-12-07 09:50:02 +00:00
|
|
|
{
|
2020-12-08 07:15:51 +00:00
|
|
|
[Serializable]
|
2021-01-26 07:26:03 +00:00
|
|
|
[MessagePackObject]
|
2020-12-08 05:33:47 +00:00
|
|
|
public class MultiplayerRoomUser : IEquatable<MultiplayerRoomUser>
|
2020-12-07 09:50:02 +00:00
|
|
|
{
|
2021-01-26 07:26:03 +00:00
|
|
|
[Key(0)]
|
2020-12-09 03:10:47 +00:00
|
|
|
public readonly int UserID;
|
2020-12-08 07:15:51 +00:00
|
|
|
|
2021-01-26 07:26:03 +00:00
|
|
|
[Key(1)]
|
2020-12-08 07:15:51 +00:00
|
|
|
public MultiplayerUserState State { get; set; } = MultiplayerUserState.Idle;
|
|
|
|
|
2021-01-03 01:25:06 +00:00
|
|
|
/// <summary>
|
2021-01-11 19:28:24 +00:00
|
|
|
/// The availability state of the current beatmap.
|
2021-01-03 01:25:06 +00:00
|
|
|
/// </summary>
|
2021-01-26 07:26:03 +00:00
|
|
|
[Key(2)]
|
2021-01-03 15:34:11 +00:00
|
|
|
public BeatmapAvailability BeatmapAvailability { get; set; } = BeatmapAvailability.LocallyAvailable();
|
2021-01-03 01:25:06 +00:00
|
|
|
|
2021-01-26 07:26:03 +00:00
|
|
|
[IgnoreMember]
|
2020-12-08 07:15:51 +00:00
|
|
|
public User? User { get; set; }
|
|
|
|
|
2020-12-09 06:05:57 +00:00
|
|
|
[JsonConstructor]
|
2021-01-26 07:26:03 +00:00
|
|
|
public MultiplayerRoomUser(int userId)
|
2020-12-07 09:50:02 +00:00
|
|
|
{
|
|
|
|
UserID = userId;
|
|
|
|
}
|
|
|
|
|
2020-12-08 05:33:47 +00:00
|
|
|
public bool Equals(MultiplayerRoomUser other)
|
|
|
|
{
|
|
|
|
if (ReferenceEquals(this, other)) return true;
|
|
|
|
|
|
|
|
return UserID == other.UserID;
|
|
|
|
}
|
|
|
|
|
|
|
|
public override bool Equals(object obj)
|
|
|
|
{
|
|
|
|
if (ReferenceEquals(this, obj)) return true;
|
2020-12-08 07:15:51 +00:00
|
|
|
if (obj.GetType() != GetType()) return false;
|
2020-12-08 05:33:47 +00:00
|
|
|
|
|
|
|
return Equals((MultiplayerRoomUser)obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
public override int GetHashCode() => UserID.GetHashCode();
|
2020-12-07 09:50:02 +00:00
|
|
|
}
|
|
|
|
}
|