Exemple #1
0
        public static void Serialize(Stream stream, PlayerInventory instance)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

            if (instance.invMain != null)
            {
                stream.WriteByte(10);
                memoryStream.SetLength((long)0);
                ItemContainer.Serialize(memoryStream, instance.invMain);
                uint length = (uint)memoryStream.Length;
                ProtocolParser.WriteUInt32(stream, length);
                stream.Write(memoryStream.GetBuffer(), 0, (int)length);
            }
            if (instance.invBelt != null)
            {
                stream.WriteByte(18);
                memoryStream.SetLength((long)0);
                ItemContainer.Serialize(memoryStream, instance.invBelt);
                uint num = (uint)memoryStream.Length;
                ProtocolParser.WriteUInt32(stream, num);
                stream.Write(memoryStream.GetBuffer(), 0, (int)num);
            }
            if (instance.invWear != null)
            {
                stream.WriteByte(26);
                memoryStream.SetLength((long)0);
                ItemContainer.Serialize(memoryStream, instance.invWear);
                uint length1 = (uint)memoryStream.Length;
                ProtocolParser.WriteUInt32(stream, length1);
                stream.Write(memoryStream.GetBuffer(), 0, (int)length1);
            }
            Pool.FreeMemoryStream(ref memoryStream);
        }
Exemple #2
0
 public virtual void WriteToStreamDelta(Stream stream, ItemContainer previous)
 {
     if (previous == null)
     {
         ItemContainer.Serialize(stream, this);
         return;
     }
     ItemContainer.SerializeDelta(stream, this, previous);
 }
Exemple #3
0
 public static byte[] SerializeToBytes(ItemContainer instance)
 {
     byte[] array;
     using (MemoryStream memoryStream = new MemoryStream())
     {
         ItemContainer.Serialize(memoryStream, instance);
         array = memoryStream.ToArray();
     }
     return(array);
 }
        public static void Serialize(Stream stream, Loot instance)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

            if (instance.contents != null)
            {
                stream.WriteByte(10);
                memoryStream.SetLength((long)0);
                ItemContainer.Serialize(memoryStream, instance.contents);
                uint length = (uint)memoryStream.Length;
                ProtocolParser.WriteUInt32(stream, length);
                stream.Write(memoryStream.GetBuffer(), 0, (int)length);
            }
            Pool.FreeMemoryStream(ref memoryStream);
        }
            public static void Serialize(Stream stream, LootableCorpse.Private instance)
            {
                MemoryStream memoryStream = Pool.Get <MemoryStream>();

                if (instance.container != null)
                {
                    for (int i = 0; i < instance.container.Count; i++)
                    {
                        ItemContainer item = instance.container[i];
                        stream.WriteByte(10);
                        memoryStream.SetLength((long)0);
                        ItemContainer.Serialize(memoryStream, item);
                        uint length = (uint)memoryStream.Length;
                        ProtocolParser.WriteUInt32(stream, length);
                        stream.Write(memoryStream.GetBuffer(), 0, (int)length);
                    }
                }
                Pool.FreeMemoryStream(ref memoryStream);
            }
        public static void Serialize(Stream stream, PlayerUpdateLoot instance)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

            stream.WriteByte(8);
            ProtocolParser.WriteUInt32(stream, instance.itemID);
            stream.WriteByte(16);
            ProtocolParser.WriteUInt32(stream, instance.entityID);
            if (instance.containers != null)
            {
                for (int i = 0; i < instance.containers.Count; i++)
                {
                    ItemContainer item = instance.containers[i];
                    stream.WriteByte(26);
                    memoryStream.SetLength((long)0);
                    ItemContainer.Serialize(memoryStream, item);
                    uint length = (uint)memoryStream.Length;
                    ProtocolParser.WriteUInt32(stream, length);
                    stream.Write(memoryStream.GetBuffer(), 0, (int)length);
                }
            }
            Pool.FreeMemoryStream(ref memoryStream);
        }
Exemple #7
0
        public static void Serialize(Stream stream, ResourceExtractor instance)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

            if (instance.fuelContents != null)
            {
                stream.WriteByte(10);
                memoryStream.SetLength((long)0);
                ItemContainer.Serialize(memoryStream, instance.fuelContents);
                uint length = (uint)memoryStream.Length;
                ProtocolParser.WriteUInt32(stream, length);
                stream.Write(memoryStream.GetBuffer(), 0, (int)length);
            }
            if (instance.outputContents != null)
            {
                stream.WriteByte(18);
                memoryStream.SetLength((long)0);
                ItemContainer.Serialize(memoryStream, instance.outputContents);
                uint num = (uint)memoryStream.Length;
                ProtocolParser.WriteUInt32(stream, num);
                stream.Write(memoryStream.GetBuffer(), 0, (int)num);
            }
            Pool.FreeMemoryStream(ref memoryStream);
        }
Exemple #8
0
 public virtual void WriteToStream(Stream stream)
 {
     ItemContainer.Serialize(stream, this);
 }
Exemple #9
0
 public void ToProto(Stream stream)
 {
     ItemContainer.Serialize(stream, this);
 }