コード例 #1
0
 public static DecayEntity Deserialize(Stream stream, DecayEntity instance, bool isDelta)
 {
     while (true)
     {
         int num = stream.ReadByte();
         if (num == -1)
         {
             break;
         }
         if (num == 13)
         {
             instance.decayTimer = ProtocolParser.ReadSingle(stream);
         }
         else if (num == 16)
         {
             instance.buildingID = ProtocolParser.ReadUInt32(stream);
         }
         else if (num == 29)
         {
             instance.upkeepTimer = ProtocolParser.ReadSingle(stream);
         }
         else
         {
             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);
 }
コード例 #2
0
        public static DecayEntity DeserializeLength(Stream stream, int length)
        {
            DecayEntity decayEntity = Pool.Get <DecayEntity>();

            DecayEntity.DeserializeLength(stream, length, decayEntity, false);
            return(decayEntity);
        }
コード例 #3
0
        public DecayEntity Copy()
        {
            DecayEntity decayEntity = Pool.Get <DecayEntity>();

            this.CopyTo(decayEntity);
            return(decayEntity);
        }
コード例 #4
0
        public static DecayEntity Deserialize(Stream stream)
        {
            DecayEntity decayEntity = Pool.Get <DecayEntity>();

            DecayEntity.Deserialize(stream, decayEntity, false);
            return(decayEntity);
        }
コード例 #5
0
 public static DecayEntity Deserialize(byte[] buffer, DecayEntity instance, bool isDelta = false)
 {
     using (MemoryStream memoryStream = new MemoryStream(buffer))
     {
         DecayEntity.Deserialize(memoryStream, instance, isDelta);
     }
     return(instance);
 }
コード例 #6
0
 public virtual void WriteToStreamDelta(Stream stream, DecayEntity previous)
 {
     if (previous == null)
     {
         DecayEntity.Serialize(stream, this);
         return;
     }
     DecayEntity.SerializeDelta(stream, this, previous);
 }
コード例 #7
0
        public static DecayEntity Deserialize(byte[] buffer)
        {
            DecayEntity decayEntity = Pool.Get <DecayEntity>();

            using (MemoryStream memoryStream = new MemoryStream(buffer))
            {
                DecayEntity.Deserialize(memoryStream, decayEntity, false);
            }
            return(decayEntity);
        }
コード例 #8
0
 public static byte[] SerializeToBytes(DecayEntity instance)
 {
     byte[] array;
     using (MemoryStream memoryStream = new MemoryStream())
     {
         DecayEntity.Serialize(memoryStream, instance);
         array = memoryStream.ToArray();
     }
     return(array);
 }
コード例 #9
0
 public static void ResetToPool(DecayEntity instance)
 {
     if (!instance.ShouldPool)
     {
         return;
     }
     instance.decayTimer  = 0f;
     instance.buildingID  = 0;
     instance.upkeepTimer = 0f;
     Pool.Free <DecayEntity>(ref instance);
 }
コード例 #10
0
        public static void Serialize(Stream stream, DecayEntity instance)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

            stream.WriteByte(13);
            ProtocolParser.WriteSingle(stream, instance.decayTimer);
            stream.WriteByte(16);
            ProtocolParser.WriteUInt32(stream, instance.buildingID);
            stream.WriteByte(29);
            ProtocolParser.WriteSingle(stream, instance.upkeepTimer);
            Pool.FreeMemoryStream(ref memoryStream);
        }
コード例 #11
0
        public static void SerializeDelta(Stream stream, DecayEntity instance, DecayEntity previous)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

            if (instance.decayTimer != previous.decayTimer)
            {
                stream.WriteByte(13);
                ProtocolParser.WriteSingle(stream, instance.decayTimer);
            }
            if (instance.buildingID != previous.buildingID)
            {
                stream.WriteByte(16);
                ProtocolParser.WriteUInt32(stream, instance.buildingID);
            }
            if (instance.upkeepTimer != previous.upkeepTimer)
            {
                stream.WriteByte(29);
                ProtocolParser.WriteSingle(stream, instance.upkeepTimer);
            }
            Pool.FreeMemoryStream(ref memoryStream);
        }
コード例 #12
0
        public static DecayEntity DeserializeLengthDelimited(Stream stream, DecayEntity instance, bool isDelta)
        {
            long position = (long)ProtocolParser.ReadUInt32(stream);

            position += stream.Position;
            while (stream.Position < position)
            {
                int num = stream.ReadByte();
                if (num == -1)
                {
                    throw new EndOfStreamException();
                }
                if (num == 13)
                {
                    instance.decayTimer = ProtocolParser.ReadSingle(stream);
                }
                else if (num == 16)
                {
                    instance.buildingID = ProtocolParser.ReadUInt32(stream);
                }
                else if (num == 29)
                {
                    instance.upkeepTimer = ProtocolParser.ReadSingle(stream);
                }
                else
                {
                    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);
                }
            }
            if (stream.Position != position)
            {
                throw new ProtocolBufferException("Read past max limit");
            }
            return(instance);
        }
コード例 #13
0
 public void CopyTo(DecayEntity instance)
 {
     instance.decayTimer  = this.decayTimer;
     instance.buildingID  = this.buildingID;
     instance.upkeepTimer = this.upkeepTimer;
 }
コード例 #14
0
 public virtual void WriteToStream(Stream stream)
 {
     DecayEntity.Serialize(stream, this);
 }
コード例 #15
0
 public byte[] ToProtoBytes()
 {
     return(DecayEntity.SerializeToBytes(this));
 }
コード例 #16
0
 public virtual void ReadFromStream(Stream stream, int size, bool isDelta = false)
 {
     DecayEntity.DeserializeLength(stream, size, this, isDelta);
 }
コード例 #17
0
 public static void SerializeLengthDelimited(Stream stream, DecayEntity instance)
 {
     byte[] bytes = DecayEntity.SerializeToBytes(instance);
     ProtocolParser.WriteUInt32(stream, (uint)bytes.Length);
     stream.Write(bytes, 0, (int)bytes.Length);
 }
コード例 #18
0
 public void ResetToPool()
 {
     DecayEntity.ResetToPool(this);
 }
コード例 #19
0
 public void ToProto(Stream stream)
 {
     DecayEntity.Serialize(stream, this);
 }
コード例 #20
0
 public void FromProto(Stream stream, bool isDelta = false)
 {
     DecayEntity.Deserialize(stream, this, isDelta);
 }