PocketMine-MP 5.42.2 git-88c18cd9cf7fc37bd5261e6f29ed6041bfe776f1
Loading...
Searching...
No Matches
CameraProgressOption.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 $value,
30 private float $time,
31 int|string $easeType,
32 ){
33 $this->easeType = is_int($easeType) ? CameraSetInstructionEaseType::toName($easeType) : $easeType;
34 }
35
36 public function getValue() : float{ return $this->value; }
37
38 public function getTime() : float{ return $this->time; }
39
43 public function getEaseType() : string{ return $this->easeType; }
44
45 public static function read(ByteBufferReader $in) : self{
46 $value = LE::readFloat($in);
47 $time = LE::readFloat($in);
48 $easeType = CommonTypes::getString($in);
49
50 return new self(
51 $value,
52 $time,
53 $easeType
54 );
55 }
56
57 public function write(ByteBufferWriter $out) : void{
58 LE::writeFloat($out, $this->value);
59 LE::writeFloat($out, $this->time);
60 CommonTypes::putString($out, $this->easeType);
61 }
62}