2020-12-07 17:50:02 +08: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 15:15:51 +08:00
|
|
|
#nullable enable
|
|
|
|
|
2020-12-08 13:33:47 +08:00
|
|
|
using System;
|
2020-12-09 14:05:57 +08:00
|
|
|
using Newtonsoft.Json;
|
2020-12-07 17:50:02 +08:00
|
|
|
using osu.Game.Users;
|
|
|
|
|
2020-12-25 12:38:11 +08:00
|
|
|
namespace osu.Game.Online.Multiplayer
|
2020-12-07 17:50:02 +08:00
|
|
|
{
|
2020-12-08 15:15:51 +08:00
|
|
|
[Serializable]
|
2020-12-08 13:33:47 +08:00
|
|
|
public class MultiplayerRoomUser : IEquatable<MultiplayerRoomUser>
|
2020-12-07 17:50:02 +08:00
|
|
|
{
|
2020-12-09 11:10:47 +08:00
|
|
|
public readonly int UserID;
|
2020-12-08 15:15:51 +08:00
|
|
|
|
|
|
|
public MultiplayerUserState State { get; set; } = MultiplayerUserState.Idle;
|
|
|
|
|
|
|
|
public User? User { get; set; }
|
|
|
|
|
2020-12-09 14:05:57 +08:00
|
|
|
[JsonConstructor]
|
2020-12-07 17:50:02 +08:00
|
|
|
public MultiplayerRoomUser(in int userId)
|
|
|
|
{
|
|
|
|
UserID = userId;
|
|
|
|
}
|
|
|
|
|
2020-12-08 13:33:47 +08: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 15:15:51 +08:00
|
|
|
if (obj.GetType() != GetType()) return false;
|
2020-12-08 13:33:47 +08:00
|
|
|
|
|
|
|
return Equals((MultiplayerRoomUser)obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
public override int GetHashCode() => UserID.GetHashCode();
|
2020-12-07 17:50:02 +08:00
|
|
|
}
|
|
|
|
}
|