MinimumCostFlowCalculator: Use match statements where possible

coincidentally, this also fixes the build.
This commit is contained in:
Dylan K. Taylor 2021-09-18 16:17:08 +01:00
parent a9c4238c59
commit 027f7e249b
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -63,15 +63,12 @@ final class MinimumCostFlowCalculator{
$y = $blockY; $y = $blockY;
$z = $blockZ; $z = $blockZ;
if($j === Facing::WEST){ match($j){
--$x; Facing::WEST => --$x,
}elseif($j === Facing::EAST){ Facing::EAST => ++$x,
++$x; Facing::NORTH => --$z,
}elseif($j === Facing::NORTH){ Facing::SOUTH => ++$z
--$z; };
}elseif($j === Facing::SOUTH){
++$z;
}
if(!isset($this->flowCostVisited[$hash = World::blockHash($x, $y, $z)])){ if(!isset($this->flowCostVisited[$hash = World::blockHash($x, $y, $z)])){
if(!$this->world->isInWorld($x, $y, $z) || !$this->canFlowInto($this->world->getBlockAt($x, $y, $z))){ if(!$this->world->isInWorld($x, $y, $z) || !$this->canFlowInto($this->world->getBlockAt($x, $y, $z))){
@ -116,15 +113,12 @@ final class MinimumCostFlowCalculator{
$y = $originY; $y = $originY;
$z = $originZ; $z = $originZ;
if($j === Facing::WEST){ match($j){
--$x; Facing::WEST => --$x,
}elseif($j === Facing::EAST){ Facing::EAST => ++$x,
++$x; Facing::NORTH => --$z,
}elseif($j === Facing::NORTH){ Facing::SOUTH => ++$z
--$z; };
}elseif($j === Facing::SOUTH){
++$z;
}
if(!$this->world->isInWorld($x, $y, $z) || !$this->canFlowInto($this->world->getBlockAt($x, $y, $z))){ if(!$this->world->isInWorld($x, $y, $z) || !$this->canFlowInto($this->world->getBlockAt($x, $y, $z))){
$this->flowCostVisited[World::blockHash($x, $y, $z)] = self::BLOCKED; $this->flowCostVisited[World::blockHash($x, $y, $z)] = self::BLOCKED;