mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-28 06:09:57 +00:00
MinimumCostFlowCalculator: Use match statements where possible
coincidentally, this also fixes the build.
This commit is contained in:
parent
a9c4238c59
commit
027f7e249b
@ -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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user