22declare(strict_types=1);
30 public const MIN_PITCH = 0;
31 public const MAX_PITCH = 24;
33 private int $pitch = self::MIN_PITCH;
37 $tile = $this->position->getWorld()->getTile($this->position);
38 if($tile instanceof TileNote){
39 $this->pitch = $tile->getPitch();
41 $this->pitch = self::MIN_PITCH;
48 parent::writeStateToWorld();
49 $tile = $this->position->getWorld()->getTile($this->position);
50 assert($tile instanceof TileNote);
51 $tile->setPitch($this->pitch);
58 public function getPitch() : int{
64 if($pitch < self::MIN_PITCH || $pitch > self::MAX_PITCH){
65 throw new \InvalidArgumentException(
"Pitch must be in range " . self::MIN_PITCH .
" - " . self::MAX_PITCH);
67 $this->pitch = $pitch;