Beispiel #1
0
        public static DemoHeader DeserializeLength(Stream stream, int length)
        {
            DemoHeader demoHeader = Pool.Get <DemoHeader>();

            DemoHeader.DeserializeLength(stream, length, demoHeader, false);
            return(demoHeader);
        }
Beispiel #2
0
        public static DemoHeader Deserialize(Stream stream)
        {
            DemoHeader demoHeader = Pool.Get <DemoHeader>();

            DemoHeader.Deserialize(stream, demoHeader, false);
            return(demoHeader);
        }
Beispiel #3
0
        public DemoHeader Copy()
        {
            DemoHeader demoHeader = Pool.Get <DemoHeader>();

            this.CopyTo(demoHeader);
            return(demoHeader);
        }
Beispiel #4
0
 public static DemoHeader Deserialize(byte[] buffer, DemoHeader instance, bool isDelta = false)
 {
     using (MemoryStream memoryStream = new MemoryStream(buffer))
     {
         DemoHeader.Deserialize(memoryStream, instance, isDelta);
     }
     return(instance);
 }
Beispiel #5
0
 public virtual void WriteToStreamDelta(Stream stream, DemoHeader previous)
 {
     if (previous == null)
     {
         DemoHeader.Serialize(stream, this);
         return;
     }
     DemoHeader.SerializeDelta(stream, this, previous);
 }
Beispiel #6
0
        public static DemoHeader Deserialize(byte[] buffer)
        {
            DemoHeader demoHeader = Pool.Get <DemoHeader>();

            using (MemoryStream memoryStream = new MemoryStream(buffer))
            {
                DemoHeader.Deserialize(memoryStream, demoHeader, false);
            }
            return(demoHeader);
        }
Beispiel #7
0
 public static byte[] SerializeToBytes(DemoHeader instance)
 {
     byte[] array;
     using (MemoryStream memoryStream = new MemoryStream())
     {
         DemoHeader.Serialize(memoryStream, instance);
         array = memoryStream.ToArray();
     }
     return(array);
 }
Beispiel #8
0
 public void CopyTo(DemoHeader instance)
 {
     instance.version     = this.version;
     instance.level       = this.level;
     instance.levelSeed   = this.levelSeed;
     instance.levelSize   = this.levelSize;
     instance.checksum    = this.checksum;
     instance.localclient = this.localclient;
     instance.position    = this.position;
     instance.rotation    = this.rotation;
     instance.levelUrl    = this.levelUrl;
 }
Beispiel #9
0
 public static void ResetToPool(DemoHeader instance)
 {
     if (!instance.ShouldPool)
     {
         return;
     }
     instance.version     = 0;
     instance.level       = string.Empty;
     instance.levelSeed   = 0;
     instance.levelSize   = 0;
     instance.checksum    = string.Empty;
     instance.localclient = (ulong)0;
     instance.position    = new Vector3();
     instance.rotation    = new Vector3();
     instance.levelUrl    = string.Empty;
     Pool.Free <DemoHeader>(ref instance);
 }
Beispiel #10
0
        public static void Serialize(Stream stream, DemoHeader instance)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

            stream.WriteByte(8);
            ProtocolParser.WriteUInt32(stream, instance.version);
            if (instance.level == null)
            {
                throw new ArgumentNullException("level", "Required by proto specification.");
            }
            stream.WriteByte(18);
            ProtocolParser.WriteString(stream, instance.level);
            stream.WriteByte(24);
            ProtocolParser.WriteUInt32(stream, instance.levelSeed);
            stream.WriteByte(32);
            ProtocolParser.WriteUInt32(stream, instance.levelSize);
            if (instance.checksum != null)
            {
                stream.WriteByte(42);
                ProtocolParser.WriteString(stream, instance.checksum);
            }
            stream.WriteByte(48);
            ProtocolParser.WriteUInt64(stream, instance.localclient);
            stream.WriteByte(58);
            memoryStream.SetLength((long)0);
            Vector3Serialized.Serialize(memoryStream, instance.position);
            uint length = (uint)memoryStream.Length;

            ProtocolParser.WriteUInt32(stream, length);
            stream.Write(memoryStream.GetBuffer(), 0, (int)length);
            stream.WriteByte(66);
            memoryStream.SetLength((long)0);
            Vector3Serialized.Serialize(memoryStream, instance.rotation);
            uint num = (uint)memoryStream.Length;

            ProtocolParser.WriteUInt32(stream, num);
            stream.Write(memoryStream.GetBuffer(), 0, (int)num);
            if (instance.levelUrl == null)
            {
                throw new ArgumentNullException("levelUrl", "Required by proto specification.");
            }
            stream.WriteByte(74);
            ProtocolParser.WriteString(stream, instance.levelUrl);
            Pool.FreeMemoryStream(ref memoryStream);
        }
Beispiel #11
0
 public virtual void WriteToStream(Stream stream)
 {
     DemoHeader.Serialize(stream, this);
 }
Beispiel #12
0
 public byte[] ToProtoBytes()
 {
     return(DemoHeader.SerializeToBytes(this));
 }
Beispiel #13
0
 public void FromProto(Stream stream, bool isDelta = false)
 {
     DemoHeader.Deserialize(stream, this, isDelta);
 }
Beispiel #14
0
 public static void SerializeLengthDelimited(Stream stream, DemoHeader instance)
 {
     byte[] bytes = DemoHeader.SerializeToBytes(instance);
     ProtocolParser.WriteUInt32(stream, (uint)bytes.Length);
     stream.Write(bytes, 0, (int)bytes.Length);
 }
Beispiel #15
0
 public void ResetToPool()
 {
     DemoHeader.ResetToPool(this);
 }
Beispiel #16
0
 public virtual void ReadFromStream(Stream stream, int size, bool isDelta = false)
 {
     DemoHeader.DeserializeLength(stream, size, this, isDelta);
 }
Beispiel #17
0
 public static DemoHeader Deserialize(Stream stream, DemoHeader instance, bool isDelta)
 {
     while (true)
     {
         int num = stream.ReadByte();
         if (num == -1)
         {
             break;
         }
         if (num <= 32)
         {
             if (num <= 18)
             {
                 if (num == 8)
                 {
                     instance.version = ProtocolParser.ReadUInt32(stream);
                     continue;
                 }
                 else if (num == 18)
                 {
                     instance.level = ProtocolParser.ReadString(stream);
                     continue;
                 }
             }
             else if (num == 24)
             {
                 instance.levelSeed = ProtocolParser.ReadUInt32(stream);
                 continue;
             }
             else if (num == 32)
             {
                 instance.levelSize = ProtocolParser.ReadUInt32(stream);
                 continue;
             }
         }
         else if (num <= 48)
         {
             if (num == 42)
             {
                 instance.checksum = ProtocolParser.ReadString(stream);
                 continue;
             }
             else if (num == 48)
             {
                 instance.localclient = ProtocolParser.ReadUInt64(stream);
                 continue;
             }
         }
         else if (num == 58)
         {
             Vector3Serialized.DeserializeLengthDelimited(stream, ref instance.position, isDelta);
             continue;
         }
         else if (num == 66)
         {
             Vector3Serialized.DeserializeLengthDelimited(stream, ref instance.rotation, isDelta);
             continue;
         }
         else if (num == 74)
         {
             instance.levelUrl = ProtocolParser.ReadString(stream);
             continue;
         }
         Key key = ProtocolParser.ReadKey((byte)num, stream);
         if (key.Field == 0)
         {
             throw new ProtocolBufferException("Invalid field id: 0, something went wrong in the stream");
         }
         ProtocolParser.SkipKey(stream, key);
     }
     return(instance);
 }
Beispiel #18
0
 public void ToProto(Stream stream)
 {
     DemoHeader.Serialize(stream, this);
 }