Exemple #1
0
        /// <summary>Reads a vector value.</summary>
        /// <param name="packet">The packet.</param>
        /// <returns>The read value.</returns>
        /// <exception cref="PacketException">The packet has not enough available data for the read operation.</exception>
        public static Vector2 ReadVector2(this IReadablePacket packet)
        {
            Vector2 result;

            result.X = packet.ReadSingle();
            result.Y = packet.ReadSingle();
            return(result);
        }
Exemple #2
0
        /// <summary>Reads a rotation value.</summary>
        /// <param name="packet">The packet.</param>
        /// <returns>The read value.</returns>
        /// <exception cref="PacketException">The packet has not enough available data for the read operation.</exception>
        private static Rotation ReadRotation(this IReadablePacket packet)
        {
            Rotation result;

            result.Sin = packet.ReadSingle();
            result.Cos = packet.ReadSingle();
            return(result);
        }
Exemple #3
0
        /// <summary>Reads a far rectangle value.</summary>
        /// <param name="packet">The packet to read from.</param>
        /// <returns>The read value.</returns>
        /// <exception cref="PacketException">The packet has not enough available data for the read operation.</exception>
        public static FarRectangle ReadFarRectangle(this IReadablePacket packet)
        {
            FarRectangle result;

            result.X      = packet.ReadFarValue();
            result.Y      = packet.ReadFarValue();
            result.Width  = packet.ReadSingle();
            result.Height = packet.ReadSingle();
            return(result);
        }
Exemple #4
0
        /// <summary>Reads a rectangle value.</summary>
        /// <param name="packet">The packet.</param>
        /// <returns>The read value.</returns>
        /// <exception cref="PacketException">The packet has not enough available data for the read operation.</exception>
        public static RectangleF ReadRectangleF(this IReadablePacket packet)
        {
            RectangleF result;

            result.X      = packet.ReadSingle();
            result.Y      = packet.ReadSingle();
            result.Width  = packet.ReadSingle();
            result.Height = packet.ReadSingle();
            return(result);
        }
Exemple #5
0
        /// <summary>Reads a far value.</summary>
        /// <param name="packet">The packet to read from.</param>
        /// <returns>The read value.</returns>
        /// <exception cref="PacketException">The packet has not enough available data for the read operation.</exception>
        public static FarValue ReadFarValue(this IReadablePacket packet)
        {
            var segment = packet.ReadInt32();
            var offset  = packet.ReadSingle();

            return(new FarValue(segment, offset));
        }
Exemple #6
0
        public void Depacketize(IReadablePacket packet)
        {
            var attributeCount = packet.ReadInt32();

            for (var i = 0; i < attributeCount; i++)
            {
                var type  = (AttributeType)packet.ReadByte();
                var value = packet.ReadSingle();
                Attributes.Add(type, value);
            }
            Projectiles = packet.ReadPacketizables <ProjectileFactory>();
        }
Exemple #7
0
        /// <summary>
        ///     Corresponds to <c>PacketizeLocal</c>, only reads own data and leaves the base class alone.
        /// </summary>
        /// <param name="packet">The packet to read from.</param>
        public void DepacketizeLocal(IReadablePacket packet)
        {
            var baseAttributeCount = packet.ReadInt32();

            for (var i = 0; i < baseAttributeCount; i++)
            {
                var key   = (TAttribute)Enum.Parse(typeof(TAttribute), packet.ReadString());
                var value = packet.ReadSingle();
                _baseAttributes[key] = value;
            }
            var modifiedAttributeCount = packet.ReadInt32();

            for (var i = 0; i < modifiedAttributeCount; i++)
            {
                var key    = (TAttribute)Enum.Parse(typeof(TAttribute), packet.ReadString());
                var values = new float[2];
                values[0] = packet.ReadSingle();
                values[1] = packet.ReadSingle();
                _modifiedAttributes[key] = values;
            }
        }
Exemple #8
0
 public void Depacketize(IReadablePacket packet)
 {
     for (var i = 0; i < _squadIds.Count; i++)
     {
         var id   = packet.ReadInt32();
         var data = _squads[id] = new SquadData();
         data.Formation = packet.ReadPacketizableWithTypeInfo <AbstractFormation>();
         data.Cache     = new FormationCache(data.Formation);
         data.Spacing   = packet.ReadSingle();
         var count = packet.ReadInt32();
         for (var j = 0; j < count; j++)
         {
             data.Members.Add(packet.ReadInt32());
         }
     }
 }
Exemple #9
0
 public static IReadablePacket Read(this IReadablePacket packet, out float data)
 {
     data = packet.ReadSingle();
     return(packet);
 }
Exemple #10
0
        /// <summary>Reads a matrix value.</summary>
        /// <param name="packet">The packet.</param>
        /// <returns>The read value.</returns>
        /// <exception cref="PacketException">The packet has not enough available data for the read operation.</exception>
        public static Matrix ReadMatrix(this IReadablePacket packet)
        {
            Matrix result;

            result.M11 = packet.ReadSingle();
            result.M12 = packet.ReadSingle();
            result.M13 = packet.ReadSingle();
            result.M14 = packet.ReadSingle();
            result.M21 = packet.ReadSingle();
            result.M22 = packet.ReadSingle();
            result.M23 = packet.ReadSingle();
            result.M24 = packet.ReadSingle();
            result.M31 = packet.ReadSingle();
            result.M32 = packet.ReadSingle();
            result.M33 = packet.ReadSingle();
            result.M34 = packet.ReadSingle();
            result.M41 = packet.ReadSingle();
            result.M42 = packet.ReadSingle();
            result.M43 = packet.ReadSingle();
            result.M44 = packet.ReadSingle();
            return(result);
        }