public static void Serialize(Stream stream, RespawnInformation instance)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

            if (instance.spawnOptions != null)
            {
                for (int i = 0; i < instance.spawnOptions.Count; i++)
                {
                    RespawnInformation.SpawnOptions item = instance.spawnOptions[i];
                    stream.WriteByte(10);
                    memoryStream.SetLength((long)0);
                    RespawnInformation.SpawnOptions.Serialize(memoryStream, item);
                    uint length = (uint)memoryStream.Length;
                    ProtocolParser.WriteUInt32(stream, length);
                    stream.Write(memoryStream.GetBuffer(), 0, (int)length);
                }
            }
            if (instance.previousLife != null)
            {
                stream.WriteByte(18);
                memoryStream.SetLength((long)0);
                PlayerLifeStory.Serialize(memoryStream, instance.previousLife);
                uint num = (uint)memoryStream.Length;
                ProtocolParser.WriteUInt32(stream, num);
                stream.Write(memoryStream.GetBuffer(), 0, (int)num);
            }
            stream.WriteByte(24);
            ProtocolParser.WriteBool(stream, instance.fadeIn);
            Pool.FreeMemoryStream(ref memoryStream);
        }
 public virtual void WriteToStreamDelta(Stream stream, PlayerLifeStory previous)
 {
     if (previous == null)
     {
         PlayerLifeStory.Serialize(stream, this);
         return;
     }
     PlayerLifeStory.SerializeDelta(stream, this, previous);
 }
 public static byte[] SerializeToBytes(PlayerLifeStory instance)
 {
     byte[] array;
     using (MemoryStream memoryStream = new MemoryStream())
     {
         PlayerLifeStory.Serialize(memoryStream, instance);
         array = memoryStream.ToArray();
     }
     return(array);
 }
Пример #4
0
        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)
 {
     PlayerLifeStory.Serialize(stream, this);
 }
 public void ToProto(Stream stream)
 {
     PlayerLifeStory.Serialize(stream, this);
 }