/** * {@inheritdoc} */ public function serializedSize(\Protobuf\ComputeSizeContext $context) { $calculator = $context->getSizeCalculator(); $size = 0; if ($this->item_effect !== null) { $size += 1; $size += $calculator->computeVarintSize($this->item_effect->value()); } if ($this->capture_multi !== null) { $size += 1; $size += 4; } if ($this->capture_multi_effect !== null) { $size += 1; $size += 4; } if ($this->item_effect_mod !== null) { $size += 1; $size += 4; } if ($this->extensions !== null) { $size += $this->extensions->serializedSize($context); } return $size; }
/** * {@inheritdoc} */ public function readFrom(\Protobuf\ReadContext $context) { $reader = $context->getReader(); $length = $context->getLength(); $stream = $context->getStream(); $limit = $length !== null ? $stream->tell() + $length : null; while ($limit === null || $stream->tell() < $limit) { if ($stream->eof()) { break; } $key = $reader->readVarint($stream); $wire = \Protobuf\WireFormat::getTagWireType($key); $tag = \Protobuf\WireFormat::getTagFieldNumber($key); if ($stream->eof()) { break; } if ($tag === 1) { $innerSize = $reader->readVarint($stream); $innerLimit = $stream->tell() + $innerSize; if ($this->item_effect === null) { $this->item_effect = new \Protobuf\EnumCollection(); } while ($stream->tell() < $innerLimit) { $this->item_effect->add(\POGOProtos\Enums\ItemEffect::valueOf($reader->readVarint($stream))); } continue; } if ($tag === 2) { $innerSize = $reader->readVarint($stream); $innerLimit = $stream->tell() + $innerSize; if ($this->item_effect_percent === null) { $this->item_effect_percent = new \Protobuf\ScalarCollection(); } while ($stream->tell() < $innerLimit) { $this->item_effect_percent->add($reader->readFloat($stream)); } continue; } if ($tag === 3) { \Protobuf\WireFormat::assertWireType($wire, 2); $this->growth_percent = $reader->readFloat($stream); continue; } $extensions = $context->getExtensionRegistry(); $extension = $extensions ? $extensions->findByNumber(__CLASS__, $tag) : null; if ($extension !== null) { $this->extensions()->add($extension, $extension->readFrom($context, $wire)); continue; } if ($this->unknownFieldSet === null) { $this->unknownFieldSet = new \Protobuf\UnknownFieldSet(); } $data = $reader->readUnknown($stream, $wire); $unknown = new \Protobuf\Unknown($tag, $wire, $data); $this->unknownFieldSet->add($unknown); } }