public virtual void WriteToStreamDelta(Stream stream, PlayerInventory previous) { if (previous == null) { PlayerInventory.Serialize(stream, this); return; } PlayerInventory.SerializeDelta(stream, this, previous); }
public static byte[] SerializeToBytes(PlayerInventory instance) { byte[] array; using (MemoryStream memoryStream = new MemoryStream()) { PlayerInventory.Serialize(memoryStream, instance); array = memoryStream.ToArray(); } return(array); }
public static void Serialize(Stream stream, BasePlayer instance) { MemoryStream memoryStream = Pool.Get <MemoryStream>(); if (instance.name != null) { stream.WriteByte(10); ProtocolParser.WriteString(stream, instance.name); } stream.WriteByte(16); ProtocolParser.WriteUInt64(stream, instance.userid); if (instance.inventory != null) { stream.WriteByte(26); memoryStream.SetLength((long)0); PlayerInventory.Serialize(memoryStream, instance.inventory); uint length = (uint)memoryStream.Length; ProtocolParser.WriteUInt32(stream, length); stream.Write(memoryStream.GetBuffer(), 0, (int)length); } if (instance.metabolism != null) { stream.WriteByte(34); memoryStream.SetLength((long)0); PlayerMetabolism.Serialize(memoryStream, instance.metabolism); uint num = (uint)memoryStream.Length; ProtocolParser.WriteUInt32(stream, num); stream.Write(memoryStream.GetBuffer(), 0, (int)num); } if (instance.modelState != null) { stream.WriteByte(50); memoryStream.SetLength((long)0); ModelState.Serialize(memoryStream, instance.modelState); uint length1 = (uint)memoryStream.Length; ProtocolParser.WriteUInt32(stream, length1); stream.Write(memoryStream.GetBuffer(), 0, (int)length1); } stream.WriteByte(56); ProtocolParser.WriteUInt64(stream, (ulong)instance.playerFlags); stream.WriteByte(64); ProtocolParser.WriteUInt32(stream, instance.heldEntity); stream.WriteByte(77); ProtocolParser.WriteSingle(stream, instance.health); if (instance.persistantData != null) { stream.WriteByte(82); memoryStream.SetLength((long)0); PersistantPlayer.Serialize(memoryStream, instance.persistantData); uint num1 = (uint)memoryStream.Length; ProtocolParser.WriteUInt32(stream, num1); stream.Write(memoryStream.GetBuffer(), 0, (int)num1); } stream.WriteByte(125); ProtocolParser.WriteSingle(stream, instance.skinCol); stream.WriteByte(133); stream.WriteByte(1); ProtocolParser.WriteSingle(stream, instance.skinTex); stream.WriteByte(141); stream.WriteByte(1); ProtocolParser.WriteSingle(stream, instance.skinMesh); if (instance.currentLife != null) { stream.WriteByte(162); stream.WriteByte(1); memoryStream.SetLength((long)0); PlayerLifeStory.Serialize(memoryStream, instance.currentLife); uint length2 = (uint)memoryStream.Length; ProtocolParser.WriteUInt32(stream, length2); stream.Write(memoryStream.GetBuffer(), 0, (int)length2); } if (instance.previousLife != null) { stream.WriteByte(170); stream.WriteByte(1); memoryStream.SetLength((long)0); PlayerLifeStory.Serialize(memoryStream, instance.previousLife); uint num2 = (uint)memoryStream.Length; ProtocolParser.WriteUInt32(stream, num2); stream.Write(memoryStream.GetBuffer(), 0, (int)num2); } stream.WriteByte(176); stream.WriteByte(1); ProtocolParser.WriteUInt32(stream, instance.mounted); stream.WriteByte(184); stream.WriteByte(1); ProtocolParser.WriteUInt64(stream, instance.currentTeam); Pool.FreeMemoryStream(ref memoryStream); }
public virtual void WriteToStream(Stream stream) { PlayerInventory.Serialize(stream, this); }
public void ToProto(Stream stream) { PlayerInventory.Serialize(stream, this); }