Advertisement
Guest User

Deserialize

a guest
Feb 18th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.02 KB | None | 0 0
  1.      public void Deserialize(byte[] buffer)
  2.         {
  3.             var myPacket = new byte[buffer.Length - 8];
  4.             for (int i = 0; i < myPacket.Length; i++)
  5.             {
  6.                 myPacket[i] = buffer[i];
  7.             }
  8.             using (var memoryStream = new System.IO.MemoryStream(myPacket))
  9.             {
  10.                 Info = Serializer.DeserializeWithLengthPrefix<MsgActionProto>(memoryStream, PrefixStyle.Fixed32);
  11.             }
  12.             ID = Info.ID;
  13.             UID = Info.UID;
  14.             TimeStamp = new Time32(Info.TimeStamp);
  15.             NpcID = Info.NpcID;
  16.             Facing = Info.Facing;
  17.             PositionX = Info.PositionX;
  18.         }
  19.         public byte[] ToArray()
  20.         {
  21.             Info = new DataProto()
  22.             {
  23.                   ID = ID, UID = UID, Facing = Facing,
  24.                   TimeStamp = (uint)TimeStamp.Value,
  25.                   PositionX = PositionX,
  26.                
  27.             };
  28.             return Kernel.FinalizeProtoBuf(Info, 10010);
  29.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement