PocketMine-MP 5.21.2 git-b2aa6396c3cc2cafdd815eacc360e1ad89599899
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 ?Vector2 $viewOffset,
39 private ?Vector3 $entityOffset,
40 private ?float $radius,
41 private ?int $audioListenerType,
42 private ?bool $playerEffects,
43 private ?bool $alignTargetAndCameraForward
44 ){}
45
46 public function getName() : string{ return $this->name; }
47
48 public function getParent() : string{ return $this->parent; }
49
50 public function getXPosition() : ?float{ return $this->xPosition; }
51
52 public function getYPosition() : ?float{ return $this->yPosition; }
53
54 public function getZPosition() : ?float{ return $this->zPosition; }
55
56 public function getPitch() : ?float{ return $this->pitch; }
57
58 public function getYaw() : ?float{ return $this->yaw; }
59
60 public function getRotationSpeed() : ?float { return $this->rotationSpeed; }
61
62 public function getSnapToTarget() : ?bool { return $this->snapToTarget; }
63
64 public function getHorizontalRotationLimit() : ?Vector2{ return $this->horizontalRotationLimit; }
65
66 public function getVerticalRotationLimit() : ?Vector2{ return $this->verticalRotationLimit; }
67
68 public function getContinueTargeting() : ?bool{ return $this->continueTargeting; }
69
70 public function getViewOffset() : ?Vector2{ return $this->viewOffset; }
71
72 public function getEntityOffset() : ?Vector3{ return $this->entityOffset; }
73
74 public function getRadius() : ?float{ return $this->radius; }
75
76 public function getAudioListenerType() : ?int{ return $this->audioListenerType; }
77
78 public function getPlayerEffects() : ?bool{ return $this->playerEffects; }
79
80 public function getAlignTargetAndCameraForward() : ?bool{ return $this->alignTargetAndCameraForward; }
81
82 public static function read(PacketSerializer $in) : self{
83 $name = $in->getString();
84 $parent = $in->getString();
85 $xPosition = $in->readOptional($in->getLFloat(...));
86 $yPosition = $in->readOptional($in->getLFloat(...));
87 $zPosition = $in->readOptional($in->getLFloat(...));
88 $pitch = $in->readOptional($in->getLFloat(...));
89 $yaw = $in->readOptional($in->getLFloat(...));
90 $rotationSpeed = $in->readOptional($in->getLFloat(...));
91 $snapToTarget = $in->readOptional($in->getBool(...));
92 $horizontalRotationLimit = $in->readOptional($in->getVector2(...));
93 $verticalRotationLimit = $in->readOptional($in->getVector2(...));
94 $continueTargeting = $in->readOptional($in->getBool(...));
95 $viewOffset = $in->readOptional($in->getVector2(...));
96 $entityOffset = $in->readOptional($in->getVector3(...));
97 $radius = $in->readOptional($in->getLFloat(...));
98 $audioListenerType = $in->readOptional($in->getByte(...));
99 $playerEffects = $in->readOptional($in->getBool(...));
100 $alignTargetAndCameraForward = $in->readOptional($in->getBool(...));
101
102 return new self(
103 $name,
104 $parent,
105 $xPosition,
106 $yPosition,
107 $zPosition,
108 $pitch,
109 $yaw,
110 $rotationSpeed,
111 $snapToTarget,
112 $horizontalRotationLimit,
113 $verticalRotationLimit,
114 $continueTargeting,
115 $viewOffset,
116 $entityOffset,
117 $radius,
118 $audioListenerType,
119 $playerEffects,
120 $alignTargetAndCameraForward
121 );
122 }
123
124 public function write(PacketSerializer $out) : void{
125 $out->putString($this->name);
126 $out->putString($this->parent);
127 $out->writeOptional($this->xPosition, $out->putLFloat(...));
128 $out->writeOptional($this->yPosition, $out->putLFloat(...));
129 $out->writeOptional($this->zPosition, $out->putLFloat(...));
130 $out->writeOptional($this->pitch, $out->putLFloat(...));
131 $out->writeOptional($this->yaw, $out->putLFloat(...));
132 $out->writeOptional($this->rotationSpeed, $out->putLFloat(...));
133 $out->writeOptional($this->snapToTarget, $out->putBool(...));
134 $out->writeOptional($this->horizontalRotationLimit, $out->putVector2(...));
135 $out->writeOptional($this->verticalRotationLimit, $out->putVector2(...));
136 $out->writeOptional($this->continueTargeting, $out->putBool(...));
137 $out->writeOptional($this->viewOffset, $out->putVector2(...));
138 $out->writeOptional($this->entityOffset, $out->putVector3(...));
139 $out->writeOptional($this->radius, $out->putLFloat(...));
140 $out->writeOptional($this->audioListenerType, $out->putByte(...));
141 $out->writeOptional($this->playerEffects, $out->putBool(...));
142 $out->writeOptional($this->alignTargetAndCameraForward, $out->putBool(...));
143 }
144}