PocketMine-MP 5.44.3 git-fe9f8bd801530ee23ac8e6fb9d8a1922846d5aff
Loading...
Searching...
No Matches
CameraSetInstructionEaseType.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 function array_flip;
18
20
21 private function __construct(){
22 //NOOP
23 }
24
25 public const LINEAR = 0;
26 public const SPRING = 1;
27 public const IN_QUAD = 2;
28 public const OUT_QUAD = 3;
29 public const IN_OUT_QUAD = 4;
30 public const IN_CUBIC = 5;
31 public const OUT_CUBIC = 6;
32 public const IN_OUT_CUBIC = 7;
33 public const IN_QUART = 8;
34 public const OUT_QUART = 9;
35 public const IN_OUT_QUART = 10;
36 public const IN_QUINT = 11;
37 public const OUT_QUINT = 12;
38 public const IN_OUT_QUINT = 13;
39 public const IN_SINE = 14;
40 public const OUT_SINE = 15;
41 public const IN_OUT_SINE = 16;
42 public const IN_EXPO = 17;
43 public const OUT_EXPO = 18;
44 public const IN_OUT_EXPO = 19;
45 public const IN_CIRC = 20;
46 public const OUT_CIRC = 21;
47 public const IN_OUT_CIRC = 22;
48 public const IN_BOUNCE = 23;
49 public const OUT_BOUNCE = 24;
50 public const IN_OUT_BOUNCE = 25;
51 public const IN_BACK = 26;
52 public const OUT_BACK = 27;
53 public const IN_OUT_BACK = 28;
54 public const IN_ELASTIC = 29;
55 public const OUT_ELASTIC = 30;
56 public const IN_OUT_ELASTIC = 31;
57
58 private const EASE_TYPE_NAMES = [
59 self::LINEAR => 'linear',
60 self::SPRING => 'spring',
61 self::IN_SINE => 'in_sine',
62 self::OUT_SINE => 'out_sine',
63 self::IN_OUT_SINE => 'in_out_sine',
64 self::IN_QUAD => 'in_quad',
65 self::OUT_QUAD => 'out_quad',
66 self::IN_OUT_QUAD => 'in_out_quad',
67 self::IN_CUBIC => 'in_cubic',
68 self::OUT_CUBIC => 'out_cubic',
69 self::IN_OUT_CUBIC => 'in_out_cubic',
70 self::IN_QUART => 'in_quart',
71 self::OUT_QUART => 'out_quart',
72 self::IN_OUT_QUART => 'in_out_quart',
73 self::IN_QUINT => 'in_quint',
74 self::OUT_QUINT => 'out_quint',
75 self::IN_OUT_QUINT => 'in_out_quint',
76 self::IN_EXPO => 'in_expo',
77 self::OUT_EXPO => 'out_expo',
78 self::IN_OUT_EXPO => 'in_out_expo',
79 self::IN_CIRC => 'in_circ',
80 self::OUT_CIRC => 'out_circ',
81 self::IN_OUT_CIRC => 'in_out_circ',
82 self::IN_BACK => 'in_back',
83 self::OUT_BACK => 'out_back',
84 self::IN_OUT_BACK => 'in_out_back',
85 self::IN_ELASTIC => 'in_elastic',
86 self::OUT_ELASTIC => 'out_elastic',
87 self::IN_OUT_ELASTIC => 'in_out_elastic',
88 self::IN_BOUNCE => 'in_bounce',
89 self::OUT_BOUNCE => 'out_bounce',
90 self::IN_OUT_BOUNCE => 'in_out_bounce'
91 ];
92
93 public static function toName(int $value) : string{
94 return self::EASE_TYPE_NAMES[$value] ?? throw new \InvalidArgumentException("Invalid raw value \"$value\" for EaseType.");
95 }
96
97 public static function fromName(string $name) : int{
98 static $cache = null;
99 if($cache === null){
100 $cache = array_flip(self::EASE_TYPE_NAMES);
101 }
102
103 return $cache[$name] ?? throw new \InvalidArgumentException("Invalid raw value \"$name\" for EaseType.");
104 }
105}