pocketmine\entity\Living::getLineOfSight PHP Method

getLineOfSight() public method

public getLineOfSight ( integer $maxDistance, integer $maxLength, array $transparent = [] ) : Block[]
$maxDistance integer
$maxLength integer
$transparent array
return pocketmine\block\Block[]
    public function getLineOfSight($maxDistance, $maxLength = 0, array $transparent = [])
    {
        if ($maxDistance > 120) {
            $maxDistance = 120;
        }
        if (count($transparent) === 0) {
            $transparent = null;
        }
        $blocks = [];
        $nextIndex = 0;
        $itr = new BlockIterator($this->level, $this->getPosition(), $this->getDirectionVector(), $this->getEyeHeight(), $maxDistance);
        while ($itr->valid()) {
            $itr->next();
            $block = $itr->current();
            $blocks[$nextIndex++] = $block;
            if ($maxLength !== 0 and count($blocks) > $maxLength) {
                array_shift($blocks);
                --$nextIndex;
            }
            $id = $block->getId();
            if ($transparent === null) {
                if ($id !== 0) {
                    break;
                }
            } else {
                if (!isset($transparent[$id])) {
                    break;
                }
            }
        }
        return $blocks;
    }