1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Stu\Lib\Map\VisualPanel\Layer\Render; |
6
|
|
|
|
7
|
|
|
use Override; |
|
|
|
|
8
|
|
|
use Stu\Lib\Map\VisualPanel\Layer\Data\CellDataInterface; |
9
|
|
|
use Stu\Lib\Map\VisualPanel\Layer\Data\SpacecraftCountData; |
10
|
|
|
use Stu\Lib\Map\VisualPanel\Layer\PanelLayerEnum; |
11
|
|
|
use Stu\Lib\Map\VisualPanel\PanelAttributesInterface; |
12
|
|
|
use Stu\Orm\Entity\SpacecraftInterface; |
13
|
|
|
|
14
|
|
|
final class SpacecraftCountLayerRenderer implements LayerRendererInterface |
15
|
|
|
{ |
16
|
44 |
|
public function __construct(private bool $showCloakedEverywhere, private ?SpacecraftInterface $currentSpacecraft) {} |
17
|
|
|
|
18
|
|
|
/** @param SpacecraftCountData $data */ |
19
|
44 |
|
#[Override] |
20
|
|
|
public function render(CellDataInterface $data, PanelAttributesInterface $panel): string |
21
|
|
|
{ |
22
|
44 |
|
$displayCount = $this->getDisplayCount($data); |
23
|
44 |
|
if ($displayCount === null) { |
24
|
14 |
|
return ''; |
25
|
|
|
} |
26
|
|
|
|
27
|
34 |
|
return sprintf( |
28
|
34 |
|
'<div style="%s z-index: %d;" class="centered">%s</div>', |
29
|
34 |
|
$panel->getFontSize(), |
30
|
34 |
|
PanelLayerEnum::SPACECRAFT_COUNT->value, |
31
|
34 |
|
$displayCount |
32
|
34 |
|
); |
33
|
|
|
} |
34
|
|
|
|
35
|
44 |
|
private function getDisplayCount(SpacecraftCountData $data): ?string |
36
|
|
|
{ |
37
|
44 |
|
if ($data->getSpacecraftCount() > 0) { |
38
|
5 |
|
return (string) $data->getSpacecraftCount(); |
39
|
|
|
} |
40
|
43 |
|
if ($data->hasCloakedShips()) { |
41
|
39 |
|
if ($this->showCloakedEverywhere) { |
42
|
1 |
|
return "?"; |
43
|
|
|
} |
44
|
|
|
|
45
|
38 |
|
$currentSpacecraft = $this->currentSpacecraft; |
46
|
|
|
|
47
|
|
|
if ( |
48
|
38 |
|
$currentSpacecraft !== null |
49
|
38 |
|
&& $currentSpacecraft->getTachyonState() |
50
|
38 |
|
&& abs($data->getPosX() - $currentSpacecraft->getPosX()) <= $this->getTachyonRange($currentSpacecraft) |
51
|
38 |
|
&& abs($data->getPosY() - $currentSpacecraft->getPosY()) <= $this->getTachyonRange($currentSpacecraft) |
52
|
|
|
) { |
53
|
28 |
|
return "?"; |
54
|
|
|
} |
55
|
|
|
} |
56
|
14 |
|
return null; |
57
|
|
|
} |
58
|
|
|
|
59
|
36 |
|
private function getTachyonRange(SpacecraftInterface $spacecraft): int |
60
|
|
|
{ |
61
|
36 |
|
return $spacecraft->isStation() ? 7 : 3; |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|
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