public static InputMessage DeserializeLengthDelimited(Stream stream)
    {
        InputMessage inputMessage = Pool.Get <InputMessage>();

        InputMessage.DeserializeLengthDelimited(stream, inputMessage, false);
        return(inputMessage);
    }
예제 #2
0
    public static PlayerTick DeserializeLengthDelimited(Stream stream, PlayerTick 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 <= 34)
            {
                if (num == 10)
                {
                    if (instance.inputState != null)
                    {
                        InputMessage.DeserializeLengthDelimited(stream, instance.inputState, isDelta);
                        continue;
                    }
                    else
                    {
                        instance.inputState = InputMessage.DeserializeLengthDelimited(stream);
                        continue;
                    }
                }
                else if (num == 18)
                {
                    Vector3Serialized.DeserializeLengthDelimited(stream, ref instance.position, isDelta);
                    continue;
                }
                else if (num == 34)
                {
                    if (instance.modelState != null)
                    {
                        ModelState.DeserializeLengthDelimited(stream, instance.modelState, isDelta);
                        continue;
                    }
                    else
                    {
                        instance.modelState = ModelState.DeserializeLengthDelimited(stream);
                        continue;
                    }
                }
            }
            else if (num == 40)
            {
                instance.activeItem = ProtocolParser.ReadUInt32(stream);
                continue;
            }
            else if (num == 50)
            {
                Vector3Serialized.DeserializeLengthDelimited(stream, ref instance.eyePos, isDelta);
                continue;
            }
            else if (num == 56)
            {
                instance.parentID = 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);
    }