|
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
|
48 |
|
public function __construct(private bool $showCloakedEverywhere, private ?SpacecraftInterface $currentSpacecraft) {} |
|
17
|
|
|
|
|
18
|
|
|
/** @param SpacecraftCountData $data */ |
|
19
|
48 |
|
#[Override] |
|
20
|
|
|
public function render(CellDataInterface $data, PanelAttributesInterface $panel): string |
|
21
|
|
|
{ |
|
22
|
48 |
|
$displayCount = $this->getDisplayCount($data); |
|
23
|
48 |
|
if ($displayCount === null) { |
|
24
|
16 |
|
return ''; |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
36 |
|
return sprintf( |
|
28
|
36 |
|
'<div style="%s z-index: %d;" class="centered">%s</div>', |
|
29
|
36 |
|
$panel->getFontSize(), |
|
30
|
36 |
|
PanelLayerEnum::SPACECRAFT_COUNT->value, |
|
31
|
36 |
|
$displayCount |
|
32
|
36 |
|
); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
48 |
|
private function getDisplayCount(SpacecraftCountData $data): ?string |
|
36
|
|
|
{ |
|
37
|
48 |
|
if (!$data->isEnabled()) { |
|
38
|
1 |
|
return null; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
47 |
|
$spacecraftCount = $data->getSpacecraftCount(); |
|
42
|
47 |
|
if ($spacecraftCount > 0) { |
|
43
|
6 |
|
return $data->isDubious() ? '!' : (string) $spacecraftCount; |
|
44
|
|
|
} |
|
45
|
45 |
|
if ($data->hasCloakedShips()) { |
|
46
|
40 |
|
if ($this->showCloakedEverywhere) { |
|
47
|
2 |
|
return $data->isDubious() ? '!' : "?"; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
38 |
|
$currentSpacecraft = $this->currentSpacecraft; |
|
51
|
|
|
|
|
52
|
|
|
if ( |
|
53
|
38 |
|
$currentSpacecraft !== null |
|
54
|
38 |
|
&& $currentSpacecraft->getTachyonState() |
|
55
|
38 |
|
&& abs($data->getPosX() - $currentSpacecraft->getPosX()) <= $this->getTachyonRange($currentSpacecraft) |
|
56
|
38 |
|
&& abs($data->getPosY() - $currentSpacecraft->getPosY()) <= $this->getTachyonRange($currentSpacecraft) |
|
57
|
|
|
) { |
|
58
|
28 |
|
return $data->isDubious() ? '!' : "?"; |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
15 |
|
return null; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
36 |
|
private function getTachyonRange(SpacecraftInterface $spacecraft): int |
|
65
|
|
|
{ |
|
66
|
36 |
|
return $spacecraft->isStation() ? 7 : 3; |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|
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