コード例 #1
0
        public PlayerProjectileAttack Copy()
        {
            PlayerProjectileAttack playerProjectileAttack = Pool.Get <PlayerProjectileAttack>();

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

            PlayerProjectileAttack.Deserialize(stream, playerProjectileAttack, false);
            return(playerProjectileAttack);
        }
コード例 #3
0
        public static void Serialize(Stream stream, PlayerProjectileAttack instance)
        {
            MemoryStream memoryStream = Pool.Get <MemoryStream>();

            if (instance.playerAttack == null)
            {
                throw new ArgumentNullException("playerAttack", "Required by proto specification.");
            }
            stream.WriteByte(10);
            memoryStream.SetLength((long)0);
            PlayerAttack.Serialize(memoryStream, instance.playerAttack);
            uint length = (uint)memoryStream.Length;

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

            ProtocolParser.WriteUInt32(stream, num);
            stream.Write(memoryStream.GetBuffer(), 0, (int)num);
            stream.WriteByte(29);
            ProtocolParser.WriteSingle(stream, instance.hitDistance);
            stream.WriteByte(37);
            ProtocolParser.WriteSingle(stream, instance.travelTime);
            Pool.FreeMemoryStream(ref memoryStream);
        }
コード例 #4
0
        public static PlayerProjectileAttack DeserializeLength(Stream stream, int length)
        {
            PlayerProjectileAttack playerProjectileAttack = Pool.Get <PlayerProjectileAttack>();

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

            using (MemoryStream memoryStream = new MemoryStream(buffer))
            {
                PlayerProjectileAttack.Deserialize(memoryStream, playerProjectileAttack, false);
            }
            return(playerProjectileAttack);
        }
コード例 #9
0
 public static PlayerProjectileAttack Deserialize(Stream stream, PlayerProjectileAttack instance, bool isDelta)
 {
     while (true)
     {
         int num = stream.ReadByte();
         if (num == -1)
         {
             break;
         }
         if (num <= 18)
         {
             if (num != 10)
             {
                 if (num == 18)
                 {
                     Vector3Serialized.DeserializeLengthDelimited(stream, ref instance.hitVelocity, isDelta);
                     continue;
                 }
             }
             else if (instance.playerAttack != null)
             {
                 PlayerAttack.DeserializeLengthDelimited(stream, instance.playerAttack, isDelta);
                 continue;
             }
             else
             {
                 instance.playerAttack = PlayerAttack.DeserializeLengthDelimited(stream);
                 continue;
             }
         }
         else if (num == 29)
         {
             instance.hitDistance = ProtocolParser.ReadSingle(stream);
             continue;
         }
         else if (num == 37)
         {
             instance.travelTime = ProtocolParser.ReadSingle(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);
 }
コード例 #10
0
 public static void ResetToPool(PlayerProjectileAttack instance)
 {
     if (!instance.ShouldPool)
     {
         return;
     }
     if (instance.playerAttack != null)
     {
         instance.playerAttack.ResetToPool();
         instance.playerAttack = null;
     }
     instance.hitVelocity = new Vector3();
     instance.hitDistance = 0f;
     instance.travelTime  = 0f;
     Pool.Free <PlayerProjectileAttack>(ref instance);
 }
コード例 #11
0
 public void CopyTo(PlayerProjectileAttack instance)
 {
     if (this.playerAttack == null)
     {
         instance.playerAttack = null;
     }
     else if (instance.playerAttack != null)
     {
         this.playerAttack.CopyTo(instance.playerAttack);
     }
     else
     {
         instance.playerAttack = this.playerAttack.Copy();
     }
     instance.hitVelocity = this.hitVelocity;
     instance.hitDistance = this.hitDistance;
     instance.travelTime  = this.travelTime;
 }
コード例 #12
0
 public virtual void ReadFromStream(Stream stream, int size, bool isDelta = false)
 {
     PlayerProjectileAttack.DeserializeLength(stream, size, this, isDelta);
 }
コード例 #13
0
 public void ResetToPool()
 {
     PlayerProjectileAttack.ResetToPool(this);
 }
コード例 #14
0
 public virtual void WriteToStream(Stream stream)
 {
     PlayerProjectileAttack.Serialize(stream, this);
 }
コード例 #15
0
 public byte[] ToProtoBytes()
 {
     return(PlayerProjectileAttack.SerializeToBytes(this));
 }
コード例 #16
0
 public void ToProto(Stream stream)
 {
     PlayerProjectileAttack.Serialize(stream, this);
 }
コード例 #17
0
 public void FromProto(Stream stream, bool isDelta = false)
 {
     PlayerProjectileAttack.Deserialize(stream, this, isDelta);
 }
コード例 #18
0
 public static void SerializeLengthDelimited(Stream stream, PlayerProjectileAttack instance)
 {
     byte[] bytes = PlayerProjectileAttack.SerializeToBytes(instance);
     ProtocolParser.WriteUInt32(stream, (uint)bytes.Length);
     stream.Write(bytes, 0, (int)bytes.Length);
 }