Beispiel #1
0
        int IPacket.ReadBody(Span <byte> span, PacketContext context)
        {
            ItemIndex = MemoryMarshal.Read <int>(span);

            var length = 4;

            _flags = MemoryMarshal.Read <Flags8>(span[(length++)..]);
        int IPacket.ReadBody(Span <byte> span, PacketContext context)
        {
            var length = 22;

            Identity   = span.Read <short>();
            Position   = span.Read <Vector2f>();
            Velocity   = span.Read <Vector2f>();
            OwnerIndex = span.Read <byte>();
            Type       = span.Read <short>();
            _flags     = span.Read <Flags8>();
            for (var i = 0; i < AdditionalInformation.Length; ++i)
            {
                if (!_flags[i])
                {
                    continue;
                }

                AdditionalInformation[i] = span.Read <float>();
                length += 4;
            }

            if (_flags[4])
            {
                Damage  = span.Read <short>();
                length += 2;
            }

            if (_flags[5])
            {
                Knockback = span.Read <float>();
                length   += 4;
            }

            if (_flags[6])
            {
                OriginalDamage = span.Read <short>();
                length        += 2;
            }

            if (_flags[7])
            {
                Uuid    = span.Read <short>();
                length += 2;
            }

            return(length);
        }