A game about forced loneliness, made by TACStudios
1using System;
2
3namespace UnityEngine.InputSystem.Users
4{
5 /// <summary>
6 /// Handle for a user account in an external API.
7 /// </summary>
8 public struct InputUserAccountHandle : IEquatable<InputUserAccountHandle>
9 {
10 /// <summary>
11 /// Symbolic name of the API that owns the handle.
12 /// </summary>
13 /// <remarks>
14 /// This essentially provides a namespace for <see cref="handle"/>.
15 ///
16 /// On PS4, for example, this will read "PS4" for user handles corresponding
17 /// to <c>sceUserId</c>.
18 ///
19 /// This will not be null or empty except if the handle is invalid.
20 /// </remarks>
21 public string apiName
22 {
23 get { return m_ApiName; }
24 }
25
26 public ulong handle
27 {
28 get { return m_Handle; }
29 }
30
31 public InputUserAccountHandle(string apiName, ulong handle)
32 {
33 if (string.IsNullOrEmpty(apiName))
34 throw new ArgumentNullException("apiName");
35
36 m_ApiName = apiName;
37 m_Handle = handle;
38 }
39
40 public override string ToString()
41 {
42 if (m_ApiName == null)
43 return base.ToString();
44
45 return string.Format("{0}({1})", m_ApiName, m_Handle);
46 }
47
48 public bool Equals(InputUserAccountHandle other)
49 {
50 return string.Equals(apiName, other.apiName) && Equals(handle, other.handle);
51 }
52
53 public override bool Equals(object obj)
54 {
55 if (ReferenceEquals(null, obj))
56 return false;
57 return obj is InputUserAccountHandle && Equals((InputUserAccountHandle)obj);
58 }
59
60 public static bool operator==(InputUserAccountHandle left, InputUserAccountHandle right)
61 {
62 return left.Equals(right);
63 }
64
65 public static bool operator!=(InputUserAccountHandle left, InputUserAccountHandle right)
66 {
67 return !left.Equals(right);
68 }
69
70 public override int GetHashCode()
71 {
72 unchecked
73 {
74 return ((apiName != null ? apiName.GetHashCode() : 0) * 397) ^ handle.GetHashCode();
75 }
76 }
77
78 private string m_ApiName;
79 private ulong m_Handle;
80 }
81}