private function checkForTurn($currentDirection, $newDirection)
{
switch ($currentDirection) {
case Entity::NORTH:
$diff = $this->x - $this->getFloorX();
if ($diff !== 0 and $diff <= 0.5) {
$dx = $this->getFloorX() + 0.5 - $this->x;
$this->move($dx, 0, 0);
return $newDirection;
}
break;
case Entity::SOUTH:
$diff = $this->x - $this->getFloorX();
if ($diff !== 0 and $diff >= 0.5) {
$dx = $this->getFloorX() + 0.5 - $this->x;
$this->move($dx, 0, 0);
return $newDirection;
}
break;
case Entity::EAST:
$diff = $this->z - $this->getFloorZ();
if ($diff !== 0 and $diff <= 0.5) {
$dz = $this->getFloorZ() + 0.5 - $this->z;
$this->move(0, 0, $dz);
return $newDirection;
}
break;
case Entity::WEST:
$diff = $this->z - $this->getFloorZ();
if ($diff !== 0 and $diff >= 0.5) {
$dz = $dz = $this->getFloorZ() + 0.5 - $this->z;
$this->move(0, 0, $dz);
return $newDirection;
}
break;
}
return $currentDirection;
}