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;
$z = $blockZ;
if($j === Facing::WEST){
--$x;
}elseif($j === Facing::EAST){
++$x;
}elseif($j === Facing::NORTH){
--$z;
}elseif($j === Facing::SOUTH){
++$z;
}
match($j){
Facing::WEST => --$x,
Facing::EAST => ++$x,
Facing::NORTH => --$z,
Facing::SOUTH => ++$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))){
@ -116,15 +113,12 @@ final class MinimumCostFlowCalculator{
$y = $originY;
$z = $originZ;
if($j === Facing::WEST){
--$x;
}elseif($j === Facing::EAST){
++$x;
}elseif($j === Facing::NORTH){
--$z;
}elseif($j === Facing::SOUTH){
++$z;
}
match($j){
Facing::WEST => --$x,
Facing::EAST => ++$x,
Facing::NORTH => --$z,
Facing::SOUTH => ++$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;