PocketMine-MP 5.42.2 git-40e2639b20bdc4ddba49d9f7f5fa0d5e92aa266f
Loading...
Searching...
No Matches
CameraFovInstruction.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
17use pmmp\encoding\ByteBufferReader;
18use pmmp\encoding\ByteBufferWriter;
19use pmmp\encoding\LE;
21use function is_int;
22
24
26 private string $easeType;
27
28 public function __construct(
29 private float $fieldOfView,
30 private float $easeTime,
31 int|string $easeType,
32 private bool $clear,
33 ){
34 $this->easeType = is_int($easeType) ? CameraSetInstructionEaseType::toName($easeType) : $easeType;
35 }
36
37 public function getFieldOfView() : float{ return $this->fieldOfView; }
38
39 public function getEaseTime() : float{ return $this->easeTime; }
40
44 public function getEaseType() : string{ return $this->easeType; }
45
46 public function getClear() : bool{ return $this->clear; }
47
48 public static function read(ByteBufferReader $in) : self{
49 $fieldOfView = LE::readFloat($in);
50 $easeTime = LE::readFloat($in);
51 $easeType = CommonTypes::getString($in);
52 $clear = CommonTypes::getBool($in);
53
54 return new self(
55 $fieldOfView,
56 $easeTime,
57 $easeType,
58 $clear
59 );
60 }
61
62 public function write(ByteBufferWriter $out) : void{
63 LE::writeFloat($out, $this->fieldOfView);
64 LE::writeFloat($out, $this->easeTime);
65 CommonTypes::putString($out, $this->easeType);
66 CommonTypes::putBool($out, $this->clear);
67 }
68}