Example #1
0
        public void CreatePayload(byte[] buffer)
        {
            Raw = buffer;
            var shift = 0;

            Header  = NetworkBinary.Deserialize <string>(Raw, ref shift);
            Payload = Raw.Skip(shift).ToArray();
        }
Example #2
0
        public static Color Deserialize(byte[] array)
        {
            var shift = 0;
            var r     = NetworkBinary.Deserialize <float>(array, ref shift);
            var g     = NetworkBinary.Deserialize <float>(array, ref shift);
            var b     = NetworkBinary.Deserialize <float>(array, ref shift);
            var a     = NetworkBinary.Deserialize <float>(array, ref shift);

            return(new Color(r, g, b, a));
        }
Example #3
0
        public static byte[] Serialize(Color color)
        {
            var arr = new List <byte>();

            arr.AddRange(NetworkBinary.Serialize(color.r));
            arr.AddRange(NetworkBinary.Serialize(color.g));
            arr.AddRange(NetworkBinary.Serialize(color.b));
            arr.AddRange(NetworkBinary.Serialize(color.a));

            return(arr.ToArray());
        }
Example #4
0
        public override void Deserialize(byte[] array)
        {
            var shift = 0;
            var idMsg = NetworkBinary.Deserialize <ObjectSpawnMessage>(array, ref shift);

            Id       = idMsg.Id;
            AssetId  = idMsg.AssetId;
            SceneId  = idMsg.SceneId;
            Position = idMsg.Position;
            Rotation = idMsg.Rotation;
        }
Example #5
0
        public void CreateRaw(byte[] array, string header)
        {
            Payload = array;
            Header  = header;

            var headerByte = NetworkBinary.Serialize(Header);

            var copyPayload = Payload != null;
            var rawLength   = copyPayload ? Payload.Length + headerByte.Length : headerByte.Length;

            Raw = new byte[rawLength];
            headerByte.CopyTo(Raw, 0);
            if (copyPayload)
            {
                Payload.CopyTo(Raw, headerByte.Length);
            }
        }
Example #6
0
 public override byte[] Serialize()
 {
     return(NetworkBinary.Serialize(this));
 }