Lidgren.Network.NetBuffer.ReadSingle C# (CSharp) Méthode

ReadSingle() public méthode

Reads a 32 bit floating point value written using Write(Single)
public ReadSingle ( float &result ) : bool
result float
Résultat bool
        public bool ReadSingle(out float result)
        {
            if (m_bitLength - m_readPosition < 32)
            {
                result = 0.0f;
                return false;
            }

            if ((m_readPosition & 7) == 0) // read directly
            {
                result = BitConverter.ToSingle(m_data, m_readPosition >> 3);
                m_readPosition += 32;
                return true;
            }

            byte[] bytes = ReadBytes(4);
            result = BitConverter.ToSingle(bytes, 0);
            return true;
        }

Same methods

NetBuffer::ReadSingle ( ) : float

Usage Example

        /// <summary>
        /// Reads a Vector2
        /// </summary>
        public static Vector2 ReadVector2(this NetBuffer message)
        {
            Vector2 retval;

            retval.x = message.ReadSingle();
            retval.y = message.ReadSingle();
            return(retval);
        }
All Usage Examples Of Lidgren.Network.NetBuffer::ReadSingle