PocketMine-MP 5.23.3 git-f7687af337d001ddbcc47b8e773f014a33faa662
Loading...
Searching...
No Matches
CameraAimAssistPacket.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;
16
19use pocketmine\network\mcpe\protocol\types\camera\CameraAimAssistActionType;
20use pocketmine\network\mcpe\protocol\types\camera\CameraAimAssistTargetMode;
21
23 public const NETWORK_ID = ProtocolInfo::CAMERA_AIM_ASSIST_PACKET;
24
25 private string $presetId;
26 private Vector2 $viewAngle;
27 private float $distance;
28 private CameraAimAssistTargetMode $targetMode;
29 private CameraAimAssistActionType $actionType;
30
34 public static function create(string $presetId, Vector2 $viewAngle, float $distance, CameraAimAssistTargetMode $targetMode, CameraAimAssistActionType $actionType) : self{
35 $result = new self;
36 $result->presetId = $presetId;
37 $result->viewAngle = $viewAngle;
38 $result->distance = $distance;
39 $result->targetMode = $targetMode;
40 $result->actionType = $actionType;
41 return $result;
42 }
43
44 public function getPresetId() : string{ return $this->presetId; }
45
46 public function getViewAngle() : Vector2{ return $this->viewAngle; }
47
48 public function getDistance() : float{ return $this->distance; }
49
50 public function getTargetMode() : CameraAimAssistTargetMode{ return $this->targetMode; }
51
52 public function getActionType() : CameraAimAssistActionType{ return $this->actionType; }
53
54 protected function decodePayload(PacketSerializer $in) : void{
55 $this->presetId = $in->getString();
56 $this->viewAngle = $in->getVector2();
57 $this->distance = $in->getLFloat();
58 $this->targetMode = CameraAimAssistTargetMode::fromPacket($in->getByte());
59 $this->actionType = CameraAimAssistActionType::fromPacket($in->getByte());
60 }
61
62 protected function encodePayload(PacketSerializer $out) : void{
63 $out->putString($this->presetId);
64 $out->putVector2($this->viewAngle);
65 $out->putLFloat($this->distance);
66 $out->putByte($this->targetMode->value);
67 $out->putByte($this->actionType->value);
68 }
69
70 public function handle(PacketHandlerInterface $handler) : bool{
71 return $handler->handleCameraAimAssist($this);
72 }
73}
static create(string $presetId, Vector2 $viewAngle, float $distance, CameraAimAssistTargetMode $targetMode, CameraAimAssistActionType $actionType)