SW 중심대학 OSS GIT 서버 박건태, 이승준, 고기완, 이준호 새로운 배포
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
4.8 KiB

4 years ago
  1. using System;
  2. using System.Collections.Generic;
  3. namespace UnityEngine.XR.ARFoundation
  4. {
  5. /// <summary>
  6. /// Event arguments for the <see cref="ARParticipantManager.participantsChanged"/> event.
  7. /// </summary>
  8. public struct ARParticipantsChangedEventArgs : IEquatable<ARParticipantsChangedEventArgs>
  9. {
  10. /// <summary>
  11. /// The list of <see cref="ARParticipant"/>s added since the last event.
  12. /// </summary>
  13. public List<ARParticipant> added { get; private set; }
  14. /// <summary>
  15. /// The list of <see cref="ARParticipant"/>s udpated since the last event.
  16. /// </summary>
  17. public List<ARParticipant> updated { get; private set; }
  18. /// <summary>
  19. /// The list of <see cref="ARParticipant"/>s removed since the last event.
  20. /// </summary>
  21. public List<ARParticipant> removed { get; private set; }
  22. /// <summary>
  23. /// Constructs an <see cref="ARParticipantsChangedEventArgs"/>.
  24. /// </summary>
  25. /// <param name="added">The list of <see cref="ARParticipant"/>s added since the last event.</param>
  26. /// <param name="updated">The list of <see cref="ARParticipant"/>s updated since the last event.</param>
  27. /// <param name="removed">The list of <see cref="ARParticipant"/>s removed since the last event.</param>
  28. public ARParticipantsChangedEventArgs(
  29. List<ARParticipant> added,
  30. List<ARParticipant> updated,
  31. List<ARParticipant> removed)
  32. {
  33. this.added = added;
  34. this.updated = updated;
  35. this.removed = removed;
  36. }
  37. /// <summary>
  38. /// Generates a hash suitable for use with containers like <c>HashSet</c> and <c>Dictionary</c>.
  39. /// </summary>
  40. /// <returns>A hash suitable for use with containers like <c>HashSet</c> and <c>Dictionary</c>.</returns>
  41. public override int GetHashCode()
  42. {
  43. unchecked
  44. {
  45. int hash = 0;
  46. hash = hash * 486187739 + (added == null ? 0 : added.GetHashCode());
  47. hash = hash * 486187739 + (updated == null ? 0 : updated.GetHashCode());
  48. hash = hash * 486187739 + (removed == null ? 0 : removed.GetHashCode());
  49. return hash;
  50. }
  51. }
  52. /// <summary>
  53. /// Tests for equality.
  54. /// </summary>
  55. /// <param name="other">The other <see cref="ARParticipantsChangedEventArgs"/> to compare against.</param>
  56. /// <returns><c>true</c> if <paramref name="other"/> is equal to this <see cref="ARParticipantsChangedEventArgs"/>.</returns>
  57. public override bool Equals(object obj) => (obj is ARParticipantsChangedEventArgs) && Equals((ARParticipantsChangedEventArgs)obj);
  58. int GetCount(List<ARParticipant> list) => list != null ? list.Count : 0;
  59. /// <summary>
  60. /// Generates a string suitable for debugging. The string contains the number of added, updated, and removed participants.
  61. /// </summary>
  62. /// <returns>A string suitable for debug logging.</returns>
  63. public override string ToString() => $"Added: {GetCount(added)}, Updated: {GetCount(updated)}, Removed: {GetCount(removed)}";
  64. /// <summary>
  65. /// Tests for equality.
  66. /// </summary>
  67. /// <param name="other">The other <see cref="ARParticipantsChangedEventArgs"/> to compare against.</param>
  68. /// <returns><c>true</c> if <paramref name="other"/> is equal to this <see cref="ARParticipantsChangedEventArgs"/>.</returns>
  69. public bool Equals(ARParticipantsChangedEventArgs other)
  70. {
  71. return
  72. ReferenceEquals(added, other.added) &&
  73. ReferenceEquals(updated, other.updated) &&
  74. ReferenceEquals(removed, other.removed);
  75. }
  76. /// <summary>
  77. /// Tests for equality. Same as <see cref="Equals(ARParticipantsChangedEventArgs)"/>.
  78. /// </summary>
  79. /// <param name="lhs">The left-hand side of the comparison.</param>
  80. /// <param name="rhs">The right-hand side of the comparison.</param>
  81. /// <returns><c>true</c> if <paramref name="lhs"/> is equal to <paramref name="rhs"/>.</returns>
  82. public static bool operator ==(ARParticipantsChangedEventArgs lhs, ARParticipantsChangedEventArgs rhs) => lhs.Equals(rhs);
  83. /// <summary>
  84. /// Tests for inequality. Same as <c>!</c><see cref="Equals(ARParticipantsChangedEventArgs)"/>.
  85. /// </summary>
  86. /// <param name="lhs">The left-hand side of the comparison.</param>
  87. /// <param name="rhs">The right-hand side of the comparison.</param>
  88. /// <returns><c>true</c> if <paramref name="lhs"/> is not equal to <paramref name="rhs"/>.</returns>
  89. public static bool operator !=(ARParticipantsChangedEventArgs lhs, ARParticipantsChangedEventArgs rhs) => !lhs.Equals(rhs);
  90. }
  91. }