1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Stu\Module\Station\Lib; |
6
|
|
|
|
7
|
|
|
use Stu\Lib\Map\VisualPanel\AbstractVisualPanel; |
8
|
|
|
use Stu\Lib\Map\VisualPanel\Layer\DataProvider\Shipcount\ShipcountLayerTypeEnum; |
9
|
|
|
use Stu\Lib\Map\VisualPanel\Layer\DataProvider\Subspace\SubspaceLayerTypeEnum; |
10
|
|
|
use Stu\Lib\Map\VisualPanel\Layer\PanelLayerCreationInterface; |
11
|
|
|
use Stu\Lib\Map\VisualPanel\PanelBoundaries; |
12
|
|
|
use Stu\Lib\Map\VisualPanel\SystemScanPanelEntry; |
13
|
|
|
use Stu\Module\Logging\LoggerUtilInterface; |
14
|
|
|
use Stu\Orm\Entity\ShipInterface; |
15
|
|
|
use Stu\Orm\Entity\StarSystemInterface; |
16
|
|
|
use Stu\Orm\Entity\UserInterface; |
17
|
|
|
|
18
|
|
|
class SystemScanPanel extends AbstractVisualPanel |
19
|
|
|
{ |
20
|
|
|
private ShipInterface $currentShip; |
21
|
|
|
|
22
|
|
|
private UserInterface $user; |
23
|
|
|
|
24
|
|
|
private StarSystemInterface $system; |
25
|
|
|
|
26
|
|
|
public function __construct( |
27
|
|
|
PanelLayerCreationInterface $panelLayerCreation, |
28
|
|
|
ShipInterface $currentShip, |
29
|
|
|
StarSystemInterface $system, |
30
|
|
|
UserInterface $user, |
31
|
|
|
LoggerUtilInterface $loggerUtil |
32
|
|
|
) { |
33
|
|
|
parent::__construct($panelLayerCreation, $loggerUtil); |
34
|
|
|
|
35
|
|
|
$this->currentShip = $currentShip; |
36
|
|
|
$this->system = $system; |
37
|
|
|
$this->user = $user; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
protected function createBoundaries(): PanelBoundaries |
41
|
|
|
{ |
42
|
|
|
return PanelBoundaries::fromSystem($this->system); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
protected function loadLayers(): void |
46
|
|
|
{ |
47
|
|
|
$panelLayerCreation = $this->panelLayerCreation |
48
|
|
|
->addShipCountLayer($this->currentShip->getTachyonState(), null, ShipcountLayerTypeEnum::ALL, 0) |
49
|
|
|
->addBorderLayer($this->currentShip, $this->system === $this->currentShip->getSystem()); |
50
|
|
|
|
51
|
|
|
$panelLayerCreation |
52
|
|
|
->addSystemLayer() |
53
|
|
|
->addColonyShieldLayer(); |
54
|
|
|
|
55
|
|
|
if ($this->currentShip->getSubspaceState()) { |
56
|
|
|
$panelLayerCreation->addSubspaceLayer($this->user->getId(), SubspaceLayerTypeEnum::IGNORE_USER); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
$this->layers = $panelLayerCreation->build($this); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
protected function getEntryCallable(): callable |
63
|
|
|
{ |
64
|
|
|
return fn (int $x, int $y) => new SystemScanPanelEntry( |
65
|
|
|
$x, |
66
|
|
|
$y, |
67
|
|
|
$this->layers, |
68
|
|
|
$this->system, |
69
|
|
|
); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
protected function getPanelViewportPercentage(): int |
73
|
|
|
{ |
74
|
|
|
return 33; |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|