OneFrameMessage.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. using System;
  2. using System.Collections.Generic;
  3. namespace ET
  4. {
  5. public partial class OneFrameMessages
  6. {
  7. protected bool Equals(OneFrameMessages other)
  8. {
  9. return this.Frame == other.Frame && Equals(this.Inputs, other.Inputs);
  10. }
  11. public void CopyTo(OneFrameMessages to)
  12. {
  13. to.Frame = this.Frame;
  14. to.Inputs.Clear();
  15. foreach (var kv in this.Inputs)
  16. {
  17. to.Inputs.Add(kv.Key, kv.Value);
  18. }
  19. }
  20. public override bool Equals(object obj)
  21. {
  22. if (ReferenceEquals(null, obj))
  23. {
  24. return false;
  25. }
  26. if (ReferenceEquals(this, obj))
  27. {
  28. return true;
  29. }
  30. if (obj.GetType() != this.GetType())
  31. {
  32. return false;
  33. }
  34. return Equals((OneFrameMessages) obj);
  35. }
  36. public override int GetHashCode()
  37. {
  38. return HashCode.Combine(this.Frame, this.Inputs);
  39. }
  40. public OneFrameMessages()
  41. {
  42. this.Inputs = new Dictionary<long, LSInput>(LSConstValue.MatchCount);
  43. }
  44. public static bool operator==(OneFrameMessages a, OneFrameMessages b)
  45. {
  46. if (a is null || b is null)
  47. {
  48. if (a is null && b is null)
  49. {
  50. return true;
  51. }
  52. return false;
  53. }
  54. if (a.Frame != b.Frame)
  55. {
  56. return false;
  57. }
  58. if (a.Inputs.Count != b.Inputs.Count)
  59. {
  60. return false;
  61. }
  62. foreach (var kv in a.Inputs)
  63. {
  64. if (!b.Inputs.TryGetValue(kv.Key, out LSInput inputInfo))
  65. {
  66. return false;
  67. }
  68. if (kv.Value != inputInfo)
  69. {
  70. return false;
  71. }
  72. }
  73. return true;
  74. }
  75. public static bool operator !=(OneFrameMessages a, OneFrameMessages b)
  76. {
  77. return !(a == b);
  78. }
  79. }
  80. public partial class Room2C_Start
  81. {
  82. public Room2C_Start()
  83. {
  84. this.UnitInfo = new List<LockStepUnitInfo>(LSConstValue.MatchCount);
  85. }
  86. }
  87. }