x = $x; $this->y = $y; $this->weight = $weight; $this->isWalkable = $isWalkable; } /** * Can this node be walked on? * * @return bool * * @since 1.0.0 */ public function isWalkable() : bool { return $this->isWalkable; } /** * Get the cost to walk on this node * * @return float * * @since 1.0.0 */ public function getWeight() : float { return $this->weight; } /** * Get x-coordinate * * @return int * * @since 1.0.0 */ public function getX() : int { return $this->x; } /** * Get y-coordinate * * @return int * * @since 1.0.0 */ public function getY() : int { return $this->y; } /** * Set parent node * * @param null|Node $node Parent node * * @return void * * @since 1.0.0 */ public function setParent(?Node $node) : void { $this->parent = $node; } /** * Get parent node * * @return null|Node * * @since 1.0.0 */ public function getParent() : ?Node { return $this->parent; } /** * Is node equal to another node? * * @param Node $node Node to compare to * * @return bool * * @since 1.0.0 */ public function isEqual(Node $node) : bool { return $this->x === $node->getX() && $this->y === $node->getY(); } /** * Get the coordinates of this node. * * @return array ['x' => ?, 'y' => ?] * * @since 1.0.0 */ public function getCoordinates() : array { return ['x' => $this->x, 'y' => $this->y]; } }