|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Stu\Lib\Map\VisualPanel\Layer; |
|
6
|
|
|
|
|
7
|
|
|
use Override; |
|
|
|
|
|
|
8
|
|
|
use RuntimeException; |
|
9
|
|
|
use Stu\Component\Map\EncodedMapInterface; |
|
10
|
|
|
use Stu\Lib\Map\VisualPanel\AbstractVisualPanel; |
|
11
|
|
|
use Stu\Lib\Map\VisualPanel\Layer\DataProvider\PanelLayerDataProviderInterface; |
|
12
|
|
|
use Stu\Lib\Map\VisualPanel\Layer\DataProvider\Shipcount\ShipcountDataProviderFactoryInterface; |
|
13
|
|
|
use Stu\Lib\Map\VisualPanel\Layer\DataProvider\Shipcount\ShipcountLayerTypeEnum; |
|
14
|
|
|
use Stu\Lib\Map\VisualPanel\Layer\DataProvider\Subspace\SubspaceDataProviderFactoryInterface; |
|
15
|
|
|
use Stu\Lib\Map\VisualPanel\Layer\DataProvider\Subspace\SubspaceLayerTypeEnum; |
|
16
|
|
|
use Stu\Lib\Map\VisualPanel\Layer\Render\BorderLayerRenderer; |
|
17
|
|
|
use Stu\Lib\Map\VisualPanel\Layer\Render\ColonyShieldLayerRenderer; |
|
18
|
|
|
use Stu\Lib\Map\VisualPanel\Layer\Render\LayerRendererInterface; |
|
19
|
|
|
use Stu\Lib\Map\VisualPanel\Layer\Render\MapLayerRenderer; |
|
20
|
|
|
use Stu\Lib\Map\VisualPanel\Layer\Render\ShipCountLayerRenderer; |
|
21
|
|
|
use Stu\Lib\Map\VisualPanel\Layer\Render\SubspaceLayerRenderer; |
|
22
|
|
|
use Stu\Lib\Map\VisualPanel\Layer\Render\SystemLayerRenderer; |
|
23
|
|
|
use Stu\Orm\Entity\LayerInterface; |
|
24
|
|
|
use Stu\Orm\Entity\ShipInterface; |
|
25
|
|
|
|
|
26
|
|
|
final class PanelLayerCreation implements PanelLayerCreationInterface |
|
27
|
|
|
{ |
|
28
|
|
|
/** @var array<int, PanelLayerDataProviderInterface> */ |
|
29
|
|
|
private array $specialDataProviders = []; |
|
30
|
|
|
|
|
31
|
|
|
/** @var array<int, LayerRendererInterface> */ |
|
32
|
|
|
private array $layers = []; |
|
33
|
|
|
|
|
34
|
|
|
/** @param array<int, PanelLayerDataProviderInterface> $dataProviders */ |
|
35
|
2 |
|
public function __construct(private EncodedMapInterface $encodedMap, private ShipcountDataProviderFactoryInterface $shipcountDataProviderFactory, private SubspaceDataProviderFactoryInterface $subspaceDataProviderFactory, private array $dataProviders) |
|
36
|
|
|
{ |
|
37
|
2 |
|
} |
|
38
|
|
|
|
|
39
|
|
|
#[Override] |
|
40
|
|
|
public function addSystemLayer(): PanelLayerCreationInterface |
|
41
|
|
|
{ |
|
42
|
|
|
$this->layers[PanelLayerEnum::SYSTEM->value] = new SystemLayerRenderer(); |
|
43
|
|
|
|
|
44
|
|
|
return $this; |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
#[Override] |
|
48
|
|
|
public function addMapLayer(LayerInterface $layer): PanelLayerCreationInterface |
|
49
|
|
|
{ |
|
50
|
|
|
$this->layers[PanelLayerEnum::MAP->value] = new MapLayerRenderer($layer, $this->encodedMap); |
|
51
|
|
|
|
|
52
|
|
|
return $this; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
#[Override] |
|
56
|
|
|
public function addColonyShieldLayer(): PanelLayerCreationInterface |
|
57
|
|
|
{ |
|
58
|
|
|
$this->layers[PanelLayerEnum::COLONY_SHIELD->value] = new ColonyShieldLayerRenderer(); |
|
59
|
|
|
|
|
60
|
|
|
return $this; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
#[Override] |
|
64
|
|
|
public function addSubspaceLayer(int $id, SubspaceLayerTypeEnum $type): PanelLayerCreationInterface |
|
65
|
|
|
{ |
|
66
|
|
|
$this->layers[PanelLayerEnum::SUBSPACE_SIGNATURES->value] = new SubspaceLayerRenderer(); |
|
67
|
|
|
$this->specialDataProviders[PanelLayerEnum::SUBSPACE_SIGNATURES->value] = $this->subspaceDataProviderFactory->getDataProvider($id, $type); |
|
68
|
|
|
|
|
69
|
|
|
return $this; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
#[Override] |
|
73
|
|
|
public function addShipCountLayer( |
|
74
|
|
|
bool $showCloakedEverywhere, |
|
75
|
|
|
?ShipInterface $currentShip, |
|
76
|
|
|
ShipcountLayerTypeEnum $type, |
|
77
|
|
|
int $id |
|
78
|
|
|
): PanelLayerCreationInterface { |
|
79
|
|
|
$this->layers[PanelLayerEnum::SHIP_COUNT->value] = new ShipCountLayerRenderer($showCloakedEverywhere, $currentShip); |
|
80
|
|
|
$this->specialDataProviders[PanelLayerEnum::SHIP_COUNT->value] = $this->shipcountDataProviderFactory->getDataProvider($id, $type); |
|
81
|
|
|
|
|
82
|
|
|
return $this; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
#[Override] |
|
86
|
|
|
public function addBorderLayer(?ShipInterface $currentShip, ?bool $isOnShipLevel): PanelLayerCreationInterface |
|
87
|
|
|
{ |
|
88
|
|
|
$this->layers[PanelLayerEnum::BORDER->value] = new BorderLayerRenderer($currentShip, $isOnShipLevel); |
|
89
|
|
|
|
|
90
|
|
|
return $this; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
#[Override] |
|
94
|
|
|
public function build(AbstractVisualPanel $panel): PanelLayers |
|
95
|
|
|
{ |
|
96
|
|
|
$layers = $this->layers; |
|
97
|
|
|
$this->layers = []; |
|
98
|
|
|
|
|
99
|
|
|
return $this->createLayers($layers, $panel); |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** @param array<int, LayerRendererInterface> $layers */ |
|
103
|
|
|
private function createLayers(array $layers, AbstractVisualPanel $panel): PanelLayers |
|
104
|
|
|
{ |
|
105
|
|
|
$result = new PanelLayers($panel); |
|
106
|
|
|
|
|
107
|
|
|
foreach ($layers as $layerType => $renderer) { |
|
108
|
|
|
$result->addLayer(PanelLayerEnum::from($layerType), new PanelLayer($this->getDataProvider($layerType)->loadData( |
|
109
|
|
|
$panel->getBoundaries() |
|
110
|
|
|
), $renderer)); |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
return $result; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
private function getDataProvider(int $layerType): PanelLayerDataProviderInterface |
|
117
|
|
|
{ |
|
118
|
|
|
if (array_key_exists($layerType, $this->specialDataProviders)) { |
|
119
|
|
|
return $this->specialDataProviders[$layerType]; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
if (!array_key_exists($layerType, $this->dataProviders)) { |
|
123
|
|
|
throw new RuntimeException(sprintf('no layer data provider existent for type: %d', $layerType)); |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
return $this->dataProviders[$layerType]; |
|
127
|
|
|
} |
|
128
|
|
|
} |
|
129
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths