Messages.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. using System;
  2. using UnityEngine;
  3. namespace Mirror
  4. {
  5. public struct ReadyMessage : NetworkMessage {}
  6. public struct NotReadyMessage : NetworkMessage {}
  7. public struct AddPlayerMessage : NetworkMessage {}
  8. public struct SceneMessage : NetworkMessage
  9. {
  10. public string sceneName;
  11. // Normal = 0, LoadAdditive = 1, UnloadAdditive = 2
  12. public SceneOperation sceneOperation;
  13. public bool customHandling;
  14. }
  15. public enum SceneOperation : byte
  16. {
  17. Normal,
  18. LoadAdditive,
  19. UnloadAdditive
  20. }
  21. public struct CommandMessage : NetworkMessage
  22. {
  23. public uint netId;
  24. public byte componentIndex;
  25. public int functionHash;
  26. // the parameters for the Cmd function
  27. // -> ArraySegment to avoid unnecessary allocations
  28. public ArraySegment<byte> payload;
  29. }
  30. public struct RpcMessage : NetworkMessage
  31. {
  32. public uint netId;
  33. public byte componentIndex;
  34. public int functionHash;
  35. // the parameters for the Cmd function
  36. // -> ArraySegment to avoid unnecessary allocations
  37. public ArraySegment<byte> payload;
  38. }
  39. public struct SpawnMessage : NetworkMessage
  40. {
  41. // netId of new or existing object
  42. public uint netId;
  43. public bool isLocalPlayer;
  44. // Sets hasAuthority on the spawned object
  45. public bool isOwner;
  46. public ulong sceneId;
  47. // If sceneId != 0 then it is used instead of assetId
  48. public Guid assetId;
  49. // Local position
  50. public Vector3 position;
  51. // Local rotation
  52. public Quaternion rotation;
  53. // Local scale
  54. public Vector3 scale;
  55. // serialized component data
  56. // ArraySegment to avoid unnecessary allocations
  57. public ArraySegment<byte> payload;
  58. }
  59. public struct ChangeOwnerMessage : NetworkMessage
  60. {
  61. public uint netId;
  62. public bool isOwner;
  63. }
  64. public struct ObjectSpawnStartedMessage : NetworkMessage {}
  65. public struct ObjectSpawnFinishedMessage : NetworkMessage {}
  66. public struct ObjectDestroyMessage : NetworkMessage
  67. {
  68. public uint netId;
  69. }
  70. public struct ObjectHideMessage : NetworkMessage
  71. {
  72. public uint netId;
  73. }
  74. public struct EntityStateMessage : NetworkMessage
  75. {
  76. public uint netId;
  77. // the serialized component data
  78. // -> ArraySegment to avoid unnecessary allocations
  79. public ArraySegment<byte> payload;
  80. }
  81. // A client sends this message to the server
  82. // to calculate RTT and synchronize time
  83. public struct NetworkPingMessage : NetworkMessage
  84. {
  85. public double clientTime;
  86. public NetworkPingMessage(double value)
  87. {
  88. clientTime = value;
  89. }
  90. }
  91. // The server responds with this message
  92. // The client can use this to calculate RTT and sync time
  93. public struct NetworkPongMessage : NetworkMessage
  94. {
  95. public double clientTime;
  96. public double serverTime;
  97. }
  98. }