Messages.cs
27.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
using System;
using System.Collections.Generic;
#pragma warning disable 618
namespace UnityEngine.Networking
{
/// <summary>
/// Network message classes should be derived from this class. These message classes can then be sent using the various Send functions of NetworkConnection, NetworkClient and NetworkServer.
/// <para>Public data fields of classes derived from MessageBase will be automatically serialized with the class. The virtual methods Serialize and Deserialize may be implemented by developers for precise control, but if they are not implemented, then implementations will be generated for them.</para>
/// <para><b>Note :</b> Unity uses its own network serialization system. It doesn't support the NonSerialized attribute. Instead, use private variables.</para>
/// <para>In the example below, the methods have implementations, but if those methods were not implemented, the message would still be usable.</para>
/// <code>
/// using UnityEngine;
/// using UnityEngine.Networking;
///
/// class SpawnMessage : MessageBase
/// {
/// public uint netId;
/// public NetworkHash128 assetId;
/// public Vector3 position;
/// public byte[] payload;
///
/// // This method would be generated
/// public override void Deserialize(NetworkReader reader)
/// {
/// netId = reader.ReadPackedUInt32();
/// assetId = reader.ReadNetworkHash128();
/// position = reader.ReadVector3();
/// payload = reader.ReadBytesAndSize();
/// }
///
/// // This method would be generated
/// public override void Serialize(NetworkWriter writer)
/// {
/// writer.WritePackedUInt32(netId);
/// writer.Write(assetId);
/// writer.Write(position);
/// writer.WriteBytesFull(payload);
/// }
/// }
/// </code>
/// </summary>
// This can't be an interface because users don't need to implement the
// serialization functions, we'll code generate it for them when they omit it.
[Obsolete("The high level API classes are deprecated and will be removed in the future.")]
public abstract class MessageBase
{
/// <summary>
/// This method is used to populate a message object from a NetworkReader stream.
/// <para>Developers may implement this method for precise control of serialization, but they do no have to. An implemenation of this method will be generated for derived classes.</para>
/// </summary>
/// <param name="reader">Stream to read from.</param>
// De-serialize the contents of the reader into this message
public virtual void Deserialize(NetworkReader reader) {}
/// <summary>
/// The method is used to populate a NetworkWriter stream from a message object.
/// <para>Developers may implement this method for precise control of serialization, but they do no have to. An implemenation of this method will be generated for derived classes.</para>
/// </summary>
/// <param name="writer">Stream to write to.</param>
// Serialize the contents of this message into the writer
public virtual void Serialize(NetworkWriter writer) {}
}
}
namespace UnityEngine.Networking.NetworkSystem
{
// ---------- General Typed Messages -------------------
/// <summary>
/// This is a utility class for simple network messages that contain only a string.
/// <para>This example sends a message with the name of the scene.</para>
/// <code>
/// using UnityEngine;
/// using UnityEngine.Networking;
/// using UnityEngine.Networking.NetworkSystem;
///
/// public class Test
/// {
/// void SendSceneName(string sceneName)
/// {
/// var msg = new StringMessage(sceneName);
/// NetworkServer.SendToAll(MsgType.Scene, msg);
/// }
/// }
/// </code>
/// </summary>
[Obsolete("The high level API classes are deprecated and will be removed in the future.")]
public class StringMessage : MessageBase
{
/// <summary>
/// The string that will be serialized.
/// </summary>
public string value;
public StringMessage()
{
}
public StringMessage(string v)
{
value = v;
}
public override void Deserialize(NetworkReader reader)
{
value = reader.ReadString();
}
public override void Serialize(NetworkWriter writer)
{
writer.Write(value);
}
}
/// <summary>
/// A utility class to send simple network messages that only contain an integer.
/// <code>
/// using UnityEngine;
/// using UnityEngine.Networking;
/// using UnityEngine.Networking.NetworkSystem;
///
/// public class Test
/// {
/// void SendValue(int value)
/// {
/// var msg = new IntegerMessage(value);
/// NetworkServer.SendToAll(MsgType.Scene, msg);
/// }
/// }
/// </code>
/// </summary>
[Obsolete("The high level API classes are deprecated and will be removed in the future.")]
public class IntegerMessage : MessageBase
{
/// <summary>
/// The integer value to serialize.
/// </summary>
public int value;
public IntegerMessage()
{
}
public IntegerMessage(int v)
{
value = v;
}
public override void Deserialize(NetworkReader reader)
{
value = (int)reader.ReadPackedUInt32();
}
public override void Serialize(NetworkWriter writer)
{
writer.WritePackedUInt32((uint)value);
}
}
/// <summary>
/// A utility class to send a network message with no contents.
/// <code>
/// using UnityEngine;
/// using UnityEngine.Networking;
/// using UnityEngine.Networking.NetworkSystem;
///
/// public class Test
/// {
/// void SendNotification()
/// {
/// var msg = new EmptyMessage();
/// NetworkServer.SendToAll(667, msg);
/// }
/// }
/// </code>
/// </summary>
[Obsolete("The high level API classes are deprecated and will be removed in the future.")]
public class EmptyMessage : MessageBase
{
public override void Deserialize(NetworkReader reader)
{
}
public override void Serialize(NetworkWriter writer)
{
}
}
// ---------- Public System Messages -------------------
/// <summary>
/// This is passed to handler functions registered for the SYSTEM_ERROR built-in message.
/// </summary>
[Obsolete("The high level API classes are deprecated and will be removed in the future.")]
public class ErrorMessage : MessageBase
{
/// <summary>
/// The error code.
/// <para>This is a value from the UNETError enumeration.</para>
/// </summary>
public int errorCode;
public override void Deserialize(NetworkReader reader)
{
errorCode = reader.ReadUInt16();
}
public override void Serialize(NetworkWriter writer)
{
writer.Write((ushort)errorCode);
}
}
/// <summary>
/// This is passed to handler funtions registered for the SYSTEM_READY built-in message.
/// </summary>
[Obsolete("The high level API classes are deprecated and will be removed in the future.")]
public class ReadyMessage : EmptyMessage
{
}
/// <summary>
/// This is passed to handler funtions registered for the SYSTEM_NOT_READY built-in message.
/// </summary>
[Obsolete("The high level API classes are deprecated and will be removed in the future.")]
public class NotReadyMessage : EmptyMessage
{
}
/// <summary>
/// This is passed to handler funtions registered for the AddPlayer built-in message.
/// </summary>
[Obsolete("The high level API classes are deprecated and will be removed in the future.")]
public class AddPlayerMessage : MessageBase
{
/// <summary>
/// The playerId of the new player.
/// <para>This is specified by the client when they call NetworkClient.AddPlayer(someId).</para>
/// <para>The HLAPI treats players and clients as separate GameObjects. In most cases, there is a single player for each client, but in some situations (for example, when there are multiple controllers connected to a console system) there might be multiple player GameObjects for a single connection. When there are multiple players for a single connection, use the playerControllerId property to tell them apart. This is an identifier that is scoped to the connection, so that it maps to the id of the controller associated with the player on that client.</para>
/// </summary>
public short playerControllerId;
/// <summary>
/// The size of the extra message data included in the AddPlayerMessage.
/// </summary>
public int msgSize;
/// <summary>
/// The extra message data included in the AddPlayerMessage.
/// </summary>
public byte[] msgData;
public override void Deserialize(NetworkReader reader)
{
playerControllerId = (short)reader.ReadUInt16();
msgData = reader.ReadBytesAndSize();
if (msgData == null)
{
msgSize = 0;
}
else
{
msgSize = msgData.Length;
}
}
public override void Serialize(NetworkWriter writer)
{
writer.Write((ushort)playerControllerId);
writer.WriteBytesAndSize(msgData, msgSize);
}
}
/// <summary>
/// This is passed to handler funtions registered for the SYSTEM_REMOVE_PLAYER built-in message.
/// </summary>
[Obsolete("The high level API classes are deprecated and will be removed in the future.")]
public class RemovePlayerMessage : MessageBase
{
/// <summary>
/// The player ID of the player GameObject which should be removed.
/// <para>This is specified by the client when they call NetworkClient.RemovePlayer(someId).</para>
/// <para>The HLAPI treats players and clients as separate GameObjects. In most cases, there is a single player for each client, but in some situations (for example, when there are multiple controllers connected to a console system) there might be multiple player GameObjects for a single connection. When there are multiple players for a single connection, use the playerControllerId property to tell them apart. This is an identifier that is scoped to the connection, so that it maps to the id of the controller associated with the player on that client.</para>
/// </summary>
public short playerControllerId;
public override void Deserialize(NetworkReader reader)
{
playerControllerId = (short)reader.ReadUInt16();
}
public override void Serialize(NetworkWriter writer)
{
writer.Write((ushort)playerControllerId);
}
}
/// <summary>
/// Information about a change in authority of a non-player in the same network game.
/// <para>This information is cached by clients and used during host-migration.</para>
/// </summary>
[Obsolete("The high level API classes are deprecated and will be removed in the future.")]
public class PeerAuthorityMessage : MessageBase
{
/// <summary>
/// The connection Id (on the server) of the peer whose authority is changing for the object.
/// </summary>
public int connectionId;
/// <summary>
/// The network id of the object whose authority state changed.
/// </summary>
public NetworkInstanceId netId;
/// <summary>
/// The new state of authority for the object referenced by this message.
/// </summary>
public bool authorityState;
public override void Deserialize(NetworkReader reader)
{
connectionId = (int)reader.ReadPackedUInt32();
netId = reader.ReadNetworkId();
authorityState = reader.ReadBoolean();
}
public override void Serialize(NetworkWriter writer)
{
writer.WritePackedUInt32((uint)connectionId);
writer.Write(netId);
writer.Write(authorityState);
}
}
/// <summary>
/// A structure used to identify player object on other peers for host migration.
/// </summary>
[Obsolete("The high level API classes are deprecated and will be removed in the future.")]
public struct PeerInfoPlayer
{
/// <summary>
/// The networkId of the player object.
/// </summary>
public NetworkInstanceId netId;
/// <summary>
/// The playerControllerId of the player GameObject.
/// <para>The HLAPI treats players and clients as separate GameObjects. In most cases, there is a single player for each client, but in some situations (for example, when there are multiple controllers connected to a console system) there might be multiple player GameObjects for a single connection. When there are multiple players for a single connection, use the playerControllerId property to tell them apart. This is an identifier that is scoped to the connection, so that it maps to the id of the controller associated with the player on that client.</para>
/// </summary>
public short playerControllerId;
}
/// <summary>
/// Information about another participant in the same network game.
/// <para>This information is cached by clients and used during host-migration.</para>
/// </summary>
[Obsolete("The high level API classes are deprecated and will be removed in the future.")]
public class PeerInfoMessage : MessageBase
{
/// <summary>
/// The id of the NetworkConnection associated with the peer.
/// </summary>
public int connectionId;
/// <summary>
/// The IP address of the peer.
/// </summary>
public string address;
/// <summary>
/// The network port being used by the peer.
/// </summary>
public int port;
/// <summary>
/// True if this peer is the host of the network game.
/// </summary>
public bool isHost;
/// <summary>
/// True if the peer if the same as the current client.
/// </summary>
public bool isYou;
/// <summary>
/// The players for this peer.
/// </summary>
public PeerInfoPlayer[] playerIds;
public override void Deserialize(NetworkReader reader)
{
connectionId = (int)reader.ReadPackedUInt32();
address = reader.ReadString();
port = (int)reader.ReadPackedUInt32();
isHost = reader.ReadBoolean();
isYou = reader.ReadBoolean();
uint numPlayers = reader.ReadPackedUInt32();
if (numPlayers > 0)
{
List<PeerInfoPlayer> ids = new List<PeerInfoPlayer>();
for (uint i = 0; i < numPlayers; i++)
{
PeerInfoPlayer info;
info.netId = reader.ReadNetworkId();
info.playerControllerId = (short)reader.ReadPackedUInt32();
ids.Add(info);
}
playerIds = ids.ToArray();
}
}
public override void Serialize(NetworkWriter writer)
{
writer.WritePackedUInt32((uint)connectionId);
writer.Write(address);
writer.WritePackedUInt32((uint)port);
writer.Write(isHost);
writer.Write(isYou);
if (playerIds == null)
{
writer.WritePackedUInt32(0);
}
else
{
writer.WritePackedUInt32((uint)playerIds.Length);
for (int i = 0; i < playerIds.Length; i++)
{
writer.Write(playerIds[i].netId);
writer.WritePackedUInt32((uint)playerIds[i].playerControllerId);
}
}
}
public override string ToString()
{
return "PeerInfo conn:" + connectionId + " addr:" + address + ":" + port + " host:" + isHost + " isYou:" + isYou;
}
}
/// <summary>
/// Internal UNET message for sending information about network peers to clients.
/// </summary>
[Obsolete("The high level API classes are deprecated and will be removed in the future.")]
public class PeerListMessage : MessageBase
{
/// <summary>
/// The list of participants in a networked game.
/// </summary>
public PeerInfoMessage[] peers;
/// <summary>
/// The connectionId of this client on the old host.
/// </summary>
public int oldServerConnectionId;
public override void Deserialize(NetworkReader reader)
{
oldServerConnectionId = (int)reader.ReadPackedUInt32();
int numPeers = reader.ReadUInt16();
peers = new PeerInfoMessage[numPeers];
for (int i = 0; i < peers.Length; ++i)
{
var peerInfo = new PeerInfoMessage();
peerInfo.Deserialize(reader);
peers[i] = peerInfo;
}
}
public override void Serialize(NetworkWriter writer)
{
writer.WritePackedUInt32((uint)oldServerConnectionId);
writer.Write((ushort)peers.Length);
for (int i = 0; i < peers.Length; i++)
{
peers[i].Serialize(writer);
}
}
}
/// <summary>
/// This network message is used when a client reconnect to the new host of a game.
/// </summary>
[Obsolete("The high level API classes are deprecated and will be removed in the future.")]
public class ReconnectMessage : MessageBase
{
/// <summary>
/// This client's connectionId on the old host.
/// </summary>
public int oldConnectionId;
/// <summary>
/// The playerControllerId of the player that is rejoining.
/// <para>The HLAPI treats players and clients as separate GameObjects. In most cases, there is a single player for each client, but in some situations (for example, when there are multiple controllers connected to a console system) there might be multiple player GameObjects for a single connection. When there are multiple players for a single connection, use the playerControllerId property to tell them apart. This is an identifier that is scoped to the connection, so that it maps to the id of the controller associated with the player on that client.</para>
/// </summary>
public short playerControllerId;
/// <summary>
/// The networkId of this player on the old host.
/// </summary>
public NetworkInstanceId netId;
/// <summary>
/// Size of additional data.
/// </summary>
public int msgSize;
/// <summary>
/// Additional data.
/// </summary>
public byte[] msgData;
public override void Deserialize(NetworkReader reader)
{
oldConnectionId = (int)reader.ReadPackedUInt32();
playerControllerId = (short)reader.ReadPackedUInt32();
netId = reader.ReadNetworkId();
msgData = reader.ReadBytesAndSize();
msgSize = msgData.Length;
}
public override void Serialize(NetworkWriter writer)
{
writer.WritePackedUInt32((uint)oldConnectionId);
writer.WritePackedUInt32((uint)playerControllerId);
writer.Write(netId);
writer.WriteBytesAndSize(msgData, msgSize);
}
}
// ---------- System Messages requried for code gen path -------------------
/* These are not used directly but manually serialized, these are here for reference.
public struct CommandMessage
{
public int cmdHash;
public string cmdName;
public byte[] payload;
}
public struct RPCMessage
{
public NetworkId netId;
public int cmdHash;
public byte[] payload;
}
public struct SyncEventMessage
{
public NetworkId netId;
public int cmdHash;
public byte[] payload;
}
internal class SyncListMessage<T> where T: struct
{
public NetworkId netId;
public int cmdHash;
public byte operation;
public int itemIndex;
public T item;
}
*/
// ---------- Internal System Messages -------------------
class ObjectSpawnMessage : MessageBase
{
public NetworkInstanceId netId;
public NetworkHash128 assetId;
public Vector3 position;
public byte[] payload;
public Quaternion rotation;
public override void Deserialize(NetworkReader reader)
{
netId = reader.ReadNetworkId();
assetId = reader.ReadNetworkHash128();
position = reader.ReadVector3();
payload = reader.ReadBytesAndSize();
uint extraPayloadSize = sizeof(uint) * 4;
if ((reader.Length - reader.Position) >= extraPayloadSize)
{
rotation = reader.ReadQuaternion();
}
}
public override void Serialize(NetworkWriter writer)
{
writer.Write(netId);
writer.Write(assetId);
writer.Write(position);
writer.WriteBytesFull(payload);
writer.Write(rotation);
}
}
class ObjectSpawnSceneMessage : MessageBase
{
public NetworkInstanceId netId;
public NetworkSceneId sceneId;
public Vector3 position;
public byte[] payload;
public override void Deserialize(NetworkReader reader)
{
netId = reader.ReadNetworkId();
sceneId = reader.ReadSceneId();
position = reader.ReadVector3();
payload = reader.ReadBytesAndSize();
}
public override void Serialize(NetworkWriter writer)
{
writer.Write(netId);
writer.Write(sceneId);
writer.Write(position);
writer.WriteBytesFull(payload);
}
}
class ObjectSpawnFinishedMessage : MessageBase
{
public uint state;
public override void Deserialize(NetworkReader reader)
{
state = reader.ReadPackedUInt32();
}
public override void Serialize(NetworkWriter writer)
{
writer.WritePackedUInt32(state);
}
}
class ObjectDestroyMessage : MessageBase
{
public NetworkInstanceId netId;
public override void Deserialize(NetworkReader reader)
{
netId = reader.ReadNetworkId();
}
public override void Serialize(NetworkWriter writer)
{
writer.Write(netId);
}
}
class OwnerMessage : MessageBase
{
public NetworkInstanceId netId;
public short playerControllerId;
public override void Deserialize(NetworkReader reader)
{
netId = reader.ReadNetworkId();
playerControllerId = (short)reader.ReadPackedUInt32();
}
public override void Serialize(NetworkWriter writer)
{
writer.Write(netId);
writer.WritePackedUInt32((uint)playerControllerId);
}
}
class ClientAuthorityMessage : MessageBase
{
public NetworkInstanceId netId;
public bool authority;
public override void Deserialize(NetworkReader reader)
{
netId = reader.ReadNetworkId();
authority = reader.ReadBoolean();
}
public override void Serialize(NetworkWriter writer)
{
writer.Write(netId);
writer.Write(authority);
}
}
class OverrideTransformMessage : MessageBase
{
public NetworkInstanceId netId;
public byte[] payload;
public bool teleport;
public int time;
public override void Deserialize(NetworkReader reader)
{
netId = reader.ReadNetworkId();
payload = reader.ReadBytesAndSize();
teleport = reader.ReadBoolean();
time = (int)reader.ReadPackedUInt32();
}
public override void Serialize(NetworkWriter writer)
{
writer.Write(netId);
writer.WriteBytesFull(payload);
writer.Write(teleport);
writer.WritePackedUInt32((uint)time);
}
}
class AnimationMessage : MessageBase
{
public NetworkInstanceId netId;
public int stateHash; // if non-zero, then Play() this animation, skipping transitions
public float normalizedTime;
public byte[] parameters;
public override void Deserialize(NetworkReader reader)
{
netId = reader.ReadNetworkId();
stateHash = (int)reader.ReadPackedUInt32();
normalizedTime = reader.ReadSingle();
parameters = reader.ReadBytesAndSize();
}
public override void Serialize(NetworkWriter writer)
{
writer.Write(netId);
writer.WritePackedUInt32((uint)stateHash);
writer.Write(normalizedTime);
if (parameters == null)
writer.WriteBytesAndSize(parameters, 0);
else
writer.WriteBytesAndSize(parameters, parameters.Length);
}
}
class AnimationParametersMessage : MessageBase
{
public NetworkInstanceId netId;
public byte[] parameters;
public override void Deserialize(NetworkReader reader)
{
netId = reader.ReadNetworkId();
parameters = reader.ReadBytesAndSize();
}
public override void Serialize(NetworkWriter writer)
{
writer.Write(netId);
if (parameters == null)
writer.WriteBytesAndSize(parameters, 0);
else
writer.WriteBytesAndSize(parameters, parameters.Length);
}
}
class AnimationTriggerMessage : MessageBase
{
public NetworkInstanceId netId;
public int hash;
public override void Deserialize(NetworkReader reader)
{
netId = reader.ReadNetworkId();
hash = (int)reader.ReadPackedUInt32();
}
public override void Serialize(NetworkWriter writer)
{
writer.Write(netId);
writer.WritePackedUInt32((uint)hash);
}
}
class LobbyReadyToBeginMessage : MessageBase
{
public byte slotId;
public bool readyState;
public override void Deserialize(NetworkReader reader)
{
slotId = reader.ReadByte();
readyState = reader.ReadBoolean();
}
public override void Serialize(NetworkWriter writer)
{
writer.Write(slotId);
writer.Write(readyState);
}
}
struct CRCMessageEntry
{
public string name;
public byte channel;
}
class CRCMessage : MessageBase
{
public CRCMessageEntry[] scripts;
public override void Deserialize(NetworkReader reader)
{
int numScripts = reader.ReadUInt16();
scripts = new CRCMessageEntry[numScripts];
for (int i = 0; i < scripts.Length; ++i)
{
var entry = new CRCMessageEntry();
entry.name = reader.ReadString();
entry.channel = reader.ReadByte();
scripts[i] = entry;
}
}
public override void Serialize(NetworkWriter writer)
{
writer.Write((ushort)scripts.Length);
for (int i = 0; i < scripts.Length; i++)
{
writer.Write(scripts[i].name);
writer.Write(scripts[i].channel);
}
}
}
}
#pragma warning restore 618