PocketMine-MP 5.23.3 git-f7687af337d001ddbcc47b8e773f014a33faa662
Loading...
Searching...
No Matches
CameraPreset.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
20
21final class CameraPreset{
22 public const AUDIO_LISTENER_TYPE_CAMERA = 0;
23 public const AUDIO_LISTENER_TYPE_PLAYER = 1;
24
25 public function __construct(
26 private string $name,
27 private string $parent,
28 private ?float $xPosition,
29 private ?float $yPosition,
30 private ?float $zPosition,
31 private ?float $pitch,
32 private ?float $yaw,
33 private ?float $rotationSpeed,
34 private ?bool $snapToTarget,
35 private ?Vector2 $horizontalRotationLimit,
36 private ?Vector2 $verticalRotationLimit,
37 private ?bool $continueTargeting,
38 private ?float $blockListeningRadius,
39 private ?Vector2 $viewOffset,
40 private ?Vector3 $entityOffset,
41 private ?float $radius,
42 private ?int $audioListenerType,
43 private ?bool $playerEffects,
44 private ?bool $alignTargetAndCameraForward,
45 private ?bool $aimAssist,
46 ){}
47
48 public function getName() : string{ return $this->name; }
49
50 public function getParent() : string{ return $this->parent; }
51
52 public function getXPosition() : ?float{ return $this->xPosition; }
53
54 public function getYPosition() : ?float{ return $this->yPosition; }
55
56 public function getZPosition() : ?float{ return $this->zPosition; }
57
58 public function getPitch() : ?float{ return $this->pitch; }
59
60 public function getYaw() : ?float{ return $this->yaw; }
61
62 public function getRotationSpeed() : ?float { return $this->rotationSpeed; }
63
64 public function getSnapToTarget() : ?bool { return $this->snapToTarget; }
65
66 public function getHorizontalRotationLimit() : ?Vector2{ return $this->horizontalRotationLimit; }
67
68 public function getVerticalRotationLimit() : ?Vector2{ return $this->verticalRotationLimit; }
69
70 public function getContinueTargeting() : ?bool{ return $this->continueTargeting; }
71
72 public function getBlockListeningRadius() : ?float{ return $this->blockListeningRadius; }
73
74 public function getViewOffset() : ?Vector2{ return $this->viewOffset; }
75
76 public function getEntityOffset() : ?Vector3{ return $this->entityOffset; }
77
78 public function getRadius() : ?float{ return $this->radius; }
79
80 public function getAudioListenerType() : ?int{ return $this->audioListenerType; }
81
82 public function getPlayerEffects() : ?bool{ return $this->playerEffects; }
83
84 public function getAlignTargetAndCameraForward() : ?bool{ return $this->alignTargetAndCameraForward; }
85
86 public function getAimAssist() : ?bool{ return $this->aimAssist; }
87
88 public static function read(PacketSerializer $in) : self{
89 $name = $in->getString();
90 $parent = $in->getString();
91 $xPosition = $in->readOptional($in->getLFloat(...));
92 $yPosition = $in->readOptional($in->getLFloat(...));
93 $zPosition = $in->readOptional($in->getLFloat(...));
94 $pitch = $in->readOptional($in->getLFloat(...));
95 $yaw = $in->readOptional($in->getLFloat(...));
96 $rotationSpeed = $in->readOptional($in->getLFloat(...));
97 $snapToTarget = $in->readOptional($in->getBool(...));
98 $horizontalRotationLimit = $in->readOptional($in->getVector2(...));
99 $verticalRotationLimit = $in->readOptional($in->getVector2(...));
100 $continueTargeting = $in->readOptional($in->getBool(...));
101 $blockListeningRadius = $in->readOptional($in->getLFloat(...));
102 $viewOffset = $in->readOptional($in->getVector2(...));
103 $entityOffset = $in->readOptional($in->getVector3(...));
104 $radius = $in->readOptional($in->getLFloat(...));
105 $audioListenerType = $in->readOptional($in->getByte(...));
106 $playerEffects = $in->readOptional($in->getBool(...));
107 $alignTargetAndCameraForward = $in->readOptional($in->getBool(...));
108 $aimAssist = $in->readOptional($in->getBool(...));
109
110 return new self(
111 $name,
112 $parent,
113 $xPosition,
114 $yPosition,
115 $zPosition,
116 $pitch,
117 $yaw,
118 $rotationSpeed,
119 $snapToTarget,
120 $horizontalRotationLimit,
121 $verticalRotationLimit,
122 $continueTargeting,
123 $blockListeningRadius,
124 $viewOffset,
125 $entityOffset,
126 $radius,
127 $audioListenerType,
128 $playerEffects,
129 $alignTargetAndCameraForward,
130 $aimAssist
131 );
132 }
133
134 public function write(PacketSerializer $out) : void{
135 $out->putString($this->name);
136 $out->putString($this->parent);
137 $out->writeOptional($this->xPosition, $out->putLFloat(...));
138 $out->writeOptional($this->yPosition, $out->putLFloat(...));
139 $out->writeOptional($this->zPosition, $out->putLFloat(...));
140 $out->writeOptional($this->pitch, $out->putLFloat(...));
141 $out->writeOptional($this->yaw, $out->putLFloat(...));
142 $out->writeOptional($this->rotationSpeed, $out->putLFloat(...));
143 $out->writeOptional($this->snapToTarget, $out->putBool(...));
144 $out->writeOptional($this->horizontalRotationLimit, $out->putVector2(...));
145 $out->writeOptional($this->verticalRotationLimit, $out->putVector2(...));
146 $out->writeOptional($this->continueTargeting, $out->putBool(...));
147 $out->writeOptional($this->blockListeningRadius, $out->putLFloat(...));
148 $out->writeOptional($this->viewOffset, $out->putVector2(...));
149 $out->writeOptional($this->entityOffset, $out->putVector3(...));
150 $out->writeOptional($this->radius, $out->putLFloat(...));
151 $out->writeOptional($this->audioListenerType, $out->putByte(...));
152 $out->writeOptional($this->playerEffects, $out->putBool(...));
153 $out->writeOptional($this->alignTargetAndCameraForward, $out->putBool(...));
154 $out->writeOptional($this->aimAssist, $out->putBool(...));
155 }
156}