コード例 #1
0
 public byte[] ToProtoBytes()
 {
     return(Attack.SerializeToBytes(this));
 }
コード例 #2
0
 public virtual void WriteToStream(Stream stream)
 {
     Attack.Serialize(stream, this);
 }
コード例 #3
0
 public static void SerializeLengthDelimited(Stream stream, Attack instance)
 {
     byte[] bytes = Attack.SerializeToBytes(instance);
     ProtocolParser.WriteUInt32(stream, (uint)bytes.Length);
     stream.Write(bytes, 0, (int)bytes.Length);
 }
コード例 #4
0
 public void ToProto(Stream stream)
 {
     Attack.Serialize(stream, this);
 }
コード例 #5
0
        public static void SerializeDelta(Stream stream, Attack instance, Attack previous)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

            if (instance.pointStart != previous.pointStart)
            {
                stream.WriteByte(10);
                memoryStream.SetLength((long)0);
                Vector3Serialized.SerializeDelta(memoryStream, instance.pointStart, previous.pointStart);
                uint length = (uint)memoryStream.Length;
                ProtocolParser.WriteUInt32(stream, length);
                stream.Write(memoryStream.GetBuffer(), 0, (int)length);
            }
            if (instance.pointEnd != previous.pointEnd)
            {
                stream.WriteByte(18);
                memoryStream.SetLength((long)0);
                Vector3Serialized.SerializeDelta(memoryStream, instance.pointEnd, previous.pointEnd);
                uint num = (uint)memoryStream.Length;
                ProtocolParser.WriteUInt32(stream, num);
                stream.Write(memoryStream.GetBuffer(), 0, (int)num);
            }
            if (instance.hitID != previous.hitID)
            {
                stream.WriteByte(24);
                ProtocolParser.WriteUInt32(stream, instance.hitID);
            }
            if (instance.hitBone != previous.hitBone)
            {
                stream.WriteByte(32);
                ProtocolParser.WriteUInt32(stream, instance.hitBone);
            }
            if (instance.hitNormalLocal != previous.hitNormalLocal)
            {
                stream.WriteByte(42);
                memoryStream.SetLength((long)0);
                Vector3Serialized.SerializeDelta(memoryStream, instance.hitNormalLocal, previous.hitNormalLocal);
                uint length1 = (uint)memoryStream.Length;
                ProtocolParser.WriteUInt32(stream, length1);
                stream.Write(memoryStream.GetBuffer(), 0, (int)length1);
            }
            if (instance.hitPositionLocal != previous.hitPositionLocal)
            {
                stream.WriteByte(50);
                memoryStream.SetLength((long)0);
                Vector3Serialized.SerializeDelta(memoryStream, instance.hitPositionLocal, previous.hitPositionLocal);
                uint num1 = (uint)memoryStream.Length;
                ProtocolParser.WriteUInt32(stream, num1);
                stream.Write(memoryStream.GetBuffer(), 0, (int)num1);
            }
            if (instance.hitNormalWorld != previous.hitNormalWorld)
            {
                stream.WriteByte(58);
                memoryStream.SetLength((long)0);
                Vector3Serialized.SerializeDelta(memoryStream, instance.hitNormalWorld, previous.hitNormalWorld);
                uint length2 = (uint)memoryStream.Length;
                ProtocolParser.WriteUInt32(stream, length2);
                stream.Write(memoryStream.GetBuffer(), 0, (int)length2);
            }
            if (instance.hitPositionWorld != previous.hitPositionWorld)
            {
                stream.WriteByte(66);
                memoryStream.SetLength((long)0);
                Vector3Serialized.SerializeDelta(memoryStream, instance.hitPositionWorld, previous.hitPositionWorld);
                uint num2 = (uint)memoryStream.Length;
                ProtocolParser.WriteUInt32(stream, num2);
                stream.Write(memoryStream.GetBuffer(), 0, (int)num2);
            }
            if (instance.hitPartID != previous.hitPartID)
            {
                stream.WriteByte(72);
                ProtocolParser.WriteUInt32(stream, instance.hitPartID);
            }
            if (instance.hitMaterialID != previous.hitMaterialID)
            {
                stream.WriteByte(80);
                ProtocolParser.WriteUInt32(stream, instance.hitMaterialID);
            }
            if (instance.hitItem != previous.hitItem)
            {
                stream.WriteByte(88);
                ProtocolParser.WriteUInt32(stream, instance.hitItem);
            }
            Pool.FreeMemoryStream(ref memoryStream);
        }
コード例 #6
0
 public void ResetToPool()
 {
     Attack.ResetToPool(this);
 }
コード例 #7
0
 public virtual void ReadFromStream(Stream stream, int size, bool isDelta = false)
 {
     Attack.DeserializeLength(stream, size, this, isDelta);
 }
コード例 #8
0
 public void FromProto(Stream stream, bool isDelta = false)
 {
     Attack.Deserialize(stream, this, isDelta);
 }
コード例 #9
0
        public static Attack DeserializeLengthDelimited(Stream stream, Attack 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 <= 42)
                {
                    if (num <= 18)
                    {
                        if (num == 10)
                        {
                            Vector3Serialized.DeserializeLengthDelimited(stream, ref instance.pointStart, isDelta);
                            continue;
                        }
                        else if (num == 18)
                        {
                            Vector3Serialized.DeserializeLengthDelimited(stream, ref instance.pointEnd, isDelta);
                            continue;
                        }
                    }
                    else if (num == 24)
                    {
                        instance.hitID = ProtocolParser.ReadUInt32(stream);
                        continue;
                    }
                    else if (num == 32)
                    {
                        instance.hitBone = ProtocolParser.ReadUInt32(stream);
                        continue;
                    }
                    else if (num == 42)
                    {
                        Vector3Serialized.DeserializeLengthDelimited(stream, ref instance.hitNormalLocal, isDelta);
                        continue;
                    }
                }
                else if (num <= 66)
                {
                    if (num == 50)
                    {
                        Vector3Serialized.DeserializeLengthDelimited(stream, ref instance.hitPositionLocal, isDelta);
                        continue;
                    }
                    else if (num == 58)
                    {
                        Vector3Serialized.DeserializeLengthDelimited(stream, ref instance.hitNormalWorld, isDelta);
                        continue;
                    }
                    else if (num == 66)
                    {
                        Vector3Serialized.DeserializeLengthDelimited(stream, ref instance.hitPositionWorld, isDelta);
                        continue;
                    }
                }
                else if (num == 72)
                {
                    instance.hitPartID = ProtocolParser.ReadUInt32(stream);
                    continue;
                }
                else if (num == 80)
                {
                    instance.hitMaterialID = ProtocolParser.ReadUInt32(stream);
                    continue;
                }
                else if (num == 88)
                {
                    instance.hitItem = ProtocolParser.ReadUInt32(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);
            }
            if (stream.Position != position)
            {
                throw new ProtocolBufferException("Read past max limit");
            }
            return(instance);
        }