PocketMine-MP 5.21.2 git-09bf203267aca9b83a09640e17bfac0fc7b58ff8
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 Vector2 $viewAngle;
26 private float $distance;
27 private CameraAimAssistTargetMode $targetMode;
28 private CameraAimAssistActionType $actionType;
29
33 public static function create(Vector2 $viewAngle, float $distance, CameraAimAssistTargetMode $targetMode, CameraAimAssistActionType $actionType) : self{
34 $result = new self;
35 $result->viewAngle = $viewAngle;
36 $result->distance = $distance;
37 $result->targetMode = $targetMode;
38 $result->actionType = $actionType;
39 return $result;
40 }
41
42 public function getViewAngle() : Vector2{ return $this->viewAngle; }
43
44 public function getDistance() : float{ return $this->distance; }
45
46 public function getTargetMode() : CameraAimAssistTargetMode{ return $this->targetMode; }
47
48 public function getActionType() : CameraAimAssistActionType{ return $this->actionType; }
49
50 protected function decodePayload(PacketSerializer $in) : void{
51 $this->viewAngle = $in->getVector2();
52 $this->distance = $in->getLFloat();
53 $this->targetMode = CameraAimAssistTargetMode::fromPacket($in->getByte());
54 $this->actionType = CameraAimAssistActionType::fromPacket($in->getByte());
55 }
56
57 protected function encodePayload(PacketSerializer $out) : void{
58 $out->putVector2($this->viewAngle);
59 $out->putLFloat($this->distance);
60 $out->putByte($this->targetMode->value);
61 $out->putByte($this->actionType->value);
62 }
63
64 public function handle(PacketHandlerInterface $handler) : bool{
65 return $handler->handleCameraAimAssist($this);
66 }
67}
static create(Vector2 $viewAngle, float $distance, CameraAimAssistTargetMode $targetMode, CameraAimAssistActionType $actionType)