PocketMine-MP 5.25.1 git-694aa17cc916a954b10fe12721c81b1dc73eecd5
Loading...
Searching...
No Matches
CameraPresetAimAssist.php
1<?php
2
3/*
4 * This file is part of BedrockProtocol.
5 * Copyright (C) 2014-2022 PocketMine Team <https://github.com/pmmp/BedrockProtocol>
6 *
7 * BedrockProtocol is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Lesser General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 */
12
13declare(strict_types=1);
14
15namespace pocketmine\network\mcpe\protocol\types\camera;
16
19
21
22 public function __construct(
23 private ?string $presetId,
24 private ?CameraAimAssistTargetMode $targetMode,
25 private ?Vector2 $viewAngle,
26 private ?float $distance,
27 ){}
28
29 public function getPresetId() : ?string{ return $this->presetId; }
30
31 public function getTargetMode() : ?CameraAimAssistTargetMode{ return $this->targetMode; }
32
33 public function getViewAngle() : ?Vector2{ return $this->viewAngle; }
34
35 public function getDistance() : ?float{ return $this->distance; }
36
37 public static function read(PacketSerializer $in) : self{
38 $presetId = $in->readOptional($in->getString(...));
39 $targetMode = $in->readOptional(fn() => CameraAimAssistTargetMode::fromPacket($in->getByte()));
40 $viewAngle = $in->readOptional($in->getVector2(...));
41 $distance = $in->readOptional($in->getLFloat(...));
42
43 return new self(
44 $presetId,
45 $targetMode,
46 $viewAngle,
47 $distance
48 );
49 }
50
51 public function write(PacketSerializer $out) : void{
52 $out->writeOptional($this->presetId, $out->putString(...));
53 $out->writeOptional($this->targetMode, fn(CameraAimAssistTargetMode $v) => $out->putByte($v->value));
54 $out->writeOptional($this->viewAngle, $out->putVector2(...));
55 $out->writeOptional($this->distance, $out->putLFloat(...));
56 }
57}