|
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(); |
|
80
|
|
|
$this->specialDataProviders[PanelLayerEnum::SUBSPACE_SIGNATURES->value] = $this->subspaceDataProviderFactory->getDataProvider($id, $type); |
|
81
|
|
|
|
|
82
|
|
|
return $this; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
5 |
|
#[Override] |
|
86
|
|
|
public function addShipCountLayer( |
|
87
|
|
|
bool $showCloakedEverywhere, |
|
88
|
|
|
?Spacecraft $currentSpacecraft, |
|
89
|
|
|
SpacecraftCountLayerTypeEnum $type, |
|
90
|
|
|
int $id |
|
91
|
|
|
): PanelLayerCreationInterface { |
|
92
|
5 |
|
$this->layers[PanelLayerEnum::SPACECRAFT_COUNT->value] = new SpacecraftCountLayerRenderer($showCloakedEverywhere, $currentSpacecraft); |
|
93
|
5 |
|
$this->specialDataProviders[PanelLayerEnum::SPACECRAFT_COUNT->value] = $this->shipcountDataProviderFactory->getDataProvider($id, $type); |
|
94
|
|
|
|
|
95
|
5 |
|
return $this; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
1 |
|
#[Override] |
|
99
|
|
|
public function addBorderLayer(?SpacecraftWrapperInterface $currentWrapper, ?bool $isOnShipLevel): PanelLayerCreationInterface |
|
100
|
|
|
{ |
|
101
|
1 |
|
$this->layers[PanelLayerEnum::BORDER->value] = new BorderLayerRenderer($currentWrapper, $isOnShipLevel); |
|
102
|
1 |
|
$this->specialDataProviders[PanelLayerEnum::BORDER->value] = $this->borderDataProviderFactory->getDataProvider($currentWrapper, $isOnShipLevel); |
|
103
|
|
|
|
|
104
|
1 |
|
return $this; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
5 |
|
#[Override] |
|
108
|
|
|
public function addAnomalyLayer(): PanelLayerCreationInterface |
|
109
|
|
|
{ |
|
110
|
5 |
|
$this->layers[PanelLayerEnum::ANOMALIES->value] = new AnomalyLayerRenderer(); |
|
111
|
|
|
|
|
112
|
5 |
|
return $this; |
|
113
|
|
|
} |
|
114
|
|
|
|
|
115
|
5 |
|
#[Override] |
|
116
|
|
|
public function build(AbstractVisualPanel $panel, ?Location $observerLocation = null): PanelLayers |
|
117
|
|
|
{ |
|
118
|
5 |
|
$layers = $this->layers; |
|
119
|
5 |
|
$this->layers = []; |
|
120
|
|
|
|
|
121
|
5 |
|
return $this->createLayers($layers, $panel, $observerLocation); |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** @param array<int, LayerRendererInterface> $layers */ |
|
125
|
5 |
|
private function createLayers(array $layers, AbstractVisualPanel $panel, ?Location $observerLocation): PanelLayers |
|
126
|
|
|
{ |
|
127
|
5 |
|
$lssBlockadeGrid = $observerLocation !== null ? $this->lssBlockadeGridFactory->createLssBlockadeGrid($observerLocation, $panel) : null; |
|
128
|
5 |
|
$result = new PanelLayers($panel, $lssBlockadeGrid); |
|
129
|
|
|
|
|
130
|
5 |
|
foreach ($layers as $layerType => $renderer) { |
|
131
|
|
|
|
|
132
|
5 |
|
if (!in_array($layerType, self::$skippedLayers)) { |
|
133
|
5 |
|
$result->addLayer(PanelLayerEnum::from($layerType), new PanelLayer($this->getDataProvider($layerType)->loadData( |
|
134
|
5 |
|
$panel->getBoundaries() |
|
135
|
5 |
|
), $renderer)); |
|
136
|
|
|
} |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
5 |
|
return $result; |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
5 |
|
private function getDataProvider(int $layerType): PanelLayerDataProviderInterface |
|
143
|
|
|
{ |
|
144
|
5 |
|
if (array_key_exists($layerType, $this->specialDataProviders)) { |
|
145
|
5 |
|
return $this->specialDataProviders[$layerType]; |
|
146
|
|
|
} |
|
147
|
|
|
|
|
148
|
5 |
|
if (!array_key_exists($layerType, $this->dataProviders)) { |
|
149
|
|
|
throw new RuntimeException(sprintf('no layer data provider existent for type: %d', $layerType)); |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
5 |
|
return $this->dataProviders[$layerType]; |
|
153
|
|
|
} |
|
154
|
|
|
} |
|
155
|
|
|
|
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