PocketMine-MP 5.32.2 git-237b304ef9858756b018e44e8f298093f66f823b
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 private bool $showDebugRender;
31
35 public static function create(string $presetId, Vector2 $viewAngle, float $distance, CameraAimAssistTargetMode $targetMode, CameraAimAssistActionType $actionType, bool $showDebugRender) : self{
36 $result = new self;
37 $result->presetId = $presetId;
38 $result->viewAngle = $viewAngle;
39 $result->distance = $distance;
40 $result->targetMode = $targetMode;
41 $result->actionType = $actionType;
42 $result->showDebugRender = $showDebugRender;
43 return $result;
44 }
45
46 public function getPresetId() : string{ return $this->presetId; }
47
48 public function getViewAngle() : Vector2{ return $this->viewAngle; }
49
50 public function getDistance() : float{ return $this->distance; }
51
52 public function getTargetMode() : CameraAimAssistTargetMode{ return $this->targetMode; }
53
54 public function getActionType() : CameraAimAssistActionType{ return $this->actionType; }
55
56 public function getShowDebugRender() : bool{ return $this->showDebugRender; }
57
58 protected function decodePayload(PacketSerializer $in) : void{
59 $this->presetId = $in->getString();
60 $this->viewAngle = $in->getVector2();
61 $this->distance = $in->getLFloat();
62 $this->targetMode = CameraAimAssistTargetMode::fromPacket($in->getByte());
63 $this->actionType = CameraAimAssistActionType::fromPacket($in->getByte());
64 $this->showDebugRender = $in->getBool();
65 }
66
67 protected function encodePayload(PacketSerializer $out) : void{
68 $out->putString($this->presetId);
69 $out->putVector2($this->viewAngle);
70 $out->putLFloat($this->distance);
71 $out->putByte($this->targetMode->value);
72 $out->putByte($this->actionType->value);
73 $out->putBool($this->showDebugRender);
74 }
75
76 public function handle(PacketHandlerInterface $handler) : bool{
77 return $handler->handleCameraAimAssist($this);
78 }
79}
static create(string $presetId, Vector2 $viewAngle, float $distance, CameraAimAssistTargetMode $targetMode, CameraAimAssistActionType $actionType, bool $showDebugRender)