NetworkBehaviourSyncVar.cs 929 B

123456789101112131415161718192021222324252627282930313233
  1. using System;
  2. namespace Mirror
  3. {
  4. // backing field for sync NetworkBehaviour
  5. public struct NetworkBehaviourSyncVar : IEquatable<NetworkBehaviourSyncVar>
  6. {
  7. public uint netId;
  8. // limited to 255 behaviours per identity
  9. public byte componentIndex;
  10. public NetworkBehaviourSyncVar(uint netId, int componentIndex) : this()
  11. {
  12. this.netId = netId;
  13. this.componentIndex = (byte)componentIndex;
  14. }
  15. public bool Equals(NetworkBehaviourSyncVar other)
  16. {
  17. return other.netId == netId && other.componentIndex == componentIndex;
  18. }
  19. public bool Equals(uint netId, int componentIndex)
  20. {
  21. return this.netId == netId && this.componentIndex == componentIndex;
  22. }
  23. public override string ToString()
  24. {
  25. return $"[netId:{netId} compIndex:{componentIndex}]";
  26. }
  27. }
  28. }