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\Border\BorderDataProviderFactoryInterface; |
13
|
|
|
use Stu\Lib\Map\VisualPanel\Layer\DataProvider\Spacecraftcount\SpacecraftCountDataProviderFactoryInterface; |
14
|
|
|
use Stu\Lib\Map\VisualPanel\Layer\DataProvider\Spacecraftcount\SpacecraftCountLayerTypeEnum; |
15
|
|
|
use Stu\Lib\Map\VisualPanel\Layer\DataProvider\Subspace\SubspaceDataProviderFactoryInterface; |
16
|
|
|
use Stu\Lib\Map\VisualPanel\Layer\DataProvider\Subspace\SubspaceLayerTypeEnum; |
17
|
|
|
use Stu\Lib\Map\VisualPanel\Layer\Render\AnomalyLayerRenderer; |
18
|
|
|
use Stu\Lib\Map\VisualPanel\Layer\Render\BorderLayerRenderer; |
|
|
|
|
19
|
|
|
use Stu\Lib\Map\VisualPanel\Layer\Render\ColonyShieldLayerRenderer; |
20
|
|
|
use Stu\Lib\Map\VisualPanel\Layer\Render\LayerRendererInterface; |
21
|
|
|
use Stu\Lib\Map\VisualPanel\Layer\Render\MapLayerRenderer; |
22
|
|
|
use Stu\Lib\Map\VisualPanel\Layer\Render\SpacecraftCountLayerRenderer; |
23
|
|
|
use Stu\Lib\Map\VisualPanel\Layer\Render\SubspaceLayerRenderer; |
24
|
|
|
use Stu\Lib\Map\VisualPanel\Layer\Render\SystemLayerRenderer; |
|
|
|
|
25
|
|
|
use Stu\Lib\Map\VisualPanel\LssBlockade\LssBlockadeGridFactory; |
26
|
|
|
use Stu\Module\Spacecraft\Lib\SpacecraftWrapperInterface; |
27
|
|
|
use Stu\Orm\Entity\Layer; |
28
|
|
|
use Stu\Orm\Entity\Location; |
29
|
|
|
use Stu\Orm\Entity\Spacecraft; |
30
|
|
|
|
31
|
|
|
final class PanelLayerCreation implements PanelLayerCreationInterface |
32
|
|
|
{ |
33
|
|
|
/** @var array<int, PanelLayerDataProviderInterface> */ |
34
|
|
|
private array $specialDataProviders = []; |
35
|
|
|
|
36
|
|
|
/** @var array<int, LayerRendererInterface> */ |
37
|
|
|
private array $layers = []; |
38
|
|
|
|
39
|
|
|
/** @var array<int> */ |
40
|
|
|
public static array $skippedLayers = []; |
41
|
|
|
|
42
|
|
|
/** @param array<int, PanelLayerDataProviderInterface> $dataProviders */ |
43
|
2 |
|
public function __construct( |
44
|
|
|
private readonly EncodedMapInterface $encodedMap, |
45
|
|
|
private readonly BorderDataProviderFactoryInterface $borderDataProviderFactory, |
46
|
|
|
private readonly SpacecraftCountDataProviderFactoryInterface $shipcountDataProviderFactory, |
47
|
|
|
private readonly SubspaceDataProviderFactoryInterface $subspaceDataProviderFactory, |
48
|
|
|
private readonly LssBlockadeGridFactory $lssBlockadeGridFactory, |
49
|
|
|
private readonly array $dataProviders |
50
|
2 |
|
) {} |
51
|
|
|
|
52
|
4 |
|
#[Override] |
53
|
|
|
public function addSystemLayer(): PanelLayerCreationInterface |
54
|
|
|
{ |
55
|
4 |
|
$this->layers[PanelLayerEnum::SYSTEM->value] = new SystemLayerRenderer(); |
56
|
|
|
|
57
|
4 |
|
return $this; |
58
|
|
|
} |
59
|
|
|
|
60
|
1 |
|
#[Override] |
61
|
|
|
public function addMapLayer(Layer $layer): PanelLayerCreationInterface |
62
|
|
|
{ |
63
|
1 |
|
$this->layers[PanelLayerEnum::MAP->value] = new MapLayerRenderer($layer, $this->encodedMap); |
64
|
|
|
|
65
|
1 |
|
return $this; |
66
|
|
|
} |
67
|
|
|
|
68
|
4 |
|
#[Override] |
69
|
|
|
public function addColonyShieldLayer(): PanelLayerCreationInterface |
70
|
|
|
{ |
71
|
4 |
|
$this->layers[PanelLayerEnum::COLONY_SHIELD->value] = new ColonyShieldLayerRenderer(); |
72
|
|
|
|
73
|
4 |
|
return $this; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
#[Override] |
77
|
|
|
public function addSubspaceLayer(int $id, SubspaceLayerTypeEnum $type): PanelLayerCreationInterface |
78
|
|
|
{ |
79
|
|
|
$this->layers[PanelLayerEnum::SUBSPACE_SIGNATURES->value] = new SubspaceLayerRenderer(PanelLayerEnum::SUBSPACE_SIGNATURES->value); |
80
|
|
|
$this->specialDataProviders[PanelLayerEnum::SUBSPACE_SIGNATURES->value] = $this->subspaceDataProviderFactory->getDataProvider($id, $type); |
81
|
|
|
|
82
|
|
|
return $this; |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
#[Override] |
86
|
|
|
public function addSpacecraftSignatureLayer(int $spacecraftId): PanelLayerCreationInterface |
87
|
|
|
{ |
88
|
|
|
$this->layers[PanelLayerEnum::SPACECRAFT_SIGNATURE->value] = new SubspaceLayerRenderer(PanelLayerEnum::SPACECRAFT_SIGNATURE->value, true); |
89
|
|
|
$this->specialDataProviders[PanelLayerEnum::SPACECRAFT_SIGNATURE->value] = $this->subspaceDataProviderFactory->getDataProvider($spacecraftId, SubspaceLayerTypeEnum::SPACECRAFT_ONLY); |
90
|
|
|
|
91
|
|
|
return $this; |
92
|
|
|
} |
93
|
|
|
|
94
|
5 |
|
#[Override] |
95
|
|
|
public function addShipCountLayer( |
96
|
|
|
bool $showCloakedEverywhere, |
97
|
|
|
?Spacecraft $currentSpacecraft, |
98
|
|
|
SpacecraftCountLayerTypeEnum $type, |
99
|
|
|
int $id |
100
|
|
|
): PanelLayerCreationInterface { |
101
|
5 |
|
$this->layers[PanelLayerEnum::SPACECRAFT_COUNT->value] = new SpacecraftCountLayerRenderer($showCloakedEverywhere, $currentSpacecraft); |
102
|
5 |
|
$this->specialDataProviders[PanelLayerEnum::SPACECRAFT_COUNT->value] = $this->shipcountDataProviderFactory->getDataProvider($id, $type); |
103
|
|
|
|
104
|
5 |
|
return $this; |
105
|
|
|
} |
106
|
|
|
|
107
|
1 |
|
#[Override] |
108
|
|
|
public function addBorderLayer(?SpacecraftWrapperInterface $currentWrapper, ?bool $isOnShipLevel): PanelLayerCreationInterface |
109
|
|
|
{ |
110
|
1 |
|
$this->layers[PanelLayerEnum::BORDER->value] = new BorderLayerRenderer($currentWrapper, $isOnShipLevel); |
111
|
1 |
|
$this->specialDataProviders[PanelLayerEnum::BORDER->value] = $this->borderDataProviderFactory->getDataProvider($currentWrapper, $isOnShipLevel); |
112
|
|
|
|
113
|
1 |
|
return $this; |
114
|
|
|
} |
115
|
|
|
|
116
|
5 |
|
#[Override] |
117
|
|
|
public function addAnomalyLayer(): PanelLayerCreationInterface |
118
|
|
|
{ |
119
|
5 |
|
$this->layers[PanelLayerEnum::ANOMALIES->value] = new AnomalyLayerRenderer(); |
120
|
|
|
|
121
|
5 |
|
return $this; |
122
|
|
|
} |
123
|
|
|
|
124
|
5 |
|
#[Override] |
125
|
|
|
public function build(AbstractVisualPanel $panel, ?Location $observerLocation = null): PanelLayers |
126
|
|
|
{ |
127
|
5 |
|
$layers = $this->layers; |
128
|
5 |
|
$this->layers = []; |
129
|
|
|
|
130
|
5 |
|
return $this->createLayers($layers, $panel, $observerLocation); |
131
|
|
|
} |
132
|
|
|
|
133
|
|
|
/** @param array<int, LayerRendererInterface> $layers */ |
134
|
5 |
|
private function createLayers(array $layers, AbstractVisualPanel $panel, ?Location $observerLocation): PanelLayers |
135
|
|
|
{ |
136
|
5 |
|
$lssBlockadeGrid = $observerLocation !== null ? $this->lssBlockadeGridFactory->createLssBlockadeGrid($observerLocation, $panel) : null; |
137
|
5 |
|
$result = new PanelLayers($panel, $lssBlockadeGrid); |
138
|
|
|
|
139
|
5 |
|
foreach ($layers as $layerType => $renderer) { |
140
|
|
|
|
141
|
5 |
|
if (!in_array($layerType, self::$skippedLayers)) { |
142
|
5 |
|
$result->addLayer(PanelLayerEnum::from($layerType), new PanelLayer($this->getDataProvider($layerType)->loadData( |
143
|
5 |
|
$panel->getBoundaries() |
144
|
5 |
|
), $renderer)); |
145
|
|
|
} |
146
|
|
|
} |
147
|
|
|
|
148
|
5 |
|
return $result; |
149
|
|
|
} |
150
|
|
|
|
151
|
5 |
|
private function getDataProvider(int $layerType): PanelLayerDataProviderInterface |
152
|
|
|
{ |
153
|
5 |
|
if (array_key_exists($layerType, $this->specialDataProviders)) { |
154
|
5 |
|
return $this->specialDataProviders[$layerType]; |
155
|
|
|
} |
156
|
|
|
|
157
|
5 |
|
if (!array_key_exists($layerType, $this->dataProviders)) { |
158
|
|
|
throw new RuntimeException(sprintf('no layer data provider existent for type: %d', $layerType)); |
159
|
|
|
} |
160
|
|
|
|
161
|
5 |
|
return $this->dataProviders[$layerType]; |
162
|
|
|
} |
163
|
|
|
} |
164
|
|
|
|
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