25 use GetTypeIdFromConstTrait;
27 public const ID = PrimitiveShapeType::PAYLOAD_TYPE_TEXT;
29 public function __construct(
31 private bool $useRotation,
32 private ?
Color $backgroundColor,
33 private bool $depthTest,
34 private bool $showBackface,
35 private bool $showTextBackface,
38 public function getText() :
string{
return $this->text; }
40 public function useRotation() :
bool{
return $this->useRotation; }
42 public function getBackgroundColor() : ?
Color{
return $this->backgroundColor; }
44 public function hasDepthTest() :
bool{
return $this->depthTest; }
46 public function hasShowBackface() :
bool{
return $this->showBackface; }
48 public function hasShowTextBackface() :
bool{
return $this->showTextBackface; }
50 public static function read(ByteBufferReader $in) :
self{
51 $text = CommonTypes::getString($in);
52 $useRotation = CommonTypes::getBool($in);
53 $backgroundColor = CommonTypes::readOptional($in, fn() => Color::fromARGB(LE::readUnsignedInt($in)));
54 $depthTest = CommonTypes::getBool($in);
55 $showBackface = CommonTypes::getBool($in);
56 $showTextBackface = CommonTypes::getBool($in);
58 return new self($text, $useRotation, $backgroundColor, $depthTest, $showBackface, $showTextBackface,);
61 public function write(ByteBufferWriter $out) :
void{
62 CommonTypes::putString($out, $this->text);
63 CommonTypes::putBool($out, $this->useRotation);
64 CommonTypes::writeOptional($out, $this->backgroundColor, fn(ByteBufferWriter $out,
Color $color) => LE::writeUnsignedInt($out, $color->
toARGB()));
65 CommonTypes::putBool($out, $this->depthTest);
66 CommonTypes::putBool($out, $this->showBackface);
67 CommonTypes::putBool($out, $this->showTextBackface);