/**
  * {@inheritdoc}
  */
 public function writeTo(\Protobuf\WriteContext $context)
 {
     $stream = $context->getStream();
     $writer = $context->getWriter();
     $sizeContext = $context->getComputeSizeContext();
     if ($this->result !== null) {
         $writer->writeVarint($stream, 8);
         $writer->writeVarint($stream, $this->result->value());
     }
     if ($this->battle_start_timestamp_ms !== null) {
         $writer->writeVarint($stream, 16);
         $writer->writeVarint($stream, $this->battle_start_timestamp_ms);
     }
     if ($this->battle_end_timestamp_ms !== null) {
         $writer->writeVarint($stream, 24);
         $writer->writeVarint($stream, $this->battle_end_timestamp_ms);
     }
     if ($this->battle_id !== null) {
         $writer->writeVarint($stream, 34);
         $writer->writeString($stream, $this->battle_id);
     }
     if ($this->defender !== null) {
         $writer->writeVarint($stream, 42);
         $writer->writeVarint($stream, $this->defender->serializedSize($sizeContext));
         $this->defender->writeTo($context);
     }
     if ($this->battle_log !== null) {
         $writer->writeVarint($stream, 50);
         $writer->writeVarint($stream, $this->battle_log->serializedSize($sizeContext));
         $this->battle_log->writeTo($context);
     }
     if ($this->attacker !== null) {
         $writer->writeVarint($stream, 58);
         $writer->writeVarint($stream, $this->attacker->serializedSize($sizeContext));
         $this->attacker->writeTo($context);
     }
     if ($this->extensions !== null) {
         $this->extensions->writeTo($context);
     }
     return $stream;
 }
 /**
  * {@inheritdoc}
  */
 public function writeTo(\Protobuf\WriteContext $context)
 {
     $stream = $context->getStream();
     $writer = $context->getWriter();
     $sizeContext = $context->getComputeSizeContext();
     if ($this->type !== null) {
         $writer->writeVarint($stream, 8);
         $writer->writeVarint($stream, $this->type->value());
     }
     if ($this->action_start_ms !== null) {
         $writer->writeVarint($stream, 16);
         $writer->writeVarint($stream, $this->action_start_ms);
     }
     if ($this->duration_ms !== null) {
         $writer->writeVarint($stream, 24);
         $writer->writeVarint($stream, $this->duration_ms);
     }
     if ($this->energy_delta !== null) {
         $writer->writeVarint($stream, 40);
         $writer->writeVarint($stream, $this->energy_delta);
     }
     if ($this->attacker_index !== null) {
         $writer->writeVarint($stream, 48);
         $writer->writeVarint($stream, $this->attacker_index);
     }
     if ($this->target_index !== null) {
         $writer->writeVarint($stream, 56);
         $writer->writeVarint($stream, $this->target_index);
     }
     if ($this->active_pokemon_id !== null) {
         $writer->writeVarint($stream, 65);
         $writer->writeFixed64($stream, $this->active_pokemon_id);
     }
     if ($this->player_joined !== null) {
         $writer->writeVarint($stream, 74);
         $writer->writeVarint($stream, $this->player_joined->serializedSize($sizeContext));
         $this->player_joined->writeTo($context);
     }
     if ($this->battle_results !== null) {
         $writer->writeVarint($stream, 82);
         $writer->writeVarint($stream, $this->battle_results->serializedSize($sizeContext));
         $this->battle_results->writeTo($context);
     }
     if ($this->damage_windows_start_timestamp_ms !== null) {
         $writer->writeVarint($stream, 88);
         $writer->writeVarint($stream, $this->damage_windows_start_timestamp_ms);
     }
     if ($this->damage_windows_end_timestamp_ms !== null) {
         $writer->writeVarint($stream, 96);
         $writer->writeVarint($stream, $this->damage_windows_end_timestamp_ms);
     }
     if ($this->player_left !== null) {
         $writer->writeVarint($stream, 106);
         $writer->writeVarint($stream, $this->player_left->serializedSize($sizeContext));
         $this->player_left->writeTo($context);
     }
     if ($this->target_pokemon_id !== null) {
         $writer->writeVarint($stream, 113);
         $writer->writeFixed64($stream, $this->target_pokemon_id);
     }
     if ($this->extensions !== null) {
         $this->extensions->writeTo($context);
     }
     return $stream;
 }